fix(chat): preserve assistant order after batched steers - #230
Conversation
morgmart
left a comment
There was a problem hiding this comment.
🤖 Automated code review
APPROVE. Fresh static review of the exact three-dot comparison 0821223...5be8572 found no publishable findings. The continuation now derives its insertion point from the contiguous batch of delivered steer messages while stopping before an undelivered steer, preserving canonical transcript order and the queue/steering laws. The added store and ACP regression tests are discriminating and cover both the repaired multiple-delivered-steer case and the adjacent undelivered-steer boundary. Final self-check covered every changed user flow, accessibility, i18n/localization, navigation and consent guards, async/error/never-completes/lifecycle/race behavior, test honesty, project laws/design-system rules, duplicate overlap, and blocking-evidence/user-effect requirements; this state-only change introduces no new UI, copy, navigation, consent, or accessibility surface. Supplied GitHub evidence was inspected: all listed check runs for the exact head SHA completed successfully, while the legacy combined commit status is pending with no statuses; required checks still govern merge readiness. No local code, tests, builds, package managers, binaries, hooks, or project scripts were run.
Deterministic publication result: 0 blocking and 0 non-blocking finding(s) publishable; 0 duplicate(s) suppressed.
Pending checks: 1 check(s) are not complete.
This approval reflects the completed code review only; merge readiness remains governed by the repository's required checks.
Summary
Fixes a chat transcript ordering bug for live steering. When a prior assistant response is completing and multiple user steers are delivered before the next assistant response starts, Berd now anchors the continuation after the contiguous delivered steer batch instead of after only the first delivered steer. Undelivered queued steers still stay ahead of their own later continuation.
Related issue
none found
Testing
pnpm vitest run src/features/chat/stores/__tests__/chatStore.test.ts src/features/chat/acp/__tests__/acpNotificationHandler.test.tsjust checkReviewer-reproducible examples
Red/green regression proof:
Apply only the regression test to
origin/main, then run the focused case:pnpm vitest run src/features/chat/acp/__tests__/acpNotificationHandler.test.ts \ -t 'keeps assistant responses in canonical order when multiple steers arrive before the next response'Before this fix, the focused case fails because the continuation assistant is inserted between the two delivered steers:
On this PR, the same focused case passes. The seeded live transcript shape matches session
20260826_2:completionStatus: "inProgress"The resulting transcript order remains:
The store test
does not cross a steering message that has not been deliveredcovers the adjacent preserved behavior: if a later local steer is stilldelivery: "steering", the continuation for the delivered steer is inserted before that undelivered steer.