Skip to content

Stream thread tails over IPC instead of the full transcript, and memoize message rows - #51

Merged
currentbits merged 2 commits into
mainfrom
coder/ipc-full-transcript-pushed-on-every-chun-617bbd
Aug 15, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/ipc-full-transcript-pushed-on-every-chun-617bbd

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #28.

Why

pushDetail (electron/runner.js) sent the result of getThreadDetail — the entire messages + workLog arrays — on every stream event. The largest thread's message array is ~4 MB, structured-cloned per chunk. On the renderer side nothing was memoized, so each push re-ran react-markdown + remark-gfm over every message in the thread and rebuilt the whole timeline.

What changed

Backend — send only what changed. pushDetail diffs the messages/work-log arrays against the last push by element identity (the store patches items immutably, so an unchanged item keeps its reference) and sends the tail plus its start index. Payload keeps the ThreadDetail shape with messagesFrom / workLogFrom added, so the channel name, preload allowlist, web bridge and the devCoder mock needed no changes — a full push is simply index 0.

Renderer — merge the tail. src/threadPatch.ts rebuilds prefix + tail; because the tail replaces everything from its index onward, a shrinking transcript (checkpoint restore, compaction) merges correctly too. useCoder merges into the open detail and refetches the full transcript when it cannot merge:

  • the tail starts past what we hold, or
  • the new per-thread seq skips a number — a web client that reconnects mid-run would otherwise keep a stale message in the middle (e.g. a tool card stuck on "running") forever.

Renderer — stop re-parsing everything. Markdown and the timeline's message row are memo'd; the row's meta object prop was flattened to scalars so the default shallow compare actually hits. A push now re-parses only the message that changed.

Verification

  • electron/test/*: 682 pass / 11 fail — the same 11 (orch-server, stopAll, worktree-create) fail on unmodified main.

  • renderer test/*: 727 pass / 0 fail. tsc --noEmit clean.

  • New: runner.test.js asserts the tails fold back to the exact store transcript and that later pushes never re-send the full array; test/threadPatchWiring.test.tsx drives the real App through a tail merge, a seq gap and a hole. All three fail if the merge is reverted to setDetail(next).

  • Two existing tests read push.payload.workLog as a complete log; they now fold the pushes / read the store.

  • PR created by the Claude Code agent

pushDetail cloned the whole transcript on every stream event (~4 MB on the
largest thread). It now diffs against the last push by element identity and
sends only what changed, with a per-thread seq so a renderer that missed a
push (web reconnect) refetches instead of merging onto a stale prefix.

Renderer: Markdown and the message row are memo'd, so a push only re-parses
the message that actually changed instead of every message in the thread.

Fixes #28

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.

stopAll marks every active run idle with an interruption event, then called
store.save() — which only arms a 250 ms unref'd timer since the store write
debounce landed. On quit that write can be lost (a SIGTERM never runs the
exit hook that flushes it), so the next launch sees status "working" and
recoverInterruptedRuns re-stamps the run as a generic failure.

saveNow() puts the bytes on disk before the process goes away. This is the
one test failing in CI on this branch and on main.

Co-Authored-By: Claude Opus 5 <[email protected]>
@currentbits
currentbits merged commit 5616819 into main Aug 15, 2026
1 check passed
@currentbits
currentbits deleted the coder/ipc-full-transcript-pushed-on-every-chun-617bbd 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.

IPC: full transcript pushed on every chunk; Markdown re-parses every message

1 participant