Skip to content

fix(chat): preserve assistant order after batched steers - #230

Merged
johnmatthewtennant merged 2 commits into
mainfrom
fix-steered-message-order
Aug 26, 2026
Merged

fix(chat): preserve assistant order after batched steers#230
johnmatthewtennant merged 2 commits into
mainfrom
fix-steered-message-order

Conversation

@johnmatthewtennant

@johnmatthewtennant johnmatthewtennant commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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.ts
  • just check

Reviewer-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:

 assistant-before-steers
 steer-1
-steer-2
-assistant continuation
+assistant continuation
+steer-2

On this PR, the same focused case passes. The seeded live transcript shape matches session 20260826_2:

  1. assistant response with completionStatus: "inProgress"
  2. two delivered steer user messages with the same timestamp
  3. next assistant chunk begins after the first steer boundary is processed

The resulting transcript order remains:

assistant-before-steers
steer-1
steer-2
assistant continuation

The store test does not cross a steering message that has not been delivered covers the adjacent preserved behavior: if a later local steer is still delivery: "steering", the continuation for the delivered steer is inserted before that undelivered steer.

@johnmatthewtennant
johnmatthewtennant marked this pull request as ready for review August 26, 2026 18:18
@johnmatthewtennant
johnmatthewtennant requested a review from a team August 26, 2026 18:18

@morgmart morgmart left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@johnmatthewtennant
johnmatthewtennant merged commit a417e14 into main Aug 26, 2026
9 checks passed
@johnmatthewtennant
johnmatthewtennant deleted the fix-steered-message-order branch August 26, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants