Repository navigation
fix(native-chat): stop flashing a reconnecting line on a stream drop - #24898
Conversation
A single transcript stream drop flashed 'Reconnecting to this chat…' above the composer for about a second. An unnamed read failure now adds nothing: the transcript and composer stay, and the host's own status shows reachability. Named or final failures keep their line.
…aming nothing A loaded chat with no messages yet still flipped to the full-pane "Could not load conversation" on every stream blip: the read owner stored any read failure as status 'error', and the pane shows that error whenever there is no transcript. Once the chat has loaded, a failure that names no reason is now the transport's own retry and is not stored; a named or final failure, and any failure before the first load, are reported as before. The "names a reason" check moves next to the final-refusal check so the owner and the failure notice share it. The older-page read moves to its own module to keep the read owner within its line budget.
A chat that never loaded but already shows the user's own message (a launch prompt or a queued send) said nothing when its first read kept failing with a failure that names no reason. The loaded case is handled at the read owner, so any read failure the pane sees beside messages is named, final, or from before the first load; the status area now says its words in every such case.
The read owner skipped any loaded-chat failure without a named reason, but an older host sends every refusal without details, so a refusal it really sent (such as a damaged history) went unshown while the read retried in silence. Skip only failures the host sent no refusal for, which is lost contact; any refusal is the host's answer and is shown. The shared 'named' check is no longer needed and is removed.
…ed as Comment-only: the read owner treats a failure with no host refusal as lost contact, which covers hosts too old to attach refusals; the test's reasonless case is a reason this build doesn't know.
…onnecting-line # Conflicts: # src/renderer/src/components/native-chat/NativeChatStructuredSessionStatus.tsx
Review summaryThe problem. In the native chat, a single drop of the connection that streams a chat's messages (a network blip, a remote host restarting, waking from sleep) flashed "Reconnecting to this chat…" above the message box for about a second, until the automatic retry reconnected. A chat that had loaded but had no messages yet flipped its whole pane to "Could not load conversation" for that second instead. Nothing was wrong and there was nothing to do. What changes for you. A brief drop no longer changes the chat at all: messages and the message box stay as they are, and the app reconnects in the background as before. A host that stays unreachable shows on the host's own status (the status bar's host list, and the workspace card in the sidebar), not as a line in every chat. A chat that never loaded but already shows your own message now says "This chat's history couldn't be loaded." if its history keeps failing, instead of "Reconnecting…". Failures the host actually reports keep their words. What the review changed. The first version only deleted the grey line. Review found that this left the cause in place: the brief drop was still stored as the chat's error, so an empty loaded chat still flashed the full-pane error. The fix moved to the source. Once a chat has loaded, a failure that carries no answer from the host is treated as lost contact and isn't stored; the connection keeps retrying. Any refusal the host sends is still shown. Review also caught three problems introduced along the way, all fixed:
Deferred (all minor, listed so nothing is hidden):
Verified.
Not verified.
|
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe native-chat session derives host outage status from runtime connection state and displays offline or reconnecting notices. It offers reconnection when allowed and suppresses older-history availability during an outage. The read owner uses a shared bounded reader for older-history requests and suppresses transport errors without a refusal after the session loads. The SSH status segment now uses shared runtime-host connection helpers. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Reconnection or project refresh failures may still produce unhandled errors. These bounded risks need owner awareness or follow-up before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is bounded to conversation loading and recovery. Explicit host refusals remain visible, and history requests retain their existing session identity and interruption protections. No new security issue was identified in the reviewed paths, but end-to-end service security was not established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 12 files. (6 skipped: 6 unsupported.)
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.
✅ No new issues found.
Reviewed changes
- Loaded chats ignore a stream drop — the read owner now drops a failure with no host refusal once
epoch !== null, so a transient drop no longer setsstatus: 'error'and neither the grey "Reconnecting…" line nor the full-pane error flashes. - Refusals and pre-load failures still surface — a host refusal (any reason, including one this build doesn't know) and any failure before the first load are stored and worded exactly as before.
- Status surface simplified —
NativeChatStructuredSessionStatusloses thereconnectingbranch and itstranslateimport;NativeChatStructuredSessionnarrows the statuserrorprop to!readFailure. - Older-page paging extracted — the anchor-retry loop moved verbatim into
structured-agent-session-older-page-read.ts, parameterized bygetState/apply/shouldStop. - Locale cleanup —
components.native-chat.state.reconnectingremoved from all six locales. - Tests — new stream-failure cases for the read owner (drop after load, known refusal with/without a reason after load, failure before load) and a rendered-status case beside a never-loaded chat.
I read the full diff and traced the surrounding code paths. epoch is only set by a page/snapshot/reset (replacePage), never by the loading action, so the epoch !== null gate is a sound "has loaded" proxy and the before-first-load path stays intact. Stream refusals ride in error.data.refusal while plain drops do not, so the owner's refusal === undefined check separates the two correctly. The extracted paging file reads the same mutable snapshot state the inline version did. The targeted suites (use-structured-agent-session-read, NativeChatStructuredSession.read-error, structured-agent-session-read-transport, 38 tests) pass locally, and the removed locale key has no remaining references.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
A loaded remote chat looked live through a long host outage while sends sat in the outbox. Derive a host-scoped notice from the host's connection state: '<host> is reconnecting…' after a 2 s grace, '<host> is offline' at once with the status bar's Connect as Reconnect, and a composer placeholder saying sends go out when the host reconnects. A lost read beside the notice adds no line of its own, and older history waits for the host.
A send while the host's transport is down fails and waits for its own Retry, so the composer must not promise it will go out on reconnect. A host that refused us (auth, protocol) still reads offline but offers no Reconnect, which would be turned away the same way. Name the host with the shared display-label selector, and keep the notice's live region mounted so it is announced.
…onnecting-line # Conflicts: # src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx # src/renderer/src/i18n/locales/es.json
…onnecting-line # Conflicts: # src/renderer/src/components/native-chat/NativeChatStructuredSessionStatus.tsx # src/renderer/src/components/native-chat/structured-agent-session-read-owner.ts
Review summary (follow-up)This updates the earlier summary; the design changed after it. The problem. In the native chat, a single drop of the connection that streams a chat's messages flashed "Reconnecting to this chat…" above the message box for about a second, or flipped an empty chat to "Could not load conversation". When a remote host really went away, that same unnamed line was the only thing a chat said, with nothing to do about it. What changes for you.
What the review changed since the last summary.
Deferred, all minor:
Verified.
Not verified.
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
168f2e0e-baa0-4add-af12-e4973617c2a0
📒 Files selected for processing (17)
src/renderer/src/components/native-chat/NativeChatHostOutageNotice.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.host-outage.test.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.read-error.test.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSessionStatus.tsxsrc/renderer/src/components/native-chat/structured-agent-session-read-owner.tssrc/renderer/src/components/native-chat/use-native-chat-host-outage.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-host-outage.tssrc/renderer/src/components/status-bar/SshStatusSegment.test.tssrc/renderer/src/components/status-bar/SshStatusSegment.tsxsrc/renderer/src/components/status-bar/runtime-environment-explicit-connect.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
💤 Files with no reviewable changes (1)
- src/renderer/src/components/native-chat/NativeChatStructuredSessionStatus.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const reconnect = (environmentId: string): void => { | ||
| setConnecting(true) | ||
| void connectRuntimeHostAndReloadProjects(environmentId).finally(() => { | ||
| if (mountedRef.current) { | ||
| setConnecting(false) | ||
| } | ||
| }) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Handle a rejected reconnect promise.
connectRuntimeHostAndReloadProjects(...).finally(...) returns a new promise. If the helper rejects (for example, a fetch throws), that rejection is unhandled, because the call has no catch and uses void. The finally handler still resets connecting. The unhandled rejection can still reach the global handler.
Proposed fix
- void connectRuntimeHostAndReloadProjects(environmentId).finally(() => {
- if (mountedRef.current) {
- setConnecting(false)
- }
- })
+ void connectRuntimeHostAndReloadProjects(environmentId)
+ .catch(() => {})
+ .finally(() => {
+ if (mountedRef.current) {
+ setConnecting(false)
+ }
+ })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const reconnect = (environmentId: string): void => { | |
| setConnecting(true) | |
| void connectRuntimeHostAndReloadProjects(environmentId).finally(() => { | |
| if (mountedRef.current) { | |
| setConnecting(false) | |
| } | |
| }) | |
| } | |
| const reconnect = (environmentId: string): void => { | |
| setConnecting(true) | |
| void connectRuntimeHostAndReloadProjects(environmentId) | |
| .catch(() => {}) | |
| .finally(() => { | |
| if (mountedRef.current) { | |
| setConnecting(false) | |
| } | |
| }) | |
| } |
| /** The status bar's Connect for a paired host; also the chat's Reconnect when its host is offline. */ | ||
| export async function connectRuntimeHostAndReloadProjects(environmentId: string): Promise<boolean> { | ||
| const store = useAppStore.getState() | ||
| const reachable = await connectRuntimeHostForNavigation({ | ||
| environmentId, | ||
| refreshStatus: connectRuntimeEnvironmentAndRecordStatus, | ||
| fetchRepos: store.fetchRuntimeEnvironmentRepos, | ||
| fetchWorktrees: store.fetchWorktrees, | ||
| fetchLineage: store.fetchWorktreeLineage | ||
| }) | ||
| if (!reachable) { | ||
| toast.error( | ||
| translate( | ||
| 'auto.components.status.bar.SshStatusSegment.runtime_connect_unavailable', | ||
| 'Remote host is not reachable' | ||
| ) | ||
| ) | ||
| } | ||
| return reachable | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 'connectRuntimeHostAndReloadProjects' src/renderer/src
rg -nP -C3 'unhandledrejection' src/renderer/src | head -40Repository: stablyai/orca
Length of output: 10442
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\\n' '--- reviewed helper ---'
nl -ba src/renderer/src/components/status-bar/runtime-environment-explicit-connect.ts | sed -n '1,100p'
printf '%s\\n' '--- SshStatusSegment caller ---'
nl -ba src/renderer/src/components/status-bar/SshStatusSegment.tsx | sed -n '90,118p'
printf '%s\\n' '--- NativeChatHostOutageNotice caller ---'
nl -ba src/renderer/src/components/native-chat/NativeChatHostOutageNotice.tsx | sed -n '1,45p'
printf '%s\\n' '--- crash diagnostics handler ---'
nl -ba src/renderer/src/lib/crash-diagnostics.ts | sed -n '1,80p'
printf '%s\\n' '--- merge-base helper / related old flow ---'
git show 6aa12c30ef5ab11d9bbc09fb4ae05e273f4727ce:src/renderer/src/components/status-bar/runtime-environment-explicit-connect.ts 2>&1 | sed -n '1,120p' || true
printf '%s\\n' '--- worktree refresh implementation references ---'
rg -n -F 'refreshRuntimeProjectWorktreesAndLineage' src/renderer/srcRepository: stablyai/orca
Length of output: 12765
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\\n' '--- scheduler implementation ---'
nl -ba src/renderer/src/hooks/runtime-project-refresh-scheduler.ts | sed -n '1,145p'
printf '%s\\n' '--- rejection listener implementation ---'
nl -ba src/renderer/src/lib/crash-diagnostics.ts | sed -n '78,145p'
printf '%s\\n' '--- relevant changed-file diff against merge base ---'
git diff --unified=4 6aa12c30ef5ab11d9bbc09fb4ae05e273f4727ce 38159dde006b37b2dd7e200fe0ad5acb013cfd21 -- src/renderer/src/components/status-bar/runtime-environment-explicit-connect.ts src/renderer/src/components/status-bar/SshStatusSegment.tsx src/renderer/src/components/native-chat/NativeChatHostOutageNotice.tsxRepository: stablyai/orca
Length of output: 14993
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\\n' '--- status-bar connect callback bindings ---'
rg -n -C 5 -F 'connectRuntimeHost' src/renderer/src/components/status-bar/SshStatusSegment.tsx
printf '%s\\n' '--- chat reconnect button binding ---'
nl -ba src/renderer/src/components/native-chat/NativeChatHostOutageNotice.tsx | sed -n '17,66p'Repository: stablyai/orca
Length of output: 4471
Handle project-refresh failures in the new chat reconnect flow.
When the host connects but the project refresh fails, connectRuntimeHostAndReloadProjects rejects without showing a refresh error. The new chat reconnect handler’s .finally() clears its loading state but leaves the returned promise rejected. Catch the refresh failure, show a separate error toast, and return true because the host connected.
No conflicts. Main's host outage notice (#24898) merges into the chat view beside this branch's send state; nothing in main's 7 commits sends through the desktop's outbox.

ELI5
When the connection that streams a chat's messages blipped for a moment, the native chat flashed "Reconnecting to this chat…" above the message box for about a second, and then it went away. Nothing was wrong and there was nothing to do, so the line was noise. A chat that had loaded but had no messages yet was worse: the whole pane flipped to "Could not load conversation" for that second.
This PR stops a brief blip from changing the chat at all. When the remote host itself really is unreachable, the chat now says so in one line that names the host, the way the common pattern does: " is reconnecting…" once it has been reconnecting for a couple of seconds, or " is offline" with a Reconnect button.
Follow-up to #24564, which added a written rule for status messages: a message that flashes for a passing state is removed, not delayed.
What Changed
The problem. The native chat reads its transcript through a live stream. When that stream drops (a network hiccup, a remote host restarting, the computer waking from sleep), the read reports the failure at once and retries 750 ms later; the retry almost always succeeds. The failure was stored as the chat's error state even when the chat had already loaded, and two things displayed it: a grey "Reconnecting to this chat…" line above the composer when the chat had messages, and the full-pane "Could not load conversation" screen when it had none. Both flashed for about a second on every drop. And because the line was per chat and tied to the stream, it was also the only thing a chat said when a remote host went away for a long time — without naming the host or offering anything to do.
What this changes for you
Mechanism.
structured-agent-session-read-owner.ts) now decides what a read failure means. Once the chat has loaded, a failure that comes with no refusal from the host is treated as lost contact: it is not stored as the chat's error, and the stream keeps retrying exactly as before (750 ms, doubling up to 30 s, and at once when a remote host comes back). Any refusal the host sent, and any failure before the chat first loads, is stored and shown as before. So a loaded chat only shows an error the host actually sent, and the status area under the transcript loses its special "reconnecting" case (the string is removed from every language file).use-native-chat-host-outage.ts) derives the notice from the connection state Orca already keeps for each remote host (the same state the status bar's host list reads); nothing new is stored. "Reconnecting" (and "checking", and a host whose Orca isn't answering yet) shows only after the host has stayed that way for 2 s, so a normal reconnect never flashes it; "disconnected" shows "offline" at once and stays until the host is connected again, so background retries don't flip it back and forth. Temporary-VM hosts are covered. A per-chat stream blip can't trigger it, because it doesn't change the host's state. The notice (NativeChatHostOutageNotice.tsx) sits above the status area in a screen-reader status region.status-bar/runtime-environment-explicit-connect.tsso both can call it. The reader's older-history paging moved, unchanged, intostructured-agent-session-older-page-read.tsto keep the reader within the file-length limit.Why
Fix the state, not the line. Deleting only the grey line would have left the same blip flipping an empty chat to a full-pane error, because the transient failure was still stored as the chat's error. Keeping it out of the chat's state once the chat has loaded removes every display of it at once.
Say the host's outage, scoped to the host. Whether a remote host can be reached is a fact about the host, not about one stream, so the notice is derived from the host's connection state and names the host. That is what the common pattern does inside the chat. Orca's other host surfaces (the status bar's host list and the sidebar workspace card) are too indirect to carry it alone: the status bar's button is one combined indicator (host names appear only after opening its menu), and the sidebar card only marks a host once it's confirmed down. Over SSH, a lost connection only means the host's state can't be checked yet, not that anything failed, so the copy says "reconnecting", not "failed".
Alternatives considered.
Differences from the common pattern
Linked Issue
Follow-up to #24564.
Visual Proof
A chat on a remote Orca host. Captured on a separate Mac test machine with two isolated, hidden test setups: a remote Orca host plus a desktop app paired to it, one setup built from
main(before) and one from this PR (after), with a stand-in agent (no real agent, account or login). The app was driven by a non-Claude automated QA agent. Timings come from an in-page timeline of what text was on screen, in milliseconds after each event. The host is named "qa-host". These were captured on this PR's commit fde0885; later commits only mergemain, align the notice's width with main's new chat-width setting, and fix a test.1. One stream blip while the host stays connected. Before: "Reconnecting to this chat…" was on screen from +86 to +899 ms. After: nothing appeared through 4.6 s.
2. The host stops answering for ~10 s, then comes back. Before: "Reconnecting to this chat…" from +484 ms until the host was back (+11.1 s). After: nothing for the first ~1.7 s, then "qa-host is reconnecting…" above the composer, gone as the host came back (+11.6 s).
3. The host is disconnected from the status bar's host menu, then reconnected. Before: "Reconnecting to this chat…" from +744 ms until Reconnect was chosen in the status bar (+5.5 s); the "before" frame below was taken ~0.1 s before that line appeared, so the timeline is the evidence for it. After: "qa-host is offline" at once with a Reconnect button in the chat; clicking it at +3.7 s cleared the line.
No new toast, banner or label appeared in the after build. The "Enjoying Orca?" card is the existing first-run prompt and shows in both builds.
A local chat (earlier captures, behaviour unchanged). Captured on a Windows test machine with the same kind of hidden test builds; the drop is one simulated stream error sent through the real app code.
On that machine a screenshot took ~3 s, so the "before" images of the first two local cases held the reconnect for 4.5 s to be photographable; the timings are from drops that were not held.
Testing
use-native-chat-host-outage.test.tsx(new): no notice while connected; "reconnecting" only after 2 s and cleared at once on recovery; "offline" at once for a disconnected host and held through retries until connected; Reconnect offered for a disconnected or never-reached host but not for one that refuses us; temporary-VM hosts included; the host name follows the user's rename, then the host's name, then its id.NativeChatStructuredSession.host-outage.test.tsx(new): a loaded remote chat whose host stays connected shows no host line and no read line (the "a blip can't trigger it" proof); a reconnecting host is named above the composer only after the 2 s wait; a disconnected host reads offline at once with Reconnect; a host that refused us gets no Reconnect and the composer promises nothing; while the notice shows, a lost-contact read failure adds no second line and a never-loaded chat waits quietly; a refusal the host itself sent is still worded.use-structured-agent-session-read.test.tsx(new tests, real history reader with the network client mocked): after load, a dropped connection leaves the chat as it was; a refusal the host sent is still stored (with a known reason and an unknown one); a failure before the first load is still stored.NativeChatStructuredSession.read-error.test.tsx: a never-loaded chat showing a message with an unexplained failure says "This chat's history couldn't be loaded." once and never mentions reconnecting.Each new behaviour was checked by reverting only the source and confirming the matching tests fail.
Also run: the read transport and read-owner tests, all
NativeChatStructuredSession*andNativeChatComposer*tests,SshStatusSegment.test.ts; web typecheck, oxlint and format, the changed-code quality gate (design system, React Doctor), and the localization catalog, extraction and coverage checks (new copy in all six languages).Visual proof: a remote-host chat (blip, host stops answering, Disconnect + Reconnect) on a Mac test machine, and three local-chat cases on a Windows test machine (see above).
Not verified: a real network drop against a real remote host (the captured local drops are simulated through the real app code; the remote-host outage was a real stop of the test host process).
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)