Skip to content

fix(chat): stop redrawing settled chat rows on every streamed chunk - #20641

Merged
chenmingwei23 merged 2 commits into
mainfrom
fix/crewmate-chat-row-identity
Oct 15, 2026
Merged

chenmingwei23 merged 2 commits into
mainfrom
fix/crewmate-chat-row-identity

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A crewmate chat stops re-rendering every message on screen for each streamed chunk and each keystroke, while every row that changes in place keeps changing.

In a crewmate DM (Crewmates page), every streaming flush re-rendered every mounted transcript row, and so did every keystroke in the composer. ChatPane handed ChatMessageList a new renderer set per flush, the grouping minted a fresh object for every row, and each row's render function closed over the new message list, so no row could bail out. On a 10-second reply this was about 3.4 s of React render time, with the main thread 63-70% busy.

Why it matters

Everyone who chats with a crewmate pays it, whatever dashboard page or template they use; split panes and the app-SDK embed draw through the same list. On a fast machine it shows as CPU use and heat. On a slower one it becomes typing lag: with the page CPU throttled 4x, a keystroke typed while a reply streams took 161 ms to reach the screen at p95, and a 10-second reply produced 116 long tasks (7.7 s in total).

Not a goal

  • No change to layout, row height, row DOM or any interaction.
  • Not the dashboard page in the crewmate's side panel, its own animation cost, or the page refetch that each chat row triggers.
  • Not the main chat page (ChatPage), which already reuses its rows through createTurnGrouper.
  • Not the side chat: it rebuilds every row object from its own buffer on each change, so it renders as it does today.
  • Not the Markdown re-parse of the streaming row itself, which is most of what remains.

What changed (motivation -> approach -> change)

Symptom -> cause. Profiling the DM showed UserMessage, AssistantMessage, CrewmateMessage and TurnBlock rendering several times per chunk for rows that had not changed. Three things defeated every memo boundary under the list: the grouping returned new objects for every row on each flush, the row render function was rebuilt on each flush because it reads messages, and ChatPane rebuilt its whole renderer set per flush because it passed the unfiltered crewmate transcript as an array.

Change.

  • pages/chat/groupDisplayItems.ts: createDisplayItemReconciler() hands a row its previous object when it describes the same message references. createTurnGrouper (the main chat page) now calls it instead of keeping its own copy of that loop, and keeps only its own "every row was reused" check; its output is unchanged.
  • app-sdk/ChatMessageList.tsx: virtualized rows render through a memoized ListRow (no DOM of its own). The row renderers read the message list through a view that changes only with the transcript version, so their identity moves only when something a row can read moves: the host's props, running, or the version. Every other input they close over stays in their own dependency arrays, checked by exhaustive-deps; the list is read through a ref, so a row that does render sees the newest messages.
  • chat-core/transcript/transcriptVersion.ts: the version moves on every change to the message list (a row lands or leaves, a reorder, a role change, any edit to a settled row, history loaded above) except a streaming row's text growing, and a row replaced by an equal copy. Every built-in rule that looks at other rows (reply footer, steer chip, transient notice tense, crewmate run position, error-card scans) reads a streaming row by its role only, so that one change cannot alter another row's output.
  • ListRow calls useLanguageGeneration(), so a language switch redraws reused rows, footer dates included.
  • pages/chat/ThreadFooter.tsx: redraws its "Last reply 2h ago" once a minute. Before, any flush redrew it; a reused row no longer does.
  • components/ChatPane.tsx, components/ChatPaneTranscript.tsx and pages/chat/transcriptRenderers.tsx: the crewmate transcript is handed as a getter whose identity follows the same version, so the renderer set is rebuilt only when the unfiltered rows change. The crewmateTranscript option now takes only a getter; ChatPane is its one caller.
  • docs/app-kit/api-reference.md + MessageRenderContext.messages: the rule an app renderer must follow: read a streaming neighbour by its role, not its text.

Before -> after, measured in Chromium 145 (headless, 1600x1000) on a crewmate DM with a synthetic 1,667-row transcript and a fake backend streaming 500 chunks over about 10 s. The numbers come from an earlier cut of this change. It behaves the same as this head while only the streaming row grows; this head also redraws every mounted row when any other row changes.

Measure Before After
React render time, one 10 s reply (profiling build) 3363 ms 2168 ms (-36%)
React render time, 61 keystrokes while idle 374 ms 241 ms (-36%)
UserMessage renders per chunk / per keystroke 3.64 / 2.03 0.04 / 0
Main thread busy during the reply (profiling build) 63% 50%
CPU 4x: keystroke -> screen while streaming, p95 161 ms 111 ms
CPU 4x: long tasks in one 10 s reply 116 (7.7 s) 22 (1.6 s)
CPU 4x: frames per second 16 21

With the dashboard tab open, React render time for the same reply went 3581 -> 2507 ms (-30%). On an unthrottled fast machine, keystroke latency barely moves (main-thread part 26 -> 25 ms); the gain there is CPU. Samples: 1 profiling run per cell, 2 throttled runs per cell.

Backwards compatibility

Compatible: the row DOM, every prop of ChatMessageList and MessageRenderContext are unchanged. crewmateTranscript, an option of the dashboard's own row set (not App Kit API), now takes a getter where main took an array. Its writers on origin/main @ 10b7fa7 (which includes #20756 and #19903) are components/ChatPane.tsx and two tests, all switched to the getter here; tsc finds no other. One rule is now written down for app renderers: a renderer that reads the text of a streaming row other than its own is not redrawn as that text grows. No built-in renderer does.

Removes nothing: no prop, row or behaviour is taken away; the one option whose type changed keeps every caller working (above); settled rows redraw on fewer occasions, and every occasion that can change a row's output still redraws it.

Tests

  • ChatMessageList.inPlaceRows.test.tsx (new, 11 cases, real row components): while a reply streams below, a settled row still updates for: the reply footer appearing when the turn ends in an error, and moving when a quiet row below is rewritten into words; a replaced message; the steer badge and the reply's "Steered" chip; a tool pill's result and a policy block; the thread footer's count, and its "last reply" age with nothing else changing; a language switch; a theme switch (a reused row's markup equals a freshly mounted one); earlier history loaded above, including a block that holds only an undrawn row; a change card following the card store.
  • ChatPane.crewmateRunReuse.test.tsx (new, 2 cases, real ChatPane and store frames): a crewmate run's corners and footer regroup as a reply joins, streams and settles; a run ended at a patrol wake that the chat does not draw keeps its corners and footer while the next turn streams.
  • ChatPane.crewmateResumeReuse.test.tsx (new, 2 cases, real ChatPane, CrewComposer and the real useChatPaneContinue): fix(chat): offer Resume in a crewmate's chat after a turn ends on a model error #20756 put the error row's Resume state (continuable, interrupted, continuing, onContinue) into the memo that builds the row set. Typing under an offered Resume, and streaming a resumed reply while typing, build no new row set and redraw no settled row; pressing Resume still redraws the error row (its button disables) and the turn starting removes it.
  • ChatMessageList.rowIdentity.test.tsx (new): a flush that only grows the streaming row does not re-render a settled row; a row appended below still updates the settled row's footer.
  • transcriptVersion.test.ts (new): what moves the version and what does not.
  • Mutation check, each guard removed in turn: freezing the versioned view reds 3 cases (a row appended below, a quiet row rewritten, a policy block); keying the redraw on list length and last role reds the "quiet row rewritten" case; dropping the footer clock reds the "last reply age" case; dropping the row's language subscription reds the language case; turning reuse off reds the row-identity case (all 11 in-place cases stay green there, so they hold on today's behaviour too); handing the crewmate rows no unfiltered transcript reds the patrol-wake case; skipping the shared reconcile inside createTurnGrouper reds 3 of its structural-sharing cases; making onContinue a fresh function per render reds both Resume reuse cases.
  • Related suites run locally on the head rebased onto 10b7fa7, 232 files, 3,091 tests passed (1 expected fail): fix(chat): offer Resume in a crewmate's chat after a turn ends on a model error #20756's own specs, the specs fix(app-sdk): keep the embed's error notices from navigating away #19903, feat(app-sdk): give ChatEmbed a stop button for a running turn #19898 and fix: show tool input and output in the chat embed's expanded row #19890 touched (AppSdkMessageRenderersCov80, ChatEmbed.approvalRollback, CollapsibleToolGroupCov80, ChatEmbed.stop, useStopPress) (ChatPane.crewmateResume, useContinuePress, chatSlice.slotResume, ChatPane.featureRequestFallback, useChatPageTurnRecovery) and the new Resume reuse spec, plus every ChatPane.*, ChatEmbed.*, SideChat.*, ChatMessageList.*, MembersPage.*, TurnBlock.*, transcriptRenderers.*, messageRenderers.* and groupDisplayItems.* spec, plus chatCoreTranscript.contract, ChatPane.owners, MemoI18nSubscriptionRatchet, VirtualTranscript, CrewChatWindow and ThreadFooter, and every ChatPage spec, since the main chat page's grouper now runs the shared reconcile. tsc -p tsconfig.app.json and eslint --max-warnings 0 on the changed files are clean. The cross-surface set the doc change pulls in runs in CI on the merge ref.

Manual verification

The before/after numbers were taken in a real browser on the earlier cut described above. This head is covered by the component tests above (happy-dom), not re-measured in a browser.

Screenshots / video

Why no screenshot: Rows render the same DOM as before; only how often a settled row re-renders changes, and a test checks that a reused row's markup equals a freshly mounted one.

Related Issues

Fixes #20518

Pattern harvest

Rule candidate: review-prompt
Pattern: a memoized list row whose render reads its sibling rows must redraw on every sibling change it can read (a whole-list version), never on a hand-picked subset such as the list length or the last row's role.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

Inherited CI red (main breakage, not this PR): test/test_dashboard_server_composition_contract.py::test_the_lazy_imports_stay_inside_the_functions_that_need_them
Failing on main run e492fda (2026-10-15); this PR does not touch that file. Will rebase onto origin/main once main carries a fix.

@chenmingwei23
chenmingwei23 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 06:02
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 85a1846eb189b4ccdee8cf617b026c067daf7557 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Check in a live crewmate DM that settled rows (reply footer, "Steered" chip, Resume button, "Last reply" age) still update while a reply streams.

[UX-REVIEWED] 85a1846

Description read

[DESCRIPTION-READ] 1654af26f8fb71ded86394c471bd359029a8771d8b181a315fdd122aa04c91ac

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 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 85a1846eb189b4ccdee8cf617b026c067daf7557 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Before merge, confirm no shipped App Kit renderer reads a streaming neighbour's text: under the new MessageRenderContext.messages rule, such a renderer now goes stale without any error.

[DESIGN-REVIEWED] 85a1846

Description read

[DESCRIPTION-READ] 33c75b13694f27e26582b17a3a2e26f829d69df1b5387adbdb907f504127a281

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 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 85a1846eb189b4ccdee8cf617b026c067daf7557 — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check one thing before merge: App Kit renderers that read a streaming neighbour's text will no longer redraw while it grows (now documented in api-reference.md).

What this change ships

Inventory (6 items) — 6 justified

Intent: A crewmate chat (and any ChatMessageList transcript mount) stops redrawing every settled row on each streamed chunk and each keystroke. This is a FIX, a performance defect measured in the description.

  1. Settled rows in a crewmate chat, split panes and ChatEmbed no longer redraw on each streamed chunk or keystroke — justified
  2. The main chat's row reuse now goes through a shared reconcile helper (createDisplayItemReconciler, 2 consumers) and shows no change — justified
  3. A thread footer's "Last reply 2h ago" now redraws on its own once a minute — justified
  4. A language switch redraws reused rows through ListRow's subscription — justified
  5. The crewmateTranscript renderer option takes a getter instead of an array (its 1 writer, ChatPane, is switched) — justified
  6. App Kit contract: a renderer that reads a streaming neighbour's text is not redrawn as that text grows. Built-ins read a streaming row by role only (crewmateRunPosition checked) — justified

[FIRST-PRINCIPLES-REVIEWED] 85a1846

Description read

[DESCRIPTION-READ] c64db661d0eea1baf186e457dd7ad228002c5a55a79cbf96105e8a8a6ccc6614

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 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 85a1846eb189b4ccdee8cf617b026c067daf7557 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 85a1846

Verdict parsed from the review's SHA-scoped output markers for commit 85a1846eb189b4ccdee8cf617b026c067daf7557.

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 85a1846eb189b4ccdee8cf617b026c067daf7557 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 85a1846

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from e00b4fc to b421982 Compare October 15, 2026 07:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 15, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at b421982.

The approach reads as sound. Rows get their previous object back from the reconcile, and the renderers move only with a transcript version that changes on every list change except a streaming row growing in place (transcriptVersion.ts L30-L53). The footer gets its own one-minute clock. The new tests cover the in-place updates the memo could have frozen.

Blockers:

  1. CI is still running on this head: backend, frontend and E2E shards, CodeQL and the GPT 6.1 Review lane. PR Readiness is pending. GPT 6.1 has not reported on this head yet.
  2. First Principles CONCERNS item 5 has no reply. crewmateTranscript accepts an array or a getter (transcriptRenderers.tsx L184), but the only production caller passes a getter. Narrow it to the getter and pass () => [row] in the two tests, or post a target=first-principles rebuttal.
  3. Please answer the Design and UX PASS punchlines. Design asks you to confirm no bundled renderer reads a streaming neighbour's text through ctx.messages. UX asks for a live crewmate-DM check that the footer, the Steered chip and the Last reply age still update while a reply streams.

To clear: CI and GPT 6.1 finish green on this head, and items 2 and 3 get dispositions.

— crew-pr-reviewer (r103)

@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 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from b421982 to d9a7690 Compare October 15, 2026 08:14
@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 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from d9a7690 to b23f312 Compare October 15, 2026 09:19
@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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 15, 2026
@chenmingwei23
chenmingwei23 enabled auto-merge (squash) October 15, 2026 10:31
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

HOLD at b421982.

  1. CI is still running on this head [...] GPT 6.1 has not reported on this head yet.
  2. First Principles CONCERNS item 5 has no reply. crewmateTranscript accepts an array or a getter [...] Narrow it to the getter and pass () => [row] in the two tests, or post a target=first-principles rebuttal.
  3. Please answer the Design and UX PASS punchlines. Design asks you to confirm no bundled renderer reads a streaming neighbour's text through ctx.messages. UX asks for a live crewmate-DM check that the footer, the Steered chip and the Last reply age still update while a reply streams.

To clear: CI and GPT 6.1 finish green on this head, and items 2 and 3 get dispositions.

-- crew-pr-reviewer (r103), comment

Dispositions. Everything below is on the current head, b23f312afe.

1. CI and GPT 6.1 on this head: done. GPT 6.1 Review passed at 09:36:17Z, and PR Readiness reported success at 10:09:04Z, both on b23f312afe. No check on that head is failing or pending.

2. First Principles item 5: done in b23f312afe. TranscriptRendererOptions.crewmateTranscript is now only () => ChatMessage[] | undefined; at b421982 it was ChatMessage[] | (() => ChatMessage[] | undefined). crewmateTranscriptOf now just calls it. The two tests pass () => [userRow] and () => [ACKED].

3a. Design: no bundled renderer reads a streaming neighbour's text through ctx.messages.
git grep -n 'ctx\.messages' -- website/src ':!website/src/test' finds 10 call sites. When one of them meets a streaming row, it either checks only the role or skips the row:

Call site Helpers What it reads from a streaming row
messageRenderers.tsx L480-488: the reply footer loop in renderAssistantBubble isHiddenInvisibleAssistantRow, isSystemNoticeRow The role only. Both helpers return false on the role check before they test any content. The loop then counts the row as a reply that follows.
messageRenderers.tsx L519: turnHadPolicyBlock none Nothing. It walks from the row itself up to the turn's user row and acts only on user and inject rows, so it never reaches a streaming row below.
messageRenderers.tsx L693: the SDK error row resolveTransientNotice -> answeredAfter The role only. streaming counts as an answer.
transcriptRenderers.tsx L439 (card row) and L552 (crewmate bubble): crewmateRunPosition neighbour/isRunTransparent, chained/isRunMember/isCrewmateSpeech, isTurnEnvelope (isWorkflowCompletionMessage, isSubagentCompletionMessage), WITHIN_TURN_ROLES The role only. isCrewmateSpeech returns true from the role alone. Both envelope tests check the role before any content and return false. transcript.indexOf compares object identity. isStopCard reads kind/meta.kind, not the text, and either way a streaming row is not run-transparent.
transcriptRenderers.tsx L590: error row resolveTransientNotice The role only.
L608 isFeatureRequestRefusal -> opensTurn Nothing. It walks up from the error row, and opensTurn returns false for the streaming role.
L609 lastErrorIndex The role only (=== 'error').
L618 sessionStartFailureStreak -> isStopEvent, injectOpensTurn Nothing. It passes over the row: none of its stop conditions match. Its content test applies only to user and assistant rows, and isStopEvent reads kind/meta.kind.
L648 contextOverflowIsNewest -> opensTurn Nothing. It passes over the row, because it stops only at an assistant row or at a row that opens a turn.

The rest of the list's reads are covered too:

  • ChatMessageList's own two reads go through versioned. autoDeniedIds checks role === 'tool' before the content, and autoExpand reads only the length, which moves the version.
  • The helpers that get the whole ctx (threadFooterFor, replyInThreadFor, quoteMessageFor, toolRow, toolLine) never read ctx.messages.
  • The two host hooks that get ctx (toolRunning, renderUnparsedFile) belong to ChatPage and never reach ChatMessageList.
  • Outside website/src, git grep 'ctx\.messages' -- ':!website/src' finds nothing. MessageRenderer and MessageRenderContext appear only in docs and specs, in one capture script that imports the default renderers, and in the unrelated Python IMessageRenderer.

3b. UX: a live crewmate-DM check shows the footer, the Steered chip and the Last reply age all update while a reply streams.

Setup:

  • Frontend: a build of b23f312afe (build id 1.0.0-b23f312).
  • Gateway: an isolated gateway bound to loopback, with a fresh throwaway data home and dashboard.crewmate_threads on.
  • Agent: a fake ACP backend. It streams in 4-character chunks and closes a reply part at each tool call. It answers _session/steer the way kiro-cli does: steering_queued, then steering_consumed carrying the <user_message> text.
  • Chat: the DM opens with two settled turns, and the first reply has a thread with two replies.
  • Reads: headless Chromium read every bubble twice on each sample: once from the DOM, and once from React's props for that bubble (isStreaming, showFooter, pos). The same pass also read the list's current messages input. The props and the DOM agreed on 718 of 719 bubble reads. The one disagreement fell inside a commit.

The expected behaviour comes from the code and the matching ChatMessageList.inPlaceRows cases.

Check What I did Expected Result
Footer Turn A: a 4-part reply with 3 tool calls, read every 300 ms (112 reads). A settled bubble shows the footer exactly when it ends its run (single or end). A streaming bubble never does. (forceFooter, crewmateRunPosition; cases 1-2) 0 violations seen in two reads in a row. 7 violations appeared in one read only, each at a commit boundary. Part 1 had no footer while part 2 streamed. The part above the steer got its footer as soon as it settled, while the reply kept streaming below the steer. Part 4 got its footer when the turn ended.
Steered chip Sent a steer with Enter while part 2 streamed. The steer row shows "Steered into the running turn" once the server marks the steer consumed. (case 4) It appeared 545 ms after the send, while the bubble below it was still streaming.
Last reply age Turn B: one 160 s part with no other row changing. I scrolled up to the thread footer. The age moves once a minute on the footer's own clock. (LAST_REPLY_TICK_MS; case 6) It went 5m -> 6m -> 7m during the stream and showed 8m when the turn ended. All 76 reads taken during the stream showed the true age or one minute less. The footer kept the same DOM node the whole time.
Reused vs fresh rows Opened a second tab during turn A and a third during turn B. Reloaded after turn B. Reused rows draw what a fresh mount draws. 33 bubble pairs were compared. 30 were identical. The other 3 are one bubble whose list input differs between the tabs (next paragraph). 0 pairs with the same input drew differently.
UTC       thread footer shows   true age   reply streaming
11:16:35  Last reply 5m ago     5m44s      yes
11:17:52  Last reply 6m ago     7m01s      yes   (minute tick)
11:18:48  Last reply 7m ago     7m57s      yes   (minute tick)
11:19:12  Last reply 8m ago     8m21s      no    (turn ended, all rows redraw)

The one difference in every comparison comes from the data, not from the rendering. In the live tab's store, the reply part above a steer is the client's settled copy of the streaming row. That copy has no ts and no meta.mid. So its footer shows no time and no Reply in thread until a reload brings in the server's row. I ran the same scenario against a build of 213339f671, this PR's base. It shows the same difference and also has 0 rendering differences, so the difference is older than this PR.

In one earlier run, the live copy was also 6 characters shorter than the server's row. That run's turn-end redraw of every row left it unchanged, so those characters were missing from the store, not just from the screen. This PR does not change the store.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (reviewed b23f312). The code is ready, but the green is stale. #20756 merged into main after this head's CI ran, and it edits four of this PR's files: ChatPane.tsx, ChatPaneTranscript.tsx, transcriptRenderers.tsx and crew-mode.md. In ChatPaneTranscript.tsx it adds the Resume props to the renderer memo, and this PR's row reuse depends on that memo's identity. GitHub reports a clean textual merge, but the combined tree has not run CI. Auto-merge is armed, so an approval now could land it untested. To clear: rebase onto current main and let CI and the AI lanes finish green on the new head. The re-review should then be quick.

Our r103 blockers are cleared on this head:

  • CI and GPT 6.1 are green.
  • crewmateTranscript now takes only a getter.
  • The Design and UX asks have concrete answers: a per-call-site table shows every ctx.messages reader treats a streaming row by role only, and a live crewmate-DM check confirms the footer, Steered chip and Last-reply age.

The design is sound. Rows get their previous objects back, and renderers move only with a transcript version that ignores nothing except a streaming row growing in place. The one public-contract narrowing for App Kit renderers is documented. All AI lanes pass, and no change request is open. I can't promise approval of the rebased head before seeing it. Optional: the live check found an older store gap, where the client's settled copy above a steer lacks ts/meta.mid and once was 6 characters short. That is worth its own issue, but it does not block this PR.

— crew-pr-reviewer (r104)

@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from b23f312 to da4b64b Compare October 15, 2026 19:17
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from da4b64b to a22dc5a Compare October 15, 2026 21:02
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
The crewmate DM, split panes and the app-SDK embed draw their
transcript through ChatMessageList's virtualized mount. Every
streaming flush minted a new object for every grouped row and a new
render function closed over the new message list, and every keystroke
in the composer re-rendered the mounted rows too. So each chunk of a
reply rendered every message on screen again: on a 10-second reply in a
crewmate DM that was about 3.4 s of React render time.

A settled row now gets its previous object back
(createDisplayItemReconciler, which ChatPage's createTurnGrouper now
calls too, so the substitution loop exists once) and is a memoized
ListRow. The row renderers read the message list through a view that
changes only with the transcript version, so their identity changes
only when something a row can read changes: the host's props, the
running flag, or the version, with every input checked by
exhaustive-deps. The version moves on every change to the message list
except a streaming row's text growing, which no other row reads; a row
re-minted as an equal copy does not move it either. ListRow subscribes
to language switches itself, and ThreadFooter redraws its "last reply"
age once a minute.

ChatPane hands the crewmate rows the unfiltered transcript as a getter
keyed on the same version, and the crewmateTranscript option now takes
only a getter, so the renderer set is no longer rebuilt per chunk. The
API reference states the one rule this asks of an app's renderer: read
a streaming neighbour by its role, not its text.

Fixes #20518
…ply streams

Main now hands the newest error row its Resume state (continuable,
interrupted, continuing, onContinue), and those values sit in the memo that
builds the pane's row set. Row reuse holds only while that set keeps its
identity, so add a case that runs the real Resume hook in a crewmate chat:
typing under an offered Resume, and streaming a resumed reply, must not
rebuild the row set or redraw a settled row. Making onContinue a fresh
function per render turns both cases red.

Also follow the tool pill's ok colour, now text-ok-text on main.
@chenmingwei23
chenmingwei23 force-pushed the fix/crewmate-chat-row-identity branch from a22dc5a to 85a1846 Compare October 15, 2026 22:08
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 15, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

HOLD (reviewed b23f312). The code is ready, but the green is stale.

Reply to r104.

Rebased. New head 85a1846eb1, base 10b7fa790f. The base includes #20756 (66cf575a11), #20930, and #19903 (d8fd52eced).

2a. Resume in the renderer memo. New ChatPane.crewmateResumeReuse.test.tsx mounts a crewmate ChatPane with CrewComposer and the real useChatPaneContinue; nothing in the Resume path is mocked. It counts how often createTranscriptRenderers builds a row set and which rows each set draws.

  • Case 1: a turn ends on a model error, Resume is offered on the error row, then the composer is typed into three times. No new row set; the settled reply and the error row are not redrawn.
  • Case 2: Resume is pressed (the error row redraws, its button disables), the slots frame reports the turn running (Resume leaves the row), then a reply streams over several chunks with a keystroke in between. No new row set; the settled reply and the error row are not redrawn.

The four Resume values are stable while a reply streams: onContinue is useCallback(..., [press]), press depends on slot, continuing, continuable and useMutation's mutate (TanStack Query 5.96.0, stable).

2b. Reverse mutation. Making onContinue a plain function (no useCallback) turns both cases red (expected 10 to be 7, expected 20 to be 13 on the row-set count). Reverted; the tree was clean afterwards.

2c. Resume itself. #20756's own specs pass on the merged tree: ChatPane.crewmateResume, useContinuePress, chatSlice.slotResume, ChatPane.featureRequestFallback, useChatPageTurnRecovery, transcriptRenderers, ChatPane.owners. Case 2 above also checks that pressing Resume and the next turn starting both redraw the error row.

2d. ctx.messages readers. git grep -n 'ctx\.messages' -- website/src ':!website/src/test' gives the same 16 sites as on b23f312afe. No new reader.

#19903 (handOff). Only website/src/app-sdk/ChatMessageList.tsx conflicted. Both sides are kept: renderMessage's context passes versioned.messages and handOff; its dependency list and renderItem's use versioned and add handOff; CollapsibleToolGroup still gets askAgent={handOff}. ChatEmbed still passes handOff={false}. handOff is a fixed host prop, so it does not change while a reply streams and does not rebuild rows. ChatPane.crewmateResumeReuse, ChatPane.crewmateRunReuse, ChatMessageList.rowIdentity and ChatMessageList.inPlaceRows pass, as do #19903's AppSdkMessageRenderersCov80, ChatEmbed.approvalRollback and CollapsibleToolGroupCov80, #19898's ChatEmbed.stop, useStopPress, ChatEmbed.attachments and ChatEmbed.composerStoreFree, and #19890's AppSdkMessageRenderersCov80 cases. #19898's change to ChatPane.tsx does not touch useChatPaneRenderers' inputs.

Locally on the merged tree: tsc -p tsconfig.app.json and eslint --max-warnings 0 on the changed files are clean; 232 related vitest files, 3,091 tests passed (1 expected fail).

On 85a1846eb1, CI and all 5 AI review lanes are green, and PR Readiness reported success at 22:54:28Z.

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 85a1846. The memo boundary is sound: every input a reused row can read either sits in the renderers' deps (running, host props) or moves the transcript version, and the one exception the version skips — a streaming row's text growing — is read by role only in every built-in rule I traced: the reply footer loop (messageRenderers.tsx:537-545, isHiddenInvisibleAssistantRow/isSystemNoticeRow both return false for streaming), answeredAfter, turnHadPolicyBlock, sessionStartFailureStreak, contextOverflowIsNewest, and crewmateRunPosition (isCrewmateSpeech is true for any streaming row). The streaming row itself still redraws because the reconcile hands it a new item.

Verified locally: the 8 touched/related suites pass (81 tests) plus the two groupDisplayItems suites (39). Mutations, each run alone and restored: versioner never moving (5 named reds), treating every changed row as unchanged (2), dropping useLanguageGeneration in ListRow (1), dropping the ThreadFooter tick (1), disabling the reconciler (2).

Non-blocking: the documented contract for app renderers (read a streaming neighbour by role, not text) is now load-bearing for third-party renderers; nothing enforces it, so a renderer that breaks it would show a stale row rather than fail. Fine as documented.

@chenmingwei23
chenmingwei23 merged commit 93617e9 into main Oct 15, 2026
105 of 113 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/crewmate-chat-row-identity branch October 15, 2026 23:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 15, 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.

perf(members): crewmate chat lags on the Crewmates page when the Dashboard tab shows a large workstream tree

3 participants