Skip to content

fix(chat): keep row callbacks stable across streamed frames - #23266

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/chat-row-callbacks-stable
Oct 23, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/chat-row-callbacks-stable

Conversation

@JLargent42

@JLargent42 JLargent42 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A long chat stays responsive during an agent turn, instead of freezing the dashboard until it goes blank.

On sessions with long histories (conductors, crewmates), the dashboard stops responding during a turn and goes blank. Every streamed frame (chat_chunk, tool_call, tool_result) re-renders every message already on screen, so the cost grows with the session's length.

Why it matters

Heavy users hit this. Conductors and crewmates with thousands of messages lose the dashboard mid-turn, and only a restart brings it back. It is a P0 oncall report on 0.9.0.4.

Not a goal

What changed (motivation → approach → change)

Symptom → cause → change:

Symptom Each streamed frame re-renders every mounted AssistantMessage and TurnBlock. Measured: about 33,500 bubble renders per 100-tool turn by turn 4.
Cause handleRegenerate, handleEditResend and handleJumpToQuote close over messages. That array is new on every frame. All three are deps of the transcript renderers memo, so every frame rebuilds it and no settled row can skip its render.
Change Each callback reads the page's existing messagesRef instead of messages, so its identity no longer follows the array. ChatPage now hands that ref to useRegenerate and useMessageActions; jumpToLoadedPinnedMessage reads it too. Behaviour is unchanged: each still acts on the newest rows when pressed, and the pending pin-jump effect lists messages itself so it still re-resolves when older rows page in.

Measured on a local gateway with the fake ACP backend (100 tool calls with 20 KB results per turn, headless Chromium):

main this PR
Main thread blocked (long tasks) after 4 turns 18.7 s 2.7 s
6 turns on a 6,000-message session (earlier revision of this fix) 81.5 s, heap 537 MB 6.1 s

Backwards compatibility

Compatible: same callbacks, same arguments, same effects. Only their identity across renders changes.

Removes nothing: no path, key, record or capability is taken away.

Tests

website/src/test/transcriptRowCallbacksStable.test.tsx: for each of the three hooks, the callback keeps its identity when messages changes and still acts on a row only the newer array holds. It fails 3/3 on main and passes with the fix. Determinism: five runs with --sequence.shuffle, all 3/3 green.

Manual verification

Reproduced and measured end to end on a 127.0.0.1-only local gateway with the fake ACP backend, as in the table above. A per-prop memo-compare counter showed no extra AssistantMessage / TurnBlock renders per frame after the fix. The probe was temporary and is not in the diff.

Screenshots / video

Why no screenshot: Only callback identity changes; every rendered pixel is the same.

Related Issues

Closes #23249

Sibling sweep

Swept: git grep -nE "\}, \[[^]]*\bmessages\b[^]]*\]\)" -- website/src/pages/chat/page/, plus a runtime probe that counted which transcript-renderers memo deps change per streamed frame.
Sibling: website/src/pages/chat/page/transcriptPins.ts -- changed here
Sibling: website/src/pages/ChatPage.tsx -- changed here
Sibling: website/src/pages/chat/page/transcriptRendering.tsx -- not affected -- redactionCoachTs memo yields a primitive ts that is stable per frame
Sibling: website/src/pages/chat/page/transcriptJumps.ts -- not affected -- effect deps, not a renderers memo input

Pattern harvest

Rule candidate: lint
Pattern: "a callback passed into a memo that gates many memo() rows lists a per-frame array (e.g. messages) in its deps"

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners October 23, 2026 00:49
@JLargent42
JLargent42 requested a review from mbriones98 October 23, 2026 00:49
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 84d3d6595cfa444779336b76bfc7fbe76a74c2f6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design problems found. The PR uses the page's existing latest-value ref, which is the standard fix for callbacks that rebuild every frame, and it takes nothing away.

[DESIGN-REVIEWED] 84d3d65

Description read

[DESCRIPTION-READ] 886e957aecf6d3a5a2913ac2cece6f81f4139e6c825e965795b05fbad0617f9c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 84d3d6595cfa444779336b76bfc7fbe76a74c2f6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The diff only changes callback identity in chat hooks and adds a test. It adds or changes no user-visible control, string or state, so the missing blind read leaves no evidence gap.

[UX-REVIEWED] 84d3d65

Description read

[DESCRIPTION-READ] 9179feab069ffb2267e30525ff8472cbfa54974835ce5d7e1e98fdc096e938a9

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 84d3d6595cfa444779336b76bfc7fbe76a74c2f6 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix removes the cause by reusing the page's existing messagesRef (activeSlotState.ts:54), and issue #23249 plus a test that fails on base give the defect its provenance.

What this change ships

Inventory (5 items) — 5 justified

Intent: keep a long chat responsive during an agent turn, so the dashboard no longer freezes and goes blank. This is a FIX.

  1. The Regenerate press handler no longer forces every mounted row to re-render on each streamed frame. — justified
  2. The Edit & resend handler no longer forces every mounted row to re-render on each streamed frame. — justified
  3. The jump-to-quoted/pinned-message handler no longer forces every mounted row to re-render on each streamed frame. — justified
  4. A pending pin jump still resolves when older rows page in, because messages is now listed in the effect's own deps. — justified
  5. useRegenerate and useMessageActions each take the page's existing messagesRef, with ChatPage as the one caller. — justified

[FIRST-PRINCIPLES-REVIEWED] 84d3d65

Description read

[DESCRIPTION-READ] c4036942aa1fe29fbf8b3c00cd7f0920f10a1d9f12ddbf2bc00f009929f28914

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 84d3d6595cfa444779336b76bfc7fbe76a74c2f6 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 84d3d65

Verdict parsed from the review's SHA-scoped output markers for commit 84d3d6595cfa444779336b76bfc7fbe76a74c2f6.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 84d3d6595cfa444779336b76bfc7fbe76a74c2f6: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 84d3d6595cfa444779336b76bfc7fbe76a74c2f6 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 84d3d65

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 84d3d6595cfa444779336b76bfc7fbe76a74c2f6: <one-sentence reason>

@JLargent42
JLargent42 force-pushed the fix/chat-row-callbacks-stable branch from 81fc5f7 to 84acd1d Compare October 23, 2026 01:30
@JLargent42

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: per-callback latest-value refs mirroring messages

  • Three new latest-value refs where messagesRef already exists (span=891a37556c01)

fixed in 84acd1d: the three new refs are gone; handleRegenerate, handleEditResend and jumpToLoadedPinnedMessage read the existing messagesRef from activeSlotState.ts.
ChatPage passes messagesRef to useRegenerate and useMessageActions; handleJumpToQuote follows handleJumpToPinnedMessage again, which is now stable because its resolver no longer lists messages.
The pending pin-jump effect lists messages itself, so it still re-resolves when older rows page in (ChatPage.transcriptPins tests green).
Regression test fails 3/3 on main, passes 3/3 here; live repro: 2.7 s of long tasks over 4 x 100-tool turns (main 18.7 s).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/chat-row-callbacks-stable branch from 84acd1d to 84d3d65 Compare October 23, 2026 06:40
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main for the #23264 Windows fix.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 23, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 23, 2026 09:05

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: chat transcript callbacks read messagesRef instead of messages, so streamed frames no longer re-render every mounted row; a new test pins the stable identities.

@KiroCrewCaptain
KiroCrewCaptain merged commit d0aee52 into main Oct 23, 2026
105 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/chat-row-callbacks-stable branch October 23, 2026 09:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat page re-renders every transcript row on every streamed frame, freezing long sessions

2 participants