Skip to content

Instantly share code, notes, and snippets.

Chat Room Navigation Performance — Mitigation Plan

The Problem

Chat room navigation shows higher latency in longer-lived sessions. Production Sentry telemetry (7 days, chat_performance.nav_ms) shows a trend, though the data skews heavily toward fresh sessions:

Session Age p50 nav (ms) p75 nav (ms) p95 nav (ms) Sample size (N) % of total
< 15 min 292 651 1,343 3,935 85.6%
15 min – 1 hr 449 924 1,521 351 7.6%
@nicktanda
nicktanda / announcement-feed-trending-sort-plan.md
Last active May 12, 2026 06:07
Plan: trending sort for announcement feed
@nicktanda
nicktanda / announcement-exclude-from-feed-plan.md
Created May 11, 2026 00:15
Plan: exclude_from_feed for announcements

Plan: "Exclude from feed" checkbox for announcements

Background

  • Announcements are Communication::Message records in announcement rooms.
  • "Requires acknowledgement" is not a column — it's an associated Communication::Acknowledgement record built via the requires_ack= setter (app/models/communication/message.rb:248-252).
  • The aggregated feed is Communication::FeedController rendering app/views/communication/feed/index.html.haml, populated by Communication::Message.announcements_for(users) in app/models/communication/message/threads.rb:75-85.
  • The room view is separate (prepare_announcement_show in app/controllers/concerns/communication/rooms_controller_common.rb:202-211) — excluded announcements should still appear here so they remain pinnable.

Goal

Add an "exclude from feed" checkbox in the announcement creation/edit form. When true, the announcement is hidden from the aggregated feed but still visible inside its room. This option must be mutually exclusive with "

default_scope.where(contract_template_department_joins: { id: nil }).to_sql
'SELECT "contract_templates"."id"
AS t0_r0, "contract_templates"."name"
AS t0_r1, "contract_templates"."description"
AS t0_r2, "contract_templates"."organisation_id"
AS t0_r3, "contract_templates"."created_at"
AS t0_r4, "contract_templates"."updated_at"
AS t0_r5, "contract_templates"."archived"
AS t0_r6, "contract_templates"."onboarding"
AS t0_r7, "contract_templates"."employment_change"
test "#user_roles" do
actual = user_roles(@user).map do |role|
{ name: role.name, description: role.description }
end
expected = [
{ name: "this is a name", description: "this is a description" },
{ name: "this is a name", description: "this is a description" },
{ name: "this is a name", description: "this is a description" }
]
assert_equal exepcted, actual
@nicktanda
nicktanda / gist:e8ffbab0a6f5e6a81ecc90f4ad87f110
Created February 22, 2024 15:30
Weird Turbo Form Submit
%td.bg-white.text-center
= turbo_frame_tag "chargebee_subscription_#{subscription.id}" do
= render partial: "shared/design_components/pill", locals: { type: (subscription.last_invoice_status == "paid") ? "success" : "tertiary", text: subscription.last_invoice_status }
%td.bg-white
= turbo_form_with model: subscription, url: update_chargebee_organisation_path, data: { turbo_frame: "chargebee_subscription_#{subscription.id}" }, method: :post do |f|
= hidden_field_tag :subscription_id, subscription.id
= render "shared/design_components/forms/select", form: f, name: "home_country" do
= select_tag :last_invoice_status, options_for_select(chargebee_statuses, selected: subscription.last_invoice_status), onchange: "this.form.querySelector('.hidden-submit').click()", class: "home_country validated-form-component w-full"
= submit_tag "Submit", class: "hidden-submit", style: "display: none;"
Prefix Verb URI Pattern Controller#Action
external_graphql POST /api/v3(.:format) graphql#api_execute
api_v3_explorer GET /api/v3/explorer(.:format) graphql#api_explorer
internal_graphql POST /graphql(.:format) graphql#app_execute
graphql_explorer GET /graphql/explorer(.:format)
<main class="mb-2 text-gray-600">
<header class="sticky top-0 mx-auto w-full border-b border-gray-200 bg-gray-50 bg-opacity-80 text-left backdrop-blur backdrop-filter">
<div class="mx-auto w-full max-w-5xl">
<!-- <h1 class="px-4 pb-4 pt-8 text-3xl font-bold tracking-tight text-black">Green v The King (1949)</h1> -->
<input class="mx-4 my-4 px-4 py-2 text-3xl font-bold rounded-lg w-6/12 text-gray-900 focus:bg-gray-50" placeholder="Case Name" value="Test"></input>
</div>
<div class="w-full border-t border-gray-200">
<div class="mx-auto w-full max-w-5xl">
<div class="mx-auto grid w-full grid-cols-5 divide-x divide-gray-200 py-3">
<div class="px-4">
@nicktanda
nicktanda / controller.rb
Created October 30, 2023 03:59
WTF Is Happening lol
def update
binding.pry
authorize!(:update, @award)
ActiveRecord::Base.transaction do
update_leave_type if should_update_payroll_leave_type?
update_leave_award
redirect_to(leave_awards_path, notice: t("views.shared_leave_types.leave_form.update_success"))
export default function ReviewContractsModal(props: Props): React.Node {
const [userContracts, setUserContracts] = React.useState<Array<UserContract>>([])
const [automaticFields, setAutomaticFields] = React.useState<Array<DynamicFields>>([])
const [contractAmendments, setContractAmendments] = React.useState<Array<string>>([])
const [currentPage, setCurrentPage] = React.useState(0)
React.useEffect(() => {
setUserContracts(
props.selectedContractTemplates.map((template: ContractTemplate) => createUserContractObject(template))
)