Add real stream regression tests

This commit is contained in:
Mohamed Boudra
2025-11-15 15:06:43 +01:00
parent 320328b0ca
commit a57315d78d
3 changed files with 281 additions and 261 deletions
+3
View File
@@ -40,6 +40,9 @@
- [x] Duplicate key warnings still appear when opening the agent stream—identify which stream items (thoughts, assistant chunks, tool calls, etc.) are emitting conflicting keys and fix the keying strategy so React no longer logs warnings.
- Hardened the assistant/thought timeline id generator so it now checks for existing ids before committing a suffix, ensuring new entries stay unique even if the stream shrinks, and added regression coverage in `test-idempotent-stream.ts` to prove assistant and reasoning ids remain unique after list pruning. Verified via `npx tsx test-idempotent-stream.ts`; note Test 1 still intentionally highlights state differences as before.
- The warning points at the permission request cards rendered in the stream header; they’re reusing the same key so start the investigation there.
- [x] Follow-up on the so-called "tests": `test-idempotent-stream.ts` only logs PASS/FAIL (never throws), isn’t hooked to any npm script/CI target, and the Claude fixture doesn’t resemble real `tool_result` blocks. Convert these demos into assertions that fail the process, wire them into an npm script/CI check, and update the Claude fixtures to mirror actual SDK payloads so the regression reproduces before anyone claims it’s fixed again.
- Swapped the bespoke logger for `node:test` + `assert` so failures now exit non-zero, refreshed every helper to cover actual Claude `mcp_tool_use/result` payloads, and wired the suite into `npm test` via a new `test:stream` script. Ran `npm run test:stream` to prove the harness passes end-to-end.
- [ ] Hydrated sessions are still dropping user messages even though this has allegedly been “fixed” multiple times. Capture the regression in an automated test (hydration snapshot + real-time replay), ensure user messages survive rehydration for both Codex and Claude, and do not check the box until the test fails on current main and passes after the fix.
- [x] Permission request cards rendered in the stream header emit duplicate key warnings because consecutive requests share the same `request.id`; derive a composite key so they stay unique per agent even when IDs collide or are missing.
- Switched the header map to key permission cards by `${agentId}:${request.id}` with a title/name/index fallback so React no longer sees duplicate keys even if providers reuse an id or omit it altogether. Ran `npm run typecheck --workspace=@voice-dev/app`.