Skip to content

Stop the 700ms stream tick from re-rendering all three main panes (#91) - #120

Merged
currentbits merged 1 commit into
mainfrom
coder/700ms-streaming-tick-re-renders-all-thre-f41da5
Aug 16, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/700ms-streaming-tick-re-renders-all-thre-f41da5

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #91.

The problem

A run pushes thread:updated every 700ms (tickMs, electron/main.js:284). The renderer's handler mapped a fresh threads array on every push and replaced the open detail, so App re-rendered Sidebar + ThreadView + AgentsPanel — ~7,400 lines of components, on top of auto-animate in the sidebar — on every tick of every streaming thread. Fine with one thread; with five concurrent streams it is a constant render storm. Only Markdown and MessageBlock were memoized.

What changed

Split what each subscriber of that one push actually consumes:

  • patchThreadList (src/threadPatch.ts) replaces the pushed row but keeps the array and row identity when the summary did not move. A tick that only grew the transcript — tool still running, waiting on a permission prompt — now never touches the list, so it costs nothing above the wire.
  • mergeThreadPatch keeps the previous thread / usage objects when they are structurally equal, so a rebuilt-but-identical object no longer invalidates the panes (or effects keyed on them).
  • Sidebar, ThreadView and AgentsPanel are memo'd, and App now holds every handler stable — that is the half without which the memo does nothing.
  • Narrowed the two panes' list dependency. ThreadView takes the resolved handoffSource (its only use of the list was one find) and AgentsPanel takes a rosterKey string (which it was already deriving internally). The array's identity churns by design; either pane holding it would defeat its own memo.

Comparison is JSON.stringify: the payloads are small and already JSON-shaped across the IPC boundary, and a false "changed" only costs a render — it can never show a stale view.

Net effect: a quiet background stream re-renders nothing, an appending one re-renders the sidebar only, and the open thread re-renders ThreadView only.

Note

onCancelQueued stays wrapped rather than passed through. It is bound straight to a button's onClick, so cancelQueued's optional threadId would swallow the DOM event and cancel nothing — the existing suite caught this.

Checks

  • npm run typecheck — clean

  • npm run build — clean

  • npm run test:renderer — 700/700 pass

  • New unit coverage in test/threadPatch.test.ts for both identity guarantees; test/teamView.test.tsx updated for the rosterKey prop.

  • PR created by the Claude Code agent

A run pushes thread:updated every 700ms. The handler mapped a fresh
threads array per push and replaced the open detail, so App re-rendered
Sidebar + ThreadView + AgentsPanel — ~7,400 lines of components, plus
auto-animate in the sidebar — on every tick of every streaming thread.

Split what each subscriber actually consumes:

- patchThreadList keeps the array AND row identity when the pushed
  summary did not move, so a tick that only grew the transcript never
  touches the list.
- mergeThreadPatch keeps the previous thread/usage objects when they are
  structurally equal, so a rebuilt-but-identical object does not
  invalidate the panes or effects keyed on them.
- Sidebar, ThreadView and AgentsPanel are memo'd, and App now holds every
  handler stable for that to bite. ThreadView takes the resolved
  handoffSource and AgentsPanel a rosterKey instead of the whole list,
  whose identity churns by design.

cancelQueued stays wrapped: it is bound straight to a button's onClick
and its optional threadId would swallow the DOM event.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 9013f62 into main Aug 16, 2026
1 check failed
@currentbits
currentbits deleted the coder/700ms-streaming-tick-re-renders-all-thre-f41da5 branch October 3, 2026 16:07
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.

700ms streaming tick re-renders all three main panes

1 participant