Repository navigation
Conversation
…used it The streaming preview bubble always rendered before every optimistic user echo. For a send issued while the agent was idle the echo IS the newest turn and the bubble is its answer, so the reply built above the prompt that caused it and the sent message stayed stranded at the bottom until the transcript's user row landed (stablyai#15608). A pending send now records whether the agent was already working when it was issued. Sends into an idle agent render before the streaming bubble; sends queued behind live work keep their previous position below it, which was already correct for them. The split is a pure helper over the pending list so the ordering rule is unit-tested without the view. Desktop chat view only — the mobile view reaches the same wrong order through its own mechanism and is left for a follow-up.
📝 WalkthroughWalkthroughNative chat marks optimistic sends made during an active agent turn with Merge Risk: ⚪ Minimal · up to This PR corrects desktop chat message ordering for idle-agent replies without changing mobile behavior, with targeted tests and type checking reported clean. No actionable merge-blocking risk remains beyond normal review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/native-chat/native-chat-pending.ts (1)
43-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new renderer comments.
Keep only the non-obvious invariant. The surrounding identifiers and code show the placement behavior.
src/renderer/src/components/native-chat/native-chat-pending.ts#L43-L47: reduce the field documentation to one concise sentence.src/renderer/src/components/native-chat/native-chat-pending.ts#L276-L284: reduce the helper documentation to its ordering invariant.src/renderer/src/components/native-chat/NativeChatView.tsx#L242-L244: reduce the send-time classification comment to one line.src/renderer/src/components/native-chat/NativeChatView.tsx#L294-L297: reduce the placement comment to one line.As per coding guidelines, comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2045045b-6d90-42d3-adf7-dce3e478821c
📒 Files selected for processing (3)
src/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/native-chat-pending.test.tssrc/renderer/src/components/native-chat/native-chat-pending.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
|
Thanks for the fix! #37773 is now merged and covers this desktop ordering repair plus the phone path, so this PR is superseded. |
Summary
What
The desktop native-chat view now renders the streaming reply bubble below an optimistic user echo that was sent while the agent was idle, and keeps it above echoes that were queued while the agent was already working.
A pending send records
queuedWhileWorkingat issue time (session.status === 'working'), and the transcript merge splits the rendered echoes around the streaming bubble via a new pure helper,splitPendingMessagesAroundStreaming(native-chat-pending.ts).Why
#15608 — sending a prompt to an idle agent rendered the streaming reply above the optimistic echo of that prompt, so the sent message sat stranded at the bottom of the transcript while its answer built above it. The old merge unconditionally placed the bubble before all echoes (the code comment even documented that order), which is correct only for sends queued behind an in-flight turn — for an idle-time send, the echo is the newest turn and the bubble is its answer.
Scope
Desktop chat view only, as called out in the issue: the mobile view reaches the same wrong order through its own mechanism and needs a separate change. This PR does not touch mobile.
Testing
native-chat-pending.test.ts(pure module, no React): idle-time echo sorts before the bubble; queued-behind-work echo stays after; a mixed pending list splits while preserving relative order on both sides. 73/73 in the two pending suites.NativeChatView.test.tsx5/5 unchanged;pnpm run typecheckclean.Fixes the desktop half of #15608.