What problem are you trying to solve?
MessageStore has only 1 direct unit test (for upsertToolCall). The streaming message lifecycle — appendStreamDelta, finalizeStream, promoteActiveTurn — has no isolated tests. These functions are covered indirectly through session-sync.test.ts integration tests, but edge cases in the streaming lifecycle deserve dedicated coverage.
Where
- Source:
packages/core/src/stores/message-store.ts
- Existing test:
packages/desktop/test/message-store.test.ts (1 test case)
What needs to be done
- Open
packages/desktop/test/message-store.test.ts
- Add test cases for:
appendStreamDelta: appending text to an active turn, creating a new active turn if none exists, handling empty deltas
finalizeStream: finalizing an active turn marks it as complete, calling finalize with no active turn is a no-op
promoteActiveTurn: promoting moves the turn into the message array with correct metadata, promoting when no active turn exists is safe
upsertToolCall fallback chain: test all 3 branches — active turn exists, fallback to last assistant message, fallback to creating a new active turn
- Run
pnpm check to verify
Why does this matter?
Message streaming is the core user-facing data flow. The appendStreamDelta → finalizeStream → promoteActiveTurn lifecycle is subtle and has caused production regressions before (message duplication). Dedicated tests prevent re-introducing these bugs.
Primary area
Task execution
What problem are you trying to solve?
MessageStorehas only 1 direct unit test (forupsertToolCall). The streaming message lifecycle —appendStreamDelta,finalizeStream,promoteActiveTurn— has no isolated tests. These functions are covered indirectly throughsession-sync.test.tsintegration tests, but edge cases in the streaming lifecycle deserve dedicated coverage.Where
packages/core/src/stores/message-store.tspackages/desktop/test/message-store.test.ts(1 test case)What needs to be done
packages/desktop/test/message-store.test.tsappendStreamDelta: appending text to an active turn, creating a new active turn if none exists, handling empty deltasfinalizeStream: finalizing an active turn marks it as complete, calling finalize with no active turn is a no-oppromoteActiveTurn: promoting moves the turn into the message array with correct metadata, promoting when no active turn exists is safeupsertToolCallfallback chain: test all 3 branches — active turn exists, fallback to last assistant message, fallback to creating a new active turnpnpm checkto verifyWhy does this matter?
Message streaming is the core user-facing data flow. The
appendStreamDelta → finalizeStream → promoteActiveTurnlifecycle is subtle and has caused production regressions before (message duplication). Dedicated tests prevent re-introducing these bugs.Primary area
Task execution