fix(protocol,client): resolve subagent type mismatches breaking CI#312
Conversation
StreamingBlock.subagent was typed as StreamingSubagentState only, but the SUBAGENT_END reducer replaces it with a FinishedSubagentState (subagent finishes while parent message is still streaming). Also, finishCurrent() copied the streaming subagent without conversion, and SubagentCard imported types not exported from @mitzo/protocol. - Widen StreamingBlock.subagent to accept both streaming and finished - Export FinishedSubagentState, StreamingSubagentState, SubagentState, SubagentUsage from @mitzo/protocol - Add finishSubagent() helper that handles both states (Map→array for streaming, passthrough for already-finished) - Cast to StreamingSubagentState in streaming reducer cases where the subagent is known to still be running Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Centaur ReviewFound 3 issue(s) (2 warning).
|
Address Centaur review findings on PR #312: - Replace 5 `as StreamingSubagentState` casts with `'blockOrder' in` narrowing guards that safely bail if the subagent is already finished - Fix test type errors: cast to StreamingSubagentState/FinishedSubagentState in assertions so tests pass tsc --noEmit (not just esbuild) - Add two tests for finishSubagent: passthrough path (already-finished) and Map→array conversion path (still-streaming at MESSAGE_END) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Centaur ReviewFound 5 issue(s) (2 warning).
|
…loop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address Centaur review round 2: - Extract getStreamingSubagent() helper to DRY the 5 repeated 'blockOrder' in narrowing guards into a single function - Replace non-null assertions (!) with .filter(Boolean) in both finishSubagent and SUBAGENT_END — handles stale blockOrder entries - Add test: stale blockId in blockOrder is safely skipped - Add test: streaming events after SUBAGENT_END are silently dropped - Update existing finishCurrent test to verify Map→array conversion Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
maincaused by subagent type mismatches inpackages/clientandfrontendStreamingBlock.subagentwas typed asStreamingSubagentStateonly, but theSUBAGENT_ENDreducer replaces it withFinishedSubagentState(subagent finishes while parent message is still streaming)finishCurrent()copiedb.subagentwithout converting from streaming to finished formSubagentCard.tsximportedFinishedSubagentState/StreamingSubagentStatewhich weren't exported from@mitzo/protocolChanges
packages/protocol/src/types.ts: WidenStreamingBlock.subagenttoStreamingSubagentState | FinishedSubagentStatepackages/protocol/src/index.ts: ExportStreamingSubagentState,FinishedSubagentState,SubagentState,SubagentUsagepackages/client/src/slices/messages.ts: AddfinishSubagent()helper (handles both Map→array conversion and finished passthrough), cast toStreamingSubagentStatein streaming reducer casesTest plan
packages/client/__tests__/messages-slice.test.ts— 64 tests passpackages/harness/__tests__/connection-registry.test.ts— 37 tests passnpx tsc -bin frontend — cleannpm run build— full Vite build succeeds🤖 Generated with Claude Code