Repository navigation
fix(native-chat): show an SSH session's chat history on the phone and desktop - #26334
Conversation
…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
|
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:
📝 WalkthroughWalkthroughNative-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 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
38967858-4a5d-446d-b92e-b98001b7d426
📒 Files selected for processing (21)
src/main/ipc/native-chat.tssrc/main/native-chat/session-file-resolver.tssrc/main/native-chat/ssh-transcript-fs-access.tssrc/main/native-chat/ssh-transcript-path.test.tssrc/main/native-chat/ssh-transcript-path.tssrc/main/native-chat/transcript-file-version.tssrc/main/native-chat/transcript-incremental-reader.tssrc/main/native-chat/transcript-tail-boundary.tssrc/main/native-chat/transcript-tail-reader.tssrc/main/native-chat/transcript-watcher-install-probe.tssrc/main/native-chat/wsl-transcript-fs-access.test.tssrc/main/native-chat/wsl-transcript-fs-access.tssrc/main/native-chat/wsl-transcript-watcher-running-guard.tssrc/main/runtime/orca-runtime-preserved-branch-cleanup.tssrc/main/runtime/rpc/methods/native-chat-opencode-semantic-pages.test.tssrc/main/runtime/rpc/methods/native-chat-opencode-wire-page-budget.test.tssrc/main/runtime/rpc/methods/native-chat-ssh-transcript.test.tssrc/main/runtime/rpc/methods/native-chat-subscription-token.test.tssrc/main/runtime/rpc/methods/native-chat.test.tssrc/main/runtime/rpc/methods/native-chat.tstests/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.
| 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 } | ||
| } |
There was a problem hiding this comment.
🩺 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.
| 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 | ||
| } |
There was a problem hiding this comment.
🎯 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 || trueRepository: 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.tsRepository: 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.tsRepository: 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
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a951dca7-2643-4bf4-a507-1cfd9f9242a6
📒 Files selected for processing (6)
config/scripts/run-ssh-docker-e2e.mjssrc/main/native-chat/ssh-transcript-fs-access.tssrc/main/native-chat/ssh-transcript-path.test.tssrc/main/native-chat/ssh-transcript-path.tssrc/main/native-chat/transcript-reader.tssrc/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 |
There was a problem hiding this comment.
🗄️ 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.tsRepository: 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/sharedRepository: 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/mainRepository: 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.tsRepository: 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 } {
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, butnativeChat.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:
fs.stat/fs.readFileRange.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.statandfs.readFileRange.Verification
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.{"messages":[],"pending":true}.appendedframe.Not in this PR