fix(agent-status): suppress duplicate child-only row mutation

This commit is contained in:
Merge Sim
2026-09-11 00:36:00 -07:00
parent a3337003c2
commit 752e65eb59
2 changed files with 10 additions and 1 deletions
@@ -87,8 +87,8 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
event.payload.agentType === 'claude'
) {
// Why: OSC has no child identity or lead boundary, so it cannot replace a persisted child-only proof before the lifecycle hook arrives.
this.commitStatusRowMutation(mutationBefore, previous)
if (mutationBefore !== undefined) {
this.commitStatusRowMutation(mutationBefore, previous)
this.emitEnrichedStatus(previous)
}
return
@@ -200,7 +200,9 @@ describe('the terminal handle a status row is stamped with', () => {
it('publishes only the remint observation for a Claude child-only row', () => {
const server = new AgentHookServer()
const enriched = vi.fn()
const mutations = vi.fn()
server.subscribeEnrichedStatus(enriched)
server.subscribeStatusRowMutations(mutations)
const payload = { state: 'working' as const, prompt: 'ship it', agentType: 'claude' as const }
ingest(server, { payload })
const row = server._getStateForTests().lastStatusByPaneKey.get(PANE_KEY) as
@@ -211,12 +213,19 @@ describe('the terminal handle a status row is stamped with', () => {
}
row.claudeLeadBoundaryChildOnly = true
enriched.mockClear()
mutations.mockClear()
ingest(server, { payload })
expect(enriched).not.toHaveBeenCalled()
expect(mutations).not.toHaveBeenCalled()
ingest(server, { paneKey: NEW_PANE_KEY, tabId: 'tab-reminted', payload })
expect(enriched).toHaveBeenCalledOnce()
expect(mutations).toHaveBeenCalledOnce()
expect(mutations).toHaveBeenCalledWith({
before: { paneKey: PANE_KEY, worktreeId: 'worktree', terminalHandle: HANDLE },
after: { paneKey: NEW_PANE_KEY, worktreeId: 'worktree', terminalHandle: HANDLE }
})
expect(enriched).toHaveBeenCalledWith(
expect.objectContaining({ paneKey: NEW_PANE_KEY, terminalHandle: HANDLE })
)