Skip to content

fix(native-chat): show an SSH session's chat history on the phone and desktop - #26334

Merged
Jinwoo-H merged 5 commits into
mainfrom
issue-26057-ssh-chat-history
Oct 7, 2026
Merged

Jinwoo-H merged 5 commits into
mainfrom
issue-26057-ssh-chat-history

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​580 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​559
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​192 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158

Fixes #26057.

Problem

A phone paired with a desktop, opening an agent chat in an SSH workspace, shows the empty "Start a chat with Claude" state and none of the conversation. The desktop's own Chat view has the same bug for SSH panes.

The agent runs on the SSH host and writes its transcript there. The hook reports that host's absolute transcriptPath, but nativeChat.readSession / nativeChat.subscribe, and the desktop Chat IPC, read that path on the desktop's own disk. The file never exists locally, so the host answers with an empty, pending snapshot.

Fix

The execution host owns the transcript, so the desktop now reads it on the SSH host through the SSH filesystem provider it already holds:

  • SSH-qualified path. When the hook store attests the session to an SSH connection, the desktop qualifies the transcript path with that connection. A qualified path sent by a client is dropped.
  • One I/O layer. Native chat already sends every file stat and read through one path-routed layer (the one that handles WSL paths). SSH-qualified paths are routed there to the SSH provider's fs.stat / fs.readFileRange.
  • Everything else is reused. The tail and incremental readers, paging, replace detection and the 1 s reconciliation poll, which picks up new turns, are all unchanged.
  • Never read locally. An SSH path is never looked up on this machine. A dropped connection reads as unavailable, never as a local file. A reconnect is picked up automatically.
  • Not written yet. A transcript the SSH host hasn't written yet reads as not found, so the chat keeps waiting instead of showing an error. The relay's not-found error is normalised at the SSH reader.

This is desktop-only, with no wire change. Phones send the same requests, so this reaches users through a desktop update. Every relay a current desktop deploys already serves fs.stat and fs.readFileRange.

Verification

  • Live e2e (tests/e2e/ssh-native-chat-phone-history.spec.ts): a real sshd container with a real deployed relay, a real Claude hook posted from the remote terminal, and a paired mobile client over RPC.
    • Before the fix: the phone gets {"messages":[],"pending":true}.
    • After the fix: it gets the seeded history, and a turn appended on the SSH host arrives as a live appended frame.
  • Unit tests use the real readers with a fake SSH provider that throws the relay's real error shape. They cover reading the history, streaming later turns, never answering from this machine while disconnected, and keeping a not-yet-written transcript pending. Each was shown failing before the fix.
  • Related suites pass: native-chat, desktop native-chat IPC, all RPC methods, and orchestration.

Not in this PR

  • A session whose hook row is gone (the agent exited and the row expired) still falls back to the old local read, which shows the pending state as before. Carrying the connection on retained rows is a follow-up.
  • Paging older history over a slow link wasn't measured: it reads in 64 KiB chunks, one round trip each.

…26057)

A Claude or Codex session in an SSH workspace writes its transcript on the
SSH host, and its hook reports that host's path. Native chat on the desktop
and on a paired phone read that path on the desktop's own disk, found
nothing, and showed "Start a chat with Claude" with the history missing.

The host now looks the session up in the hook store; when a row attests it
to an SSH connection, the transcript path names that connection, and the
native chat reader stats and range-reads it through the SSH filesystem
provider. Live turns follow through the existing reconciliation poll, a
dropped connection reads as unavailable rather than falling back to a local
file, and local and WSL sessions are unchanged. Desktop-only: the phone
sends the same requests as before.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…iting (#26057 review)

The relay replaces Node's 'ENOENT' code with its transport code, so a fresh
SSH session read as a failed read and the desktop Chat view showed an error
instead of waiting. The SSH reader now restores the not-found code.

Also from review: the phone's native chat RPC reads hook rows through the
runtime's injected snapshot instead of importing the hook server; the
transcript open/read helpers are named for what they do now that they route
SSH too; the unused read-cache edit is reverted; the e2e keeps only the SSH
case and narrows without a non-null assertion.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dba44efb-5349-4c8e-a7e5-9274c447d3bc
📥 Commits

Reviewing files that changed from the base of the PR and between 3089f38 and 53f9186.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Native-chat reads and subscriptions now resolve transcript paths from agent-provider session rows. SSH transcript paths encode the connection and remote path, and shared transcript filesystem operations route them to SSH stat and read operations. Transcript readers use the shared filesystem API. Tests cover path selection, SSH history reads and subscriptions, missing or disconnected remote transcripts, and phone history over SSH.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 3089f

SSH history may fall back to a local path while its remote path is pending, and older hosts may show an unclear read error. Resolve these bounded cases before merging, or accept them explicitly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.62% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#26057] requires mobile clients to display conversation history from an SSH server. The PR qualifies attested SSH transcript paths, routes stat and range reads through the SSH filesystem provid…
Out of Scope Changes check ✅ Passed The changes remain within the SSH transcript-history fix for [#26057]. The shared transcript access layer, runtime session-row accessor, reader updates, compatibility test updates, RPC tests, and end-…
Title check ✅ Passed The title clearly and concisely describes the main change: restoring SSH session chat history on phone and desktop clients.
Description check ✅ Passed The description is detailed and relevant. It explains the problem, fix, rationale, linked issue, verification, scope, and known limitations. It does not reproduce every template heading or include exp…
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38967858-4a5d-446d-b92e-b98001b7d426
📥 Commits

Reviewing files that changed from the base of the PR and between 31a5b42 and 53705ae.

📒 Files selected for processing (21)
  • src/main/ipc/native-chat.ts
  • src/main/native-chat/session-file-resolver.ts
  • src/main/native-chat/ssh-transcript-fs-access.ts
  • src/main/native-chat/ssh-transcript-path.test.ts
  • src/main/native-chat/ssh-transcript-path.ts
  • src/main/native-chat/transcript-file-version.ts
  • src/main/native-chat/transcript-incremental-reader.ts
  • src/main/native-chat/transcript-tail-boundary.ts
  • src/main/native-chat/transcript-tail-reader.ts
  • src/main/native-chat/transcript-watcher-install-probe.ts
  • src/main/native-chat/wsl-transcript-fs-access.test.ts
  • src/main/native-chat/wsl-transcript-fs-access.ts
  • src/main/native-chat/wsl-transcript-watcher-running-guard.ts
  • src/main/runtime/orca-runtime-preserved-branch-cleanup.ts
  • src/main/runtime/rpc/methods/native-chat-opencode-semantic-pages.test.ts
  • src/main/runtime/rpc/methods/native-chat-opencode-wire-page-budget.test.ts
  • src/main/runtime/rpc/methods/native-chat-ssh-transcript.test.ts
  • src/main/runtime/rpc/methods/native-chat-subscription-token.test.ts
  • src/main/runtime/rpc/methods/native-chat.test.ts
  • src/main/runtime/rpc/methods/native-chat.ts
  • tests/e2e/ssh-native-chat-phone-history.spec.ts

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

Comment on lines +29 to +45
export async function readSshTranscript(
handle: SshTranscriptHandle,
buffer: Buffer,
offset: number,
length: number,
position: number
): Promise<{ bytesRead: number; buffer: Buffer }> {
const { connectionId, remotePath } = handle.sshTranscript
const bytes = await readRemoteTranscriptRange(
requireSshFilesystemProvider(connectionId),
remotePath,
position,
length
).catch(rethrowWithNotFoundCode)
buffer.set(bytes, offset)
return { bytesRead: bytes.length, buffer }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle an SSH provider that does not implement readFileRange.

readFileRange is optional in IFilesystemProvider. readRemoteTranscriptRange calls provider.readFileRange! without a check. An older relay host does not provide range reads. In that case the call throws a TypeError ("readFileRange is not a function"). The reader then shows that raw text as the chat error. Check provider.readFileRange first, or call supportsFileRangeRead(). If neither is available, throw a clear "transcript unavailable" error.

Comment on lines +34 to +53
export function nativeChatTranscriptPathOnExecutionHost(
statusRows: readonly AgentStatusIpcPayload[],
sessionId: string,
transcriptPath: string | undefined
): string | undefined {
// Only the host mints this form; a client-supplied one would name a file the hook never attested.
const requested =
transcriptPath && !parseSshTranscriptPath(transcriptPath) ? transcriptPath : undefined
const sshRow = statusRows.find(
(row) =>
row.providerSession?.id === sessionId &&
row.providerSession.transcriptPath &&
(requested === undefined || row.providerSession.transcriptPath === requested) &&
row.connectionId &&
!isWslHookRelayConnectionId(row.connectionId)
)
return sshRow?.connectionId && sshRow.providerSession?.transcriptPath
? toSshTranscriptPath(sshRow.connectionId, sshRow.providerSession.transcriptPath)
: requested
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- changed file ---'
nl -ba src/main/native-chat/ssh-transcript-path.ts
printf '%s\n' '--- references and status-row declarations ---'
rg -n -F -- 'nativeChatTranscriptPathOnExecutionHost' src || true
rg -n -F -- 'AgentStatusIpcPayload' src || true
rg -n -F -- 'receivedAt' src || true
printf '%s\n' '--- specified PR diff ---'
git diff --stat 7b054e649463b47b90852fde6c6baf82ef59a244 53705aeeaaae7313ae4a4c1f1b97db1d5c42fbfc -- src/main/native-chat/ssh-transcript-path.ts
git diff --unified=80 7b054e649463b47b90852fde6c6baf82ef59a244 53705aeeaaae7313ae4a4c1f1b97db1d5c42fbfc -- src/main/native-chat/ssh-transcript-path.ts
printf '%s\n' '--- status-row context ---'
rg -n -C 8 -F -- 'interface AgentStatusIpcPayload' src || true
rg -n -C 8 -F -- 'type AgentStatusIpcPayload' src || true

Repository: stablyai/orca

Length of output: 41825


🏁 Script executed:

set -eu
printf '%s\n' '--- AgentStatusIpcPayload and parsed payload ---'
nl -ba src/shared/agent-status-ipc-payload.ts | sed -n '1,90p'
rg -n -F -- 'export type ParsedAgentStatusPayload' src/shared
rg -n -F -- 'export interface ParsedAgentStatusPayload' src/shared
printf '%s\n' '--- native-chat IPC callers ---'
nl -ba src/main/ipc/native-chat.ts | sed -n '1,75p'
nl -ba src/main/ipc/native-chat.ts | sed -n '180,220p'
printf '%s\n' '--- native-chat runtime RPC callers ---'
nl -ba src/main/runtime/rpc/methods/native-chat.ts | sed -n '65,105p'
nl -ba src/main/runtime/rpc/methods/native-chat.ts | sed -n '140,170p'
printf '%s\n' '--- snapshot construction ---'
nl -ba src/main/agent-hooks/server/server-listeners.ts | sed -n '160,240p'
rg -n -C 12 -F -- 'combinedStatusEntries' src/main/agent-hooks src/shared
printf '%s\n' '--- native-chat tests ---'
nl -ba src/main/native-chat/ssh-transcript-path.test.ts

Repository: stablyai/orca

Length of output: 5209


🏁 Script executed:

set -u
printf '%s\n' '--- native-chat IPC callers ---'
nl -ba src/main/ipc/native-chat.ts | sed -n '1,75p'
nl -ba src/main/ipc/native-chat.ts | sed -n '180,220p'
printf '%s\n' '--- native-chat runtime RPC callers ---'
nl -ba src/main/runtime/rpc/methods/native-chat.ts | sed -n '65,105p'
nl -ba src/main/runtime/rpc/methods/native-chat.ts | sed -n '140,170p'
printf '%s\n' '--- snapshot construction ---'
nl -ba src/main/agent-hooks/server/server-listeners.ts | sed -n '160,240p'
rg -n -C 20 -F -- 'combinedStatusEntries' src/main/agent-hooks src/shared || true
printf '%s\n' '--- status-row selection and freshness usage ---'
rg -n -C 12 -E 'evidenceObservedAt|receivedAt|selectFresh|providerSession.*id' src/main/agent-hooks src/main/runtime src/shared/agent-status* || true
printf '%s\n' '--- native-chat tests ---'
nl -ba src/main/native-chat/ssh-transcript-path.test.ts

Repository: stablyai/orca

Length of output: 29405


Select the freshest matching SSH row when no transcript path is requested.

transcriptPath is optional, and the current find call selects the first matching row. The snapshot is ordered by pane listing order, not freshness. If multiple rows match a provider session, this can select a stale connection.

Select the row with the greatest evidenceObservedAt, falling back to receivedAt for older hosts. Do not use receivedAt alone because reconnects can restamp replayed rows.

…ot-found handling (#26057 review)

- An SSH-attested session is read on its host even when a client sends a
  stale path; an exact path match only picks between SSH rows. The lookup
  takes just the two row fields it reads.
- The readers classify not-found with isENOENT, which already recognises a
  relay error by its message, so the SSH reader no longer rebuilds errors.
- The SSH reader no longer imports back from the WSL access module.
- Run the new Docker SSH spec in the SSH Docker CI lane (gate contract).

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a951dca7-2643-4bf4-a507-1cfd9f9242a6
📥 Commits

Reviewing files that changed from the base of the PR and between 53705ae and 3089f38.

📒 Files selected for processing (6)
  • config/scripts/run-ssh-docker-e2e.mjs
  • src/main/native-chat/ssh-transcript-fs-access.ts
  • src/main/native-chat/ssh-transcript-path.test.ts
  • src/main/native-chat/ssh-transcript-path.ts
  • src/main/native-chat/transcript-reader.ts
  • src/main/native-chat/transcript-tail-reader.ts

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 requested =
transcriptPath && !parseSshTranscriptPath(transcriptPath) ? transcriptPath : undefined
const rows = statusRows.filter(
(row) => row.providerSession?.id === sessionId && row.providerSession.transcriptPath

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,110p' src/main/native-chat/ssh-transcript-path.ts
sed -n '30,85p' src/main/ipc/native-chat.ts
rg -n 'nativeChatTranscriptPathOnExecutionHost|providerSession.*transcriptPath' src/main/runtime/rpc/methods/native-chat.ts src/main/agent-hooks/server/server-listeners.ts

Repository: stablyai/orca

Length of output: 4998


🏁 Script executed:

set -e
printf '%s\n' '--- row construction and status types ---'
sed -n '220,275p' src/main/agent-hooks/server/server-listeners.ts
sed -n '100,170p' src/shared/agent-status-types.ts
sed -n '55,90p' src/main/agent-hooks/server/server-types.ts
printf '%s\n' '--- native chat read call sites and implementation ---'
sed -n '60,175p' src/main/runtime/rpc/methods/native-chat.ts
rg -n -F -- 'readNativeChatTranscriptTail' src/main src/shared

Repository: stablyai/orca

Length of output: 17369


🏁 Script executed:

set -e
printf '%s\n' '--- provider-session row source ---'
rg -n -F -- 'getAgentProviderSessionRows' src/main
printf '%s\n' '--- transcript tail reader ---'
sed -n '210,310p' src/main/native-chat/transcript-tail-reader.ts
sed -n '1,90p' src/main/native-chat/native-chat-file-provenance.ts
printf '%s\n' '--- SSH path consumers ---'
rg -n -F -- 'parseSshTranscriptPath' src/main
rg -n -F -- 'orca-ssh-transcript:' src/main

Repository: stablyai/orca

Length of output: 10121


🏁 Script executed:

set -e
printf '%s\n' '--- provider-session accessor ---'
sed -n '95,116p' src/main/runtime/orca-runtime-preserved-branch-cleanup.ts
printf '%s\n' '--- session-file resolver path precedence ---'
sed -n '90,135p' src/main/native-chat/session-file-resolver.ts
printf '%s\n' '--- SSH filesystem path handling ---'
sed -n '70,100p' src/main/native-chat/wsl-transcript-fs-access.ts
sed -n '112,132p' src/main/native-chat/wsl-transcript-fs-access.ts

Repository: stablyai/orca

Length of output: 4819


Do not fall back to requested when only an unresolved SSH row matches.

A matching SSH row can have no providerSession.transcriptPath. If no locally attested row matches requested, return undefined instead of allowing the caller-supplied local path to reach the transcript reader.

Preserve local precedence. If a separate matching row attests requested, return requested even when a pathless SSH row also exists.

🐛 Suggested fix
--- "a/src/main/native-chat/ssh-transcript-path.ts"
+++ "b/src/main/native-chat/ssh-transcript-path.ts"
@@ -37,17 +37,25 @@
   // Only the host mints this form; a client-supplied one would name a file the hook never attested.
   const requested =
     transcriptPath && !parseSshTranscriptPath(transcriptPath) ? transcriptPath : undefined
-  const rows = statusRows.filter(
+  const sessionRows = statusRows.filter((row) => row.providerSession?.id === sessionId)
+  const rows = sessionRows.filter(
-    (row) => row.providerSession?.id === sessionId && row.providerSession.transcriptPath
+    (row) => row.providerSession?.transcriptPath
   )
   // Why: the row attesting the requested path decides the host; a stale path falls back to SSH.
   const row =
     rows.find((candidate) => candidate.providerSession?.transcriptPath === requested) ??
     rows.find(isSshRow)
   const remotePath = row?.providerSession?.transcriptPath
+  const hasUnresolvedSshRow = sessionRows.some(
+    (candidate) => isSshRow(candidate) && !candidate.providerSession?.transcriptPath
+  )
   return row && isSshRow(row) && remotePath
     ? toSshTranscriptPath(row.connectionId, remotePath)
-    : requested
+    : row
+      ? requested
+      : hasUnresolvedSshRow
+        ? undefined
+        : requested
 }
 
 function isSshRow(row: HookRow): row is HookRow & { connectionId: string } {

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.

[Bug] The mobile client can't show the conversation history from the server.

1 participant