Skip to content

fix(chat): keep streaming replies after their prompts - #37773

Merged
AmoabaKelvin merged 5 commits into
mainfrom
streaming-replies-follow-prompts
Nov 3, 2026
Merged

AmoabaKelvin merged 5 commits into
mainfrom
streaming-replies-follow-prompts

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​268
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​169 $\color{#cf222e}{\Huge{\mathbf{−}}}$​75 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94

ELI5

Your sent prompt now stays above the reply it starts on desktop and phone. Follow-ups queued during that reply stay below it.

What Changed

Desktop and phone use the same causal rank for transcript rows, active sent echoes, the streaming preview and queued sends. Send-time placement uses the host's existing durable turn stamp, so transcript catch-up, permission changes and phone Stop do not move queued follow-ups ahead of the current answer. Phone preview reconciliation now reads the transcript and pending sends; structured transcript ordering stays with its existing projection owner. Desktop send capture also preserves reconciled host activity through transcript read errors and recovery.

Why

The old rank put every sent echo after the preview. The preview has no timestamp, and client and host clocks cannot establish which prompt it answers. Shared semantic ranks repair the order without comparing those clocks or changing the wire format.

Linked Issue

Repairs the streaming-reply ordering portion of #15608. Its separate history-scroll-anchor scope remains open. Fresh replacement for the desktop-only #15617, as requested in triage.

Visual Proof

Production components with controlled transcript/status inputs. Desktop uses hidden Electron on macOS at 1100×780; phone uses the production web rendering at 390×844 with the real Send button. These are component captures, not a live agent or native simulator run.

Surface Before After
Desktop Before After
Phone web Before After

Phone Send interaction, before:

page@80ae3e7dd028e920f0341a5c64b885a7.webm

Phone Send interaction, after:

page@a39c3aece016aa0b12319ab0a237614c.webm

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Reproduced the wrong order on fresh main at both desktop and phone owner boundaries. Focused and implementation-dependent checks pass, 302 desktop/shared tests across 28 files and 153 phone tests across 14 files, with maxWorkers=2. The existing streaming spec's 10 cases also pass. Changed-code quality and React Doctor pass against origin/main. The integrated check:changed --maxWorkers=2 --timeout=1 passed 29/30 selected checks, including node/web/CLI typechecks and all static gates; only broad related-unit selection hit the authorized one-minute limit. The focused dependent selection above is the local substitute, with exact-head CI still required.

Exact-head CI is green on cc74b54ee30adf9e7949b2d6a4a9d052dd9c7bb9: PR checks passed and Mobile verify. One unchanged ACP backlog-timing test failed on the first attempt, passed all 11 cases in isolation and the prior CI run, then passed the single bounded failed-job retry. No ACP code or assertions were changed.

Coverage includes idle sends, multiple queued echoes with skewed clocks, prompt reconciliation, caught-up preview suppression, old-host unknown epochs, phone Stop and empty history, plus structured opening sends. Rendered captures show prompt → streaming answer → queued follow-up, with no phone page errors.

To try: open terminal-backed chat with an idle agent, send a prompt, then send two follow-ups while the reply streams. The initial prompt should stay above the reply; follow-ups should stay below it through transcript catch-up and Stop.

Risk

Level: Medium

The main risk is classifying an unmatched echo during a host turn transition. The classifier uses the existing durable host stamp and preserves queue placement when older hosts provide no durable epoch. No saved-data or RPC schema changes; the same owner covers local and remote sessions and does not depend on workspace paths or OS APIs. Actual SSH, Linux, Windows and native-device runs are left to CI and device verification. A plain revert restores the old display behavior.

AI Disclosure

Review

Two independent read-only peers in each of two rounds. Both round-one findings were repaired; the final pair returned one clean report and one P2 about send capture during a transcript read error. That correction has failing-first view-boundary coverage, but was made after the two-round review cap and has not had a third independent review.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Expected-behavior repair, eligible to merge only after the exact-head PR aggregate and Mobile verify gates are green. Worktree: /Users/kelvinamoaba/orca/workspaces/orca/mw3-b2-chat-09.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Focused local checks are listed above; exact-head CI passed the broader gates. No full local suite or packaging build was run.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Pending sends now record the host working epoch and receive active or queued placement. Shared ordering and streaming-text logic account for queued messages. Desktop and mobile chat pass epoch and placement data through pending-send tracking and rendering.

Merge Risk: Minimal · up to bae4c

No actionable ordering defect is established. Merge after the required exact-head checks pass.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Inconclusive The description follows the template well: it has an ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk with a Level, AI Disclosure heading, Review, Agent skill boundary checkbox, Note… 1) Fill in the AI Disclosure section. State which AI model, if any, was used, or state that none was used. The template asks for this from anyone who is not a StablyAI team member. 2) Confirm the linked issue requirement. The template says …
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: keeping streaming replies after their prompts. It is concise and directly matches the desktop and phone ordering fix.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 21 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description follows the template well: it has an ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk with a Level, AI Disclosure heading, Review, Agent skill boundary checkbox, Notes, and a checklist. The ELI5 is in plain language, and the What Changed and Why sections explain the mechanism and the rejected alternative (comparing client and host clocks). Testing lists concrete commands, check counts, and CI run links. Risk names the riskiest part (classifying an unmatched echo during a host turn transition), states that there are no saved-data or RPC schema changes, and gives a revert path. Visual Proof includes before/after captures for desktop and phone. The main gaps are: the AI Disclosure section is left empty, though the template says to fill it in for non-team contributors and the author is not identifiable as an internal member from the text; the Linked Issue is a partial reference ("Repairs the streaming-reply ordering portion of #15608") and the template line "Fixes #" was replaced with a non-closing reference, which may not satisfy the outside-contributor rule requiring an actual linked issue; and the Testing section counts (302 tests across 28 files) differ from the objectives text (289 tests across 27 files), which is a consistency point worth confirming, not a template violation.

Resolution

  1. Fill in the AI Disclosure section. State which AI model, if any, was used, or state that none was used. The template asks for this from anyone who is not a StablyAI team member. 2) Confirm the linked issue requirement. The template says an actual issue must be linked for outside contributors, and "Refs"-style references are not sufficient. The current text says it repairs part of #15608 and that a separate scope remains open. Either link a closing reference such as "Fixes #15608" if that issue is fully addressed, or confirm the contributor status and that an issue exists for this change. 3) Reconcile the test counts. The description reports 302 desktop/shared tests across 28 files, but the PR objectives report 289 tests across 27 files. Use one accurate figure. 4) Optionally, state the review status clearly. The Review section says the final correction has not had a third independent review. Keep that statement, or add the result of that review before merge.
Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94864d78-6d8a-41f2-a204-ee46d4dcd1ea
Commits

Reviewing files that changed from the base of the PR and between 2f6601d and bae4cfd.

Files selected for processing: 21
  • mobile/src/session/native-chat/mobile-native-chat-pending-echo.ts
  • mobile/src/session/native-chat/mobile-native-chat-render-data.test.ts
  • mobile/src/session/native-chat/mobile-native-chat-render-data.ts
  • mobile/src/session/native-chat/use-mobile-native-chat-controller.test.ts
  • mobile/src/session/native-chat/use-mobile-native-chat-controller.ts
  • mobile/src/session/use-mobile-native-chat-terminal-turn.ts
  • src/renderer/src/components/native-chat/NativeChatResolvedView.prompt-card-composer.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
  • src/renderer/src/components/native-chat/native-chat-live-session-contract.ts
  • src/renderer/src/components/native-chat/native-chat-message-grouping.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/native-chat-session-assembler.ts
  • src/renderer/src/components/native-chat/use-native-chat-pending-delivery.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-pending-delivery.ts
  • src/shared/native-chat/native-chat-live-status.test.ts
  • src/shared/native-chat/native-chat-live-status.ts
  • src/shared/native-chat/native-chat-streaming.ts
  • src/shared/native-chat/native-chat-types.ts
  • src/shared/native-chat/transcript/native-chat-message-order.test.ts
  • src/shared/native-chat/transcript/native-chat-message-order.ts
  • src/shared/native-chat/transcript/native-chat-pending-sends.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

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.

1 participant