You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(chat): keep streaming replies after their prompts - #37773
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
Phone web
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.
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: 3 · 1 · 1
Failed checks: 1 warning · 1 inconclusive
Check name
Status
Explanation
Resolution
Docstring Coverage
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
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 checks: 3 passed
Check name
Status
Explanation
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Phone Send interaction, before:
page@80ae3e7dd028e920f0341a5c64b885a7.webm
Phone Send interaction, after:
page@a39c3aece016aa0b12319ab0a237614c.webm
Testing
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=1passed 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (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.