Repository navigation
perf(web): reconcile the reconnect sub-agent replay into held cards - #23797
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the end-of-replay marker is the right shape for reconciling held cards, and every reader of the changed reconnect sequence is listed. Notes
[DESIGN-REVIEWED] 8809c2a Description read[DESCRIPTION-READ] 7703fee0bf1cd34f709b37f972b8ee374dd9e461b5ceafe55fe83269aaa8ec1b 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 |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The PR adds or changes no control, string or component. It is reducer and wire work that keeps the sub-agent cards and their tool-call timelines in place across a reconnect, so they no longer drop and rebuild. [UX-REVIEWED] 8809c2a Description read[DESCRIPTION-READ] eb61246c995d7e6cfd007fd07b61683831e118cdc10fd3e4b26652a83899ebb1 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findings (all downgraded on adjudication)Reviewed Opus 5.5 adjudication downgraded every blocking finding. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents. Review detailsBLOCKING -- website/src/store/chat/subagents.ts:164 -- Tool-count ordering loses replay output and misorders permission calls
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — LOW. The failure needs a backpressured replay in which a live |
|
issue: GPT 6.1 F1 (a retained card keeps a stale
|
9202ad7 to
051b9ac
Compare
|
issue (blocking): fixed in 051b9ac. A retained card no longer keeps a stale
|
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item traces to the measured re-render and lost-timeline defect. The marker is new: grep finds no existing end-of-replay signal in Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: keep sub-agent cards and their tool-call timelines steady across a dashboard reconnect instead of rebuilding them. This is a FIX (filed as perf).
[FIRST-PRINCIPLES-REVIEWED] 8809c2a Description read[DESCRIPTION-READ] 29cfde46b98e16c844ec492df08e482461436682048920a8b93b9568724c8513 That sha256 names the PR description this verdict read. Recompute it with |
|
note: the red
|
051b9ac to
0341722
Compare
0341722 to
b57e75b
Compare
6041864 to
07ff964
Compare
|
note: rebased on main (07ff964), no behaviour change. Main now includes #24774, which drops the strict xfail on |
iamwhatever
left a comment
There was a problem hiding this comment.
Request changes at 07ff964.
The approach looks sound. The server side moves the replay send helpers unchanged into ws_subagent_send.py (every line removed from ws.py appears there, so the owner and scope gates are untouched). The only new server behaviour is an empty subagent_replay_done frame sent to dashboard sockets only. The reducers reconcile into held cards and drop the unconfirmed ones at the marker. Checks and all AI lanes are green, and the earlier blocking GPT items are fixed.
Two deferred items need a linked issue before approval:
- Your reply in the GPT disposition says the complete fix for the repeated-row case is to send
tool_call_idinbuild_subagent_snapshot, and calls it "already a listed follow-up". I could not find an issue for it. Please open one and link it in the description. - The Design note says cards that only the durable CREW LOG fold knows are still dropped and rebuilt on every reconnect, and asks for that to be stated in the goal or moved after the fold in a follow-up. Please either narrow the goal line or open an issue and link it.
— crew-pr-reviewer (r129)
|
@iamwhatever thanks for the review at 07ff964. Both deferred items are now answered in the description, with no code change, so the head stays 07ff964. todo (non-blocking): It describes the case (an approval raises note (non-blocking): the Goal line is narrowed to the cards the in-memory replay names. It now says a card that only the CREW LOG fold knows is still dropped at |
|
span=587d8ec018d3
|
|
span=36ae5a580e24
|
|
span=36ae5a580e24
|
|
span=36ae5a580e24
resolution: removed -- withReplayedTool is a second writer of the recordToolCall rule that this PR added; the replay now runs recordToolCall on a copied timeline |
|
span=36ae5a580e24
|
Every (re)connect dropped every sub-agent card that was not a pending approval, then rebuilt each from the replay, so every card and whole-map reader re-rendered and a running card lost its tool-call timeline. clearSubagentsForSnapshot now marks those cards unconfirmed; replayed snapshot and done items reconcile into them, keeping the card object when nothing changed. The gateway sends the dashboard subagent_replay_done after the last replay frame, and the client drops the cards the replay did not name.
|
span=36ae5a580e24
resolution: narrowed -- a stale snapshot now writes identity and start time only, replacing the whole-object early return |
iamwhatever
left a comment
There was a problem hiding this comment.
Approve at 8809c2a.
The server change is small and safe. The replay helpers move verbatim into ws_subagent_send.py: every line removed from ws.py, including the owner filter and the _ws_client_allowed scope gate, is present there unchanged, and ws.py re-exports the names. The new subagent_replay_done frame is empty and dashboard-only, and last_tool_call_id goes through the same redaction as last_tool. On the client, subagentReplayDone drops only cards the replay did not name and keeps pending approvals. A lower-count snapshot fills identity only.
Both items from our r129 review are settled: tool_call_id is now sent and reconciled by id in this PR (closing Pearcekieser#58), and the Goal line now states that cards only the CREW LOG fold knows are still rebuilt. Every check on this head is green.
AI findings judged non-blocking:
- GPT 6.1 F1 (downgraded): a stale snapshot in a backpressured replay can keep older streaming text or append an older call row. This is display-only and transient, and nothing is persisted (subagents.ts#L163).
- Design: cleanup depends on the marker arriving. The served bundle always meets a gateway that sends it, and a lost marker only keeps stale cards until the next reconnect.
- First Principles: the module move is no longer forced by the line cap. It is a verbatim move with no behaviour change.
— crew-pr-reviewer (r136)
Problem / Motivation
Goal: A reconnect whose in-memory replay names the same sub-agents re-renders none of those cards, and a running card keeps its tool-call timeline across the reconnect. A card that only the durable CREW LOG fold knows (a finished run from before a gateway restart) is still dropped at the
subagent_replay_donemarker and rebuilt when the fold'ssubagent_doneframe arrives; moving the marker after the fold is out of scope here.On every connect and reconnect the client dispatched
clearSubagentsForSnapshotand sentsubscribe_subagents. The clear replacedstate.chat.subagents, everyslotActivity[*].subagentsand both queued maps with fresh objects holding only pending approvals, even when they were already empty. The gateway's replay then rebuilt every card from scratch. In a vitest harness on origin/main, replaying 3 unchanged running cards kept 0 of 3 card objects and none of the maps, and a running card restarted its tool-call timeline from the one tool the replay carries (the reducer's own comment says so).Why it matters
Every sub-agent card and every selector over the whole maps (sidebar counts, rail activity, the progress bar, the side panel) re-renders once per reconnect, and the user loses the list of tool calls a running agent had made. Reconnects are rare on a desktop and more frequent on phones, laptops waking from sleep and tunnelled connections.
Not a goal
subagent_doneframe arrives.subagent_snapshot_batch.What changed (motivation → approach → change)
Reconciling into existing cards needs the client to know when the replay is over, so it can still drop the cards the replay did not name. Below the batch threshold the replay is a run of ordinary frames with no end, so the gateway now marks it.
src/kiro_crew/dashboard/ws.py: right after_send_subagent_replaysends the in-memory replay, thesubscribe_subagentshandler sendssubagent_replay_done {}to a dashboard socket. The durable fold runs later on the socket'sSubagentReplayQueue, so its frames come after the marker and add their own cards. An app socket never gets the marker, since nows_event_scopetable names it.src/kiro_crew/dashboard/ws_subagent_send.py(new): the reconnect replay's send path in one module.SUBAGENT_REPLAY_BATCH_THRESHOLD,_subagent_replay_has_ownerand_send_subagent_replaymove here unchanged, beside the newsend_subagent_replay_done, andws.pyre-exports all four. The move was made whenws.pysat over the 2,000-line cap; main has since moved the side-chat frames out too, andws.pyends at 1,778 lines.src/kiro_crew/subagent_parts/run_record.py,subagent_manager/run_turn.py,dashboard/ws.py: a run recordslast_tool_call_idbesidelast_toolon its permission-request and tool-call paths, andbuild_subagent_snapshotsends it. The replay runsrecordToolCall, the rule live frames already use, on a copy of the held timeline, so it matches the newest row by that id when both carry one. An approval that movestool_countwith no frame adds no row, while a same-title call with a new id still does. Without an id (an older gateway, or a card rehydrated fromstate.json, which does not store it) the title-or-count rule applies.website/src/store/chat/subagents.ts:clearSubagentsForSnapshotno longer removes cards. It records every non-pending card id insubagentReplayUnconfirmedand clearsretryingon each, since the replay carries no retry state and a recovery the old socket missed would otherwise leave the card saying it retries, and empties the queued maps only when they hold something.sseSubagentSnapshotandsseSubagentDoneconfirm the id they name. The newsubagentReplayDonereducer drops the cards still unconfirmed and clears the record; with no replay in progress it does nothing.sseSubagentSnapshotbuilds the card as before but keeps the held object when the two are equal (undefined fields ignored), and keeps a repeated stall's receipt time.tool_countis lower than the card's was collected before a live tool frame the card already applied. The invariant: tool and progress fields only move forward, and identity always fills. Such a snapshot writes only the task, agent, label, model, child session, batch id and start time, which a card created by a live frame lacks, and never the timeline, current tool, count, streaming text or stall state.sseSubagentDonewritesretryinganderroronly when they move, and its new-card branch spellsretrying: false, so replaying a finished card changes nothing.website/src/hooks/useWebSocket.tsroutessubagent_replay_doneto the new reducer. Comments and the spec line indocs/system-specs/modules/subagent.mddescribe the new order.Backwards compatibility
Compatible: an older client ignores the unknown
subagent_replay_doneframe, and the bundle a gateway serves always handles it. Apps receive nothing new.Reader: website/src/hooks/websocket/reconnectCatchUp.ts:runReconnectCatchUp -- chat -- still dispatches
clearSubagentsForSnapshotbeforesubscribe_subagents; cards now stay until the markerReader: website/src/hooks/websocket/reconnectCatchUp.ts:runFirstConnect -- chat -- same sequence on the first connect
Reader: website/src/hooks/websocket/connection.ts:subscribeSubagents -- chat -- a subscribe with no clear before it gets a marker with no replay in progress, which changes nothing
Reader: test/integration/test_subagent_panel_restart_hydration.py:_subscribe_subagents_until -- subagent -- still reads until the beacon run, and now also requires the marker
Tests
website/src/test/SubagentReplayReconcile.reducers.test.ts(new, 20 cases). A snapshot at a lower count than a newer live frame keeps the live call as the newest row, and fills the task, agent and real start time of a card the live frame created; a current snapshot whose call id also sits earlier in the timeline is still applied. A replay whoselast_tool_call_idmatches the newest row adds no row after an approval-only count bump and keeps the array identity; a same-title replay with a new id appends one row. With the id rule disabled the first of those fails.test/test_subagent_snapshot_idle_secs.pypinslast_tool_call_idon the snapshot frame. An identical replay keeps every map, every card and both queued maps. A running card keeps its tool-call timeline and stays on screen while the replay is in flight. A changed replay item replaces its card. The marker drops unnamed cards in every slot and keeps pending approvals. A marker outside a replay changes nothing. Queued counts still reset. A repeated stall keeps its card. A retained card'sretryingflag is cleared when the replay starts, and a retry frame on the new connection sets it again.website/src/test/useWebSocketReconnect.test.tsandwebsite/src/test/SubagentMissedSpawn.reducers.test.tsx: the cases that expected the connect itself to drop cards now sendsubagent_replay_donefirst.website/src/store/chatSlice.publicSurface.test.tspins the new action and state field.test/integration/test_subagent_panel_restart_hydration.py: both restart-replay tests still read until the beacon run, which now arrives from the replay queue after the marker, and also assert the socket receivedsubagent_replay_done. With the marker send mutated, both fail; with it, both pass (KIROCREW_INTEGRATION=1).--sequence.shuffle. Allsrc/test/useWebSocket*,src/test/UseWebSocketCoverage*,src/hooks/websocket,src/store,src/test/Subagent*andsrc/test/chatSlice*vitest files pass (203 tests in the six changed and reconnect files after the rebase on main).test_ws_event_scoping_live.py,test_ws_event_scoping_audit.pyandtest_subagent_panel_durable_replay.pypass.tsc -p tsconfig.app.json, eslint and flake8 on the changed files are clean.Manual verification
N/A -- unit coverage sufficient: the reducer tests pin card and map identity for each replay shape, and the integration test drives the real handler.
Screenshots / video
Why no screenshot: an unchanged reconnect now renders the same cards with the same content; the visible difference is that a running card's tool-call list survives, which the reducer test pins.
Related Issues
Fixes #23796
Also fixes Pearcekieser#58 (send
tool_call_idinbuild_subagent_snapshot), which the Opus and GPT lanes both raised on the replayed tool row.Pattern harvest
Rule candidate: review-prompt
Pattern: a reconnect that clears client state before an authoritative replay instead of reconciling the replay into it, so every reader of that state re-renders even when nothing changed.
Checklist