Repository navigation
perf(engine): cut live-stream burst volume — opt-in sync copies, patches on demand, throttled shell output #1778
Description
Important
Problem — Live activity produces multi-MB frames on one ordered stream. Per-turn summary events carry full patch text for every changed file (up to 12.3 MB on the Studio; 1,111 such events over 100 KB). Every stored event is emitted twice, once plain and once as a sync copy the app discards. A running shell tool republishes its last 30 KB of output on every chunk, with no throttle. Everything behind a burst waits, and every relay and the webview pay to parse it.
Approach — Send sync copies only to subscribers that ask for them (the workspace control plane does). Strip patch bodies from summary diffs on the wire while keeping file, status, and counts; the surfaces that render patch bodies fetch them on demand. Throttle shell output updates to at most about five per second, with a trailing flush and a guaranteed final update on completion.
Scope — in: sync-copy opt-in; the wire projection of summary diffs; on-demand patch fetch for the rendering surfaces; the shell output throttle. out: the stored event log and its size; other tools' metadata.
Assumptions — The per-turn diff accordion is the live consumer of summary patch bodies, and the other surfaces need only file and counts — to be confirmed in this slice before stripping.
Acceptance Criteria
- The global stream omits sync copies unless the subscriber requests them; the workspace control-plane subscription requests them and still replays correctly.
- Summary diffs in live events carry file, status, additions, and deletions but no patch bodies; the stored record is unchanged.
- Expanding a file in the per-turn diff view fetches and renders its patch; diff counts and file lists render as before without any fetch.
- A shell command printing continuously produces at most about five output updates per second on the stream, and its final output is always delivered on completion.
- A fixture turn (multi-file edit plus a chatty shell command) keeps its largest live frame under 256 KB, and the slice reports total stream bytes before and after.
Testing Decisions
- Extend the engine server suite (opt-in filter, wire projection), the shell tool tests (throttle and final flush), and the session-ui tests for the per-turn diff view (on-demand fetch).
Key Decisions
- Sync copies are opt-in per subscription, off by default.
- The projection is wire-only; storage is untouched.
- Throttle: the first update goes out immediately, then at most one per 200 ms with a trailing flush.
Constraints & Invariants
- Sync copies keep their source event's id, so filtering them leaves no sequence holes.
- Nothing about what is persisted changes.
Prior Art
- The event-v2 bridge's twin emission; the control-plane workspace's replay of sync events; the session summary diff shape; the shell tool's output preview; the per-turn diff accordion and the diff-change bars.
Source
- Part of Fleet event stream is lossy by construction — remote sessions lag and desync during live activity #1770 · Blocked by feat(engine): sequenced, replayable global event stream (epoch:seq ids, replay buffer, reset) #1776 (shares the global stream handler).
Activity
feat(engine): sync copies are opt-in per global-stream subscription; …
feat(engine): summary diffs carry no patch bodies on the wire; the pe…
jeonghun-jj-lee commentedon Oct 12, 2026
Merged into the #1770 integration branch as 8291932 (PR #1781 — HITL review there). Fixture turn: 38.44 MiB -> 6.06 MiB on the wire (-84.2%), largest frame 2688.7 KiB -> 110.9 KiB, sync copies 481 -> 0, shell updates 300 -> 16. Director gates: drift PASS 937, materialize 937 hashes, engine + overlay typecheck clean, extension suite green; app + session-ui full sweeps have the identical failure set to the integration tip (0 new, 24 pre-existing; CI does not run them). One rare failure (1/60) traced to the upstream shared test harness colliding with leaked test servers — pre-existing on main, tracked in #1782.
feat(engine): throttle shell output updates to <= 1 per 200 ms with a…
test(engine): fixture-turn byte report — largest live frame under 256…
style(engine): prettier-format the #1778 tests (#1778)
Merge #1778: engine burst-volume cuts — opt-in sync copies, patches o…