fix(desktop): preserve mid-turn message order - #73882
Conversation
fe0f63e to
167c5fa
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression test. The proposed reorder conflicts with the current live transcript contract.
Problems
- The primary redirect path explicitly inserts the correction before the active reply before awaiting the RPC (
apps/desktop/src/app/session/hooks/use-prompt-actions/index.ts:686-690); its helper inserts at the active stream or latest-assistant index (:267-280). Session tiles use the same placement (apps/desktop/src/app/chat/session-tile-actions.ts:287-304). appendLiveSessionProjectionalready matches that live ordering—prompt, corrections, thenassistant-stream—atapps/desktop/src/app/session/hooks/use-session-actions/utils.ts:510-535. This was intentionally established by8a21df18acbe73c63d06747d0ab359288bf84276(fix(desktop): place steer messages before redirected replies).
Suggested changes
- Retain the existing projection order and restore the prior test expectation. An arrival-order redesign would need to update the live redirect paths and recovery contract together, rather than changing only resume projection.
Automated hermes-sweeper review.
| @@ -494,6 +478,23 @@ export function appendLiveSessionProjection( | |||
| }) | |||
There was a problem hiding this comment.
This reverses the order used by both live redirect renderers: the primary path passes insertBeforeActiveReply: true (use-prompt-actions/index.ts:686-690) and session tiles insert before streamId/the last assistant row (session-tile-actions.ts:287-304). Keeping this block before the assistant projection is necessary for resume to match the live transcript.
|
Verified the review independently against current Both live redirect paths insert the correction before the active reply, not after:
The real bug in #73793 is real, though: a mid-turn correction is inserted once, before a single assistant bubble that keeps mutating in place for the rest of the turn — so by the time the turn ends, content generated before the correction (which the user already watched appear above it) ends up rendered below it too. Fixing that properly means splitting the in-flight assistant bubble at each correction boundary — both live paths and the resume/recovery projection need to agree on that split, which likely also needs the backend Closing this one rather than merging a projection-only reorder that's confirmed to conflict with the established contract. Happy to see a follow-up PR that tackles the bubble-splitting approach end-to-end if someone wants to take that on — #73793 stays open for it. |
What changed
Reordered the live-session projection so mid-turn correction messages are appended after the assistant output that was already streaming when the correction arrived.
Why
The live renderer updates the assistant bubble in place, then appends a mid-turn user message. On resume or reload,
appendLiveSessionProjection()rebuilt the same data as prompt, correction, assistant. That moved the correction above all partial assistant output, including content the user had already read.The projection now matches the visible arrival order: prompt, current assistant stream, corrections, then any queued next-turn prompt. Existing persisted corrections are still deduplicated.
Closes #73793.
Validation
npm run --workspace apps/desktop test:ui -- src/app/session/hooks/use-session-actions/utils.test.ts(42 tests)npm exec --workspace apps/desktop -- eslint src/app/session/hooks/use-session-actions/utils.ts src/app/session/hooks/use-session-actions/utils.test.tsnpm run --workspace apps/desktop typecheckgit diff --check