Repository navigation
fix(native-chat): read SSH transcripts on their owning host - #15515
brennanb2025 wants to merge 13 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds provider-session ownership metadata and propagates it through native chat APIs, mobile sessions, renderer state, and runtime resume flows. Native chat transcript reads and subscriptions now resolve local, SSH, legacy, and unknown ownership. SSH transcripts use generation-pinned ranged filesystem access with bounded reads and stability checks. Unresolved and unverifiable transcript states remain advisory while polling continues. Tests cover routing, provider replacement, error precedence, callback failures, cleanup, and end-to-end ownership behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/native-chat/transcript-watch.ts (1)
52-58: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the new rationale comments.
Keep the non-obvious reason, but reduce these comments to brief statements.
src/main/native-chat/transcript-watch.ts#L52-L58: Use one concise comment for the delayed advisory rationale.src/main/native-chat/transcript-watch-unresolved-notice.test.ts#L47-L50: Use one concise comment for the non-terminal recovery rationale.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: 34a00b18-eec4-460c-8a7f-613d11f01727
📒 Files selected for processing (3)
src/main/native-chat/transcript-watch-contract.tssrc/main/native-chat/transcript-watch-unresolved-notice.test.tssrc/main/native-chat/transcript-watch.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/native-chat/transcript-watch.ts (1)
52-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new explanatory comments.
Use one concise rationale sentence per comment block. The current comments restate control flow and implementation details.
As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Also applies to: 93-115
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fcd0a76b-4c25-4806-95a0-6460a2d97fc0
📒 Files selected for processing (5)
src/main/native-chat/transcript-watch-resolve-poll.test.tssrc/main/native-chat/transcript-watch-unresolved-notice.test.tssrc/main/native-chat/transcript-watch.tssrc/renderer/src/components/native-chat/use-native-chat-live-session.test.tssrc/renderer/src/components/native-chat/use-native-chat-live-session.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Review statusScope check first: this PR does not fix #13663. An agent in an SSH worktree still cannot load Review loop — 3 independent rounds, converged
Defects found (all fixed, each with red-proof against the pre-fix source):
Every guard was mutation-tested — 8 mutations, all red. No vacuous tests remain. Correction to the original descriptionIt claimed desktop "spins forever". It doesn't — desktop was already bounded at ~60s by the ReadinessOpening pass: READY WITH FIXES. Closing pass after review: READY TO MERGE. All opening findings CI: 46 checks, all green. Manual validationValidated over a real SSH relay (throwaway Docker target, real relay, real
Local control on the same build: real snapshot, 4 messages, 1.0s, no error.
Follow-ups (not blocking)
|
Manual QA: real SSH relay (issue #13663 / PR #15515)Isolated Orca dev instance ( Throwaway Linux Docker SSH target ( UI proofAfter the ~60s unresolved-notice deadline the transcript area showed an honest advisory instead of an endless spinner: Visible copy:
SSH arm —
|
| Host | Path / slug | Result |
|---|---|---|
| Remote container | /root/.claude/projects/-work-demo-project-grokqawt/a57cc132-bd76-4330-b8e1-3836b543e2f8.jsonl |
present |
| Desktop | ~/.claude/projects/-work-demo-project-grokqawt |
absent |
This is the #13663 split: the agent wrote on the remote host, the desktop resolved nothing, and the subscribe path now emits one advisory instead of spinning forever.
af48f0b to
f9e9a9b
Compare
f9e9a9b to
b757d18
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
src/main/providers/ssh-filesystem-dispatch.test.ts (1)
73-99: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMove test cleanup into a
finallyblock.The
statesdeclaration appears once. If an assertion fails,unsubscribe()andunregisterSshFilesystemProvider('generation-conn')do not run, leaving the module-global listener registered for later tests.src/renderer/src/components/native-chat/use-native-chat-live-session.ts (1)
134-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the added comments.
These comments explain local control flow across multiple lines. Replace each with one concise reason.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Proposed change
- // Why: this hook's notFound window and the main-side unresolved notice both - // expire at ~60s on the same transcript; the stream owns recovery, so its - // message wins regardless of which lands last. + // Prefer the stream error over concurrent seed-read errors. ... - // Why: nor may it trade already-read history for an error card (mobile - // keeps its retained transcript for the same reason). + // Retain existing transcript history after a stream error.Also applies to: 217-218
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e7516b8-c7b5-4e9c-bbb2-79669f99e618
📒 Files selected for processing (62)
config/reliability-gates.jsoncmobile/src/session/mobile-native-chat-eligibility.test.tsmobile/src/session/mobile-native-chat-eligibility.tsmobile/src/session/use-mobile-native-chat-controller.tsmobile/src/session/use-mobile-native-chat-session.test.tsmobile/src/session/use-mobile-native-chat-session.tssrc/main/agent-hooks/server-hook-http-ingest.test.tssrc/main/agent-hooks/server-ingest-terminal-status.test.tssrc/main/agent-hooks/server-last-status-hydrate-validation.test.tssrc/main/agent-hooks/server.tssrc/main/ipc/native-chat.test.tssrc/main/ipc/native-chat.tssrc/main/native-chat/native-chat-transcript-owner.tssrc/main/native-chat/session-file-resolver.tssrc/main/native-chat/ssh-transcript-host-routing.test.tssrc/main/native-chat/ssh-transcript-range-fs.tssrc/main/native-chat/ssh-transcript-read.tssrc/main/native-chat/ssh-transcript-subscription.tssrc/main/native-chat/transcript-file-version.tssrc/main/native-chat/transcript-host-verdict.tssrc/main/native-chat/transcript-incremental-reader.tssrc/main/native-chat/transcript-native-watcher.tssrc/main/native-chat/transcript-range-fs.tssrc/main/native-chat/transcript-tail-boundary.tssrc/main/native-chat/transcript-tail-reader.tssrc/main/native-chat/transcript-watch-contract.tssrc/main/native-chat/transcript-watch-engine.tssrc/main/native-chat/transcript-watch-read.tssrc/main/native-chat/transcript-watch-resolve-poll.test.tssrc/main/native-chat/transcript-watch-unresolved-notice.test.tssrc/main/native-chat/transcript-watch-wsl-exact-path.test.tssrc/main/native-chat/transcript-watch.tssrc/main/providers/ssh-filesystem-dispatch.test.tssrc/main/providers/ssh-filesystem-dispatch.tssrc/main/runtime/rpc/methods/native-chat-rpc-schema.tssrc/main/runtime/rpc/methods/native-chat.test.tssrc/main/runtime/rpc/methods/native-chat.tssrc/preload/api/native-chat-api.tssrc/preload/index.tssrc/renderer/src/components/native-chat/NativeChatSessionGate.tsxsrc/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/native-chat-live-session-types.tssrc/renderer/src/components/native-chat/native-chat-live-source-key.tssrc/renderer/src/components/native-chat/native-chat-pane-resolution.test.tssrc/renderer/src/components/native-chat/native-chat-pane-resolution.tssrc/renderer/src/components/native-chat/native-chat-runtime-contract.tssrc/renderer/src/components/native-chat/native-chat-session-transport.test.tssrc/renderer/src/components/native-chat/native-chat-session-transport.tssrc/renderer/src/components/native-chat/native-chat-subscription-identity.tssrc/renderer/src/components/native-chat/native-chat-view-types.tssrc/renderer/src/components/native-chat/use-native-chat-live-session.test.tssrc/renderer/src/components/native-chat/use-native-chat-live-session.tssrc/renderer/src/components/native-chat/use-native-chat-provider-session-locator.tssrc/renderer/src/components/native-chat/use-native-chat-retained-session.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-session-launch.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/shared/agent-session-resume.test.tssrc/shared/agent-session-resume.tssrc/shared/workspace-session-sleeping-agents.tstests/e2e/headless-native-chat-runtime-routing.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/native-chat/transcript-watch-resolve-poll.test.ts
- src/main/native-chat/transcript-watch-unresolved-notice.test.ts
- src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6b57253a-d82f-4493-9b88-71734fe67003
📒 Files selected for processing (14)
config/reliability-gates.jsoncsrc/main/agent-hooks/server-ingest-remote.test.tssrc/main/agent-hooks/server-last-status-hydrate-validation.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-live.integration.test.tssrc/main/native-chat/ssh-transcript-host-routing.test.tssrc/main/native-chat/ssh-transcript-read.tssrc/main/native-chat/transcript-watch-engine.tssrc/main/native-chat/transcript-watch-error.test.tssrc/main/providers/ssh-filesystem-dispatch.test.tssrc/preload/index.tssrc/renderer/src/components/native-chat/NativeChatSessionGate.tsxsrc/renderer/src/components/native-chat/use-native-chat-live-session.tstests/e2e/headless-native-chat-runtime-routing.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/preload/index.ts
- src/renderer/src/components/native-chat/use-native-chat-live-session.ts
- src/renderer/src/components/native-chat/NativeChatSessionGate.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
a9d77ca to
6e2129d
Compare
…stead of spinning An agent running in an SSH worktree writes its transcript on the remote machine, so the desktop resolves nothing and subscribeNativeChatTranscript re-polls forever with no frame. The client's loading state only clears on a stream frame, so the chat view spins indefinitely with no error (#13663). Emit one advisory snapshot once an unresolved transcript passes a deadline. It is deliberately non-terminal: the resolve poll keeps running and a later real snapshot replaces it, so a session that is merely slow to flush its first JSONL line still loads (#8401). The deadline is generous for the same reason -- a late message costs less than a false one on a healthy session. This lands in the shared subscribe path, so desktop, mobile, web and headless all get it without a wire change; clients already render an error carried on the snapshot frame.
…non-destructive Review follow-ups on the #13663 notice: - Split the advisory latch from the WSL gate latch. They shared one boolean, so a distro that stalled after the deadline had its actionable retry message silenced by the generic notice. - Never trade already-read history for an error card: an error frame carries no transcript, so the desktop keeps a non-empty ready list (mobile already retains its transcript for the same reason). - Let the stream's error outrank the seed's notFound miss. Both deadlines expire at ~60s on the same transcript, so one failure was showing two messages depending on which resolved last. - Schedule the next poll before notifying, and contain a throwing subscriber, so an emit on a dying connection can't kill the loop as an unhandled rejection. - Say only what the deadline establishes: a remote host, a cold WSL distro and a slow first flush all land on it. Drops a comment that claimed the deadline exceeded the documented worst-case first flush when #8401 says minutes. - Tests: assert the recovered transcript's content (the old assertion could pass on an empty frame), pin the once-only latch across ~10 further ticks, and publish test transcripts by rename so a zero-byte file can't race the poll.
…bscriber can't kill the poll The unresolved-transcript notice was already contained, but its sibling emit in runAttempt's catch was not: a throw there escaped `void runAttempt()` as an unhandled rejection and skipped the reschedule below it, stranding the poll for good. Route both through one emitAdvisory helper.
4ded91c to
fa6bf3d
Compare
|
Superseded by #15672, which now carries the server-authoritative routing fix plus restart-durable transcript-owner evidence and mixed-version capability gating. |

ELI5
Orca knew an agent terminal lived on an SSH machine, but native chat could still open the transcript path on the desktop. If the desktop happened to have a file at the same path, Orca could show the wrong conversation.
This PR makes the runtime ask its authenticated agent-hook records which host and path own the transcript. Local and WSL transcripts stay local; SSH transcripts are read through that exact SSH connection. If Orca cannot prove the owner, it reports the transcript as
unverifiableinstead of guessing.What Changed
paneKeyalready known by desktop, web, and mobile clients.paneKey + agent + sessionIdagainst the authenticatedAgentHookServerrow and uses that row'sconnectionId + transcriptPathas authority. Caller-supplied paths are not trusted for a matched pane.wsl:*owners retain the existing local/UNC path handling. SSH owners route through the registered SSH filesystem provider.Why This Boundary
The authenticated hook server already owns both facts needed for routing: the pane/session association and the execution connection. Resolving there is smaller and safer than copying caller-asserted host metadata through generic provider-session, resume, persistence, renderer, preload, mobile, and RPC models.
The resulting authority chain is:
paneKey + sessionId→ authenticated hook row →connectionId + transcriptPath→ local/WSL/SSH readerReproduction
On
main, an isolated Orca app connected to a throwaway Linux Docker SSH/relay target. The SSH host and desktop were given the same session id and exact transcript path but different bytes. Native chat rendered the desktop poison transcript for both an SSH Git worktree and an SSH folder workspace.With this PR, the initial snapshot and a later remote-only append come from the SSH file, while the desktop lookalike remains present and is never rendered.
Linked Issue
Fixes #13663
Visual Proof
SSH Git worktree
Before —
mainselected the desktop lookalike:After — the real remote snapshot rendered and a remote-only append appeared live:
SSH folder workspace
Before —
mainselected the desktop lookalike:After — the real remote snapshot rendered and a remote-only append appeared live:
Testing
tests/e2e/headless-native-chat-runtime-routing.spec.ts: 1 passed.git diff --check: passed.Review and Tradeoffs
The branch is intentionally end-to-end because ownership must remain intact across desktop, paired web/mobile, runtime RPC, authenticated hook state, initial reads, live subscriptions, reconnects, and both worktree and folder workspaces. About half of the net diff is tests and reliability-gate registration.
The main downside is additional SSH-specific range-read and recovery code. It adds remote stat/range traffic and retry state, though reads are bounded and live appends advance a cursor rather than rereading the prefix. A stable-prefix append can complete the snapshot, while a rewrite racing it invalidates and retries; very large unread live backlogs switch to a bounded tail replacement instead of retaining the whole backlog in main-process memory.
A new client paired to an old runtime cannot make that old runtime execute this new authority lookup: the old schema strips
paneKeyand keeps its prior local behavior. This is a valid mixed-version P2 residual, not a regression introduced by this PR. Globally disabling native chat on old runtimes would also regress valid local sessions, so capability negotiation is left as a follow-up.No physical Windows SSH journey was run. Windows packaging, WSL boundary tests, macOS/Linux SSH validation, and cross-version CI cover the implementation contract.
AI Disclosure
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.