Repository navigation
fix(native-chat): read SSH worktree transcripts on the execution host - #15672
brennanb2025 wants to merge 14 commits into
Conversation
📝 WalkthroughWalkthroughThe change adds pane-aware native chat transcript routing across preload, RPC, renderer, mobile, and runtime layers. It records and resolves local and SSH transcript ownership, persists owner evidence, and prevents unsafe fallback. SSH transcripts use bounded ranged reads with provider-generation and stability checks. Remote subscriptions retry provider changes and use reconciliation watchers. Runtime capability checks and structured relay errno handling are added with supporting tests and reliability documentation. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b3114719-be0b-49b7-b73a-078fa0f740ae
📒 Files selected for processing (22)
src/main/ipc/native-chat.tssrc/main/native-chat/ssh-transcript-owner.test.tssrc/main/native-chat/ssh-transcript-owner.tssrc/main/native-chat/ssh-transcript-range-fs.test.tssrc/main/native-chat/ssh-transcript-range-fs.tssrc/main/native-chat/ssh-transcript-read.tssrc/main/native-chat/ssh-transcript-routing.test.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-probe.tssrc/main/native-chat/transcript-watch.tssrc/main/runtime/rpc/methods/native-chat.tssrc/preload/api/native-chat-api.tssrc/renderer/src/components/native-chat/native-chat-runtime-contract.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| } catch (error) { | ||
| // Why: "not flushed yet" degrades to resolve-polling, but a stalled distro | ||
| // or unreachable SSH host must reach the caller so it can surface a | ||
| // retryable message instead of stranding the client at `loading`. | ||
| if (error instanceof WslTranscriptFsError || error instanceof TranscriptHostUnverifiableError) { | ||
| throw error | ||
| } | ||
| return false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve remote probe failures for SSH classification.
When rangeFs.stat() rejects with a raw provider error, this catch returns false. installTranscriptWatcher() then returns null, so subscribeSshNativeChatTranscript() retries without calling classifySshTranscriptReadError(). A disconnected host or unsupported ranged read can remain in retry state instead of emitting unverifiable.
When rangeFs is set, rethrow the error and let the SSH subscription classify it. Keep the local missing-file fallback unchanged. Also normalize later SSH range-read failures to TranscriptHostUnverifiableError, because the active drain only preserves that typed verdict.
Proposed fix
} catch (error) {
+ if (rangeFs) {
+ throw error
+ }
// Why: "not flushed yet" degrades to resolve-polling, but a stalled distro
Live SSH validation — DEFECT FOUNDExercised on the Linux SSH target What ran
Connected (host reachable)
{ "error": "Transcript unverifiable on the remote host", "unverifiable": true }Relay logs showed After disconnectHook snapshot row was gone. VerdictDEFECT FOUND. Native-chat IPC does not deliver the remote transcript while the host is connected ( |
…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.
7381e90 to
5453890
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. |
|
Revised this implementation around durable, server-authoritative transcript ownership. What changed:
What stayed:
Verification:
Non-vacuity: temporarily changing the SSH owner verdict to |
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (1)
src/renderer/src/web/web-preload-api.ts (1)
1302-1313: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winCache the capability probe instead of sending
status.geton every native-chat request.
assertOwnerCapabilityissues a freshstatus.getfor eachreadSessionand eachsubscribe.readSessionalso runs for every "load earlier" page, so each history page costs two round-trips over the web transport. The renderer runtime path avoids this:runtimeEnvironmentSupportsCapabilitycaches the status result with a TTL and only reprobes when the cached value is stale or unsupported.Cache the verdict per environment with a TTL, and invalidate it when the pairing changes or when the capability is absent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 693a6d69-e2de-46fb-82b9-f798b131b0e3
📒 Files selected for processing (81)
config/reliability-gates.jsoncdocs/reference/remote-wire-compatibility.mdmobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/session/mobile-native-chat-eligibility.test.tsmobile/src/session/mobile-native-chat-eligibility.tsmobile/src/session/use-mobile-native-chat-controller.test.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.tsmobile/src/transport/host-status-gates.test.tsmobile/src/transport/host-status-gates.tsmobile/src/transport/stable-logical-rpc-client.test.tsmobile/src/transport/stable-logical-rpc-client.tssrc/main/agent-hooks/server-last-status-write.test.tssrc/main/agent-hooks/server-transcript-owner-persistence.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/wsl-hook-relay-live.integration.test.tssrc/main/ipc/filesystem-path-containment.tssrc/main/ipc/native-chat.test.tssrc/main/ipc/native-chat.tssrc/main/native-chat/host-readable-transcript-path.test.tssrc/main/native-chat/host-readable-transcript-path.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-owner-evidence-routing.test.tssrc/main/native-chat/ssh-transcript-range-fs.test.tssrc/main/native-chat/ssh-transcript-range-fs.tssrc/main/native-chat/ssh-transcript-range-pagination.test.tssrc/main/native-chat/ssh-transcript-read.tssrc/main/native-chat/ssh-transcript-relay-errno.test.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-error.test.tssrc/main/native-chat/transcript-watch-read.tssrc/main/native-chat/transcript-watch-resolve-poll.test.tssrc/main/native-chat/transcript-watch-wsl-stall.test.tssrc/main/native-chat/transcript-watch.tssrc/main/providers/filesystem-provider-contract.tssrc/main/providers/ssh-filesystem-dispatch.test.tssrc/main/providers/ssh-filesystem-dispatch.tssrc/main/providers/ssh-filesystem-provider-range.test.tssrc/main/providers/ssh-filesystem-provider.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/relay/dispatcher-structured-error.test.tssrc/relay/dispatcher.tssrc/relay/integration.test.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-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-retained-session.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-session-launch.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/web/web-preload-api-agent-providers.test.tssrc/renderer/src/web/web-preload-api.tssrc/shared/definitive-filesystem-absence.tssrc/shared/protocol-version.tstests/e2e/headless-native-chat-runtime-routing.spec.ts
💤 Files with no reviewable changes (2)
- src/main/native-chat/transcript-watch-resolve-poll.test.ts
- src/main/agent-hooks/wsl-hook-relay-live.integration.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/main/native-chat/transcript-file-version.ts
- src/main/native-chat/transcript-native-watcher.ts
- src/main/native-chat/transcript-incremental-reader.ts
- src/main/native-chat/ssh-transcript-subscription.ts
- src/main/native-chat/transcript-tail-boundary.ts
- src/main/native-chat/transcript-watch-contract.ts
- src/main/native-chat/transcript-tail-reader.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| client: transcriptTransportAuthorized ? client : null, | ||
| sourceIdentity: encodeNativeChatTranscriptIdentity([hostId, worktreeId]), | ||
| agent: activeChatResolution?.agent ?? null, | ||
| sessionId: activeChatSessionId, | ||
| transcriptPath: activeChatResolution?.transcriptPath ?? null | ||
| transcriptPath: activeChatResolution?.transcriptPath ?? null, | ||
| paneKey: activeChatResolution?.paneKey ?? null |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Gate native-chat writes with transcript authorization.
When SSH ownership is pending, unavailable, or unknown, this hook passes null to useMobileNativeChatSession. However, the answer, permission, stop, and message-send hooks still receive the original client, and inputSendable does not include transcriptTransportAuthorized. Users can therefore send native-chat actions while the transcript subscription is disabled, creating unseen turns and inconsistent chat state.
Gate the common write enablement with transcriptTransportAuthorized, or pass the gated client to every native-chat I/O hook.
Proposed fix
- const inputSendable = nativeChatInputLeaseReady && connState === 'connected'
+ const inputSendable =
+ transcriptTransportAuthorized &&
+ nativeChatInputLeaseReady &&
+ connState === 'connected'| paneKey: string | null | ||
| }): MobileNativeChatSession { | ||
| const { client, sourceIdentity, agent, sessionId, transcriptPath } = args | ||
| const { client, sourceIdentity, agent, sessionId, transcriptPath, paneKey } = args |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- hook signature and nearby code ---'
sed -n '35,75p' mobile/src/session/use-mobile-native-chat-session.ts
printf '%s\n' '--- cited test range ---'
sed -n '445,495p' mobile/src/session/use-mobile-native-chat-session.test.ts
printf '%s\n' '--- all hook call sites ---'
rg -n -C 4 'useMobileNativeChatSession' mobileRepository: stablyai/orca
Length of output: 18308
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- first test harness call ---'
sed -n '28,52p' mobile/src/session/use-mobile-native-chat-session.test.ts
printf '%s\n' '--- production controller call ---'
sed -n '88,115p' mobile/src/session/use-mobile-native-chat-controller.ts
printf '%s\n' '--- complete second harness declaration and call ---'
sed -n '458,485p' mobile/src/session/use-mobile-native-chat-session.test.ts
printf '%s\n' '--- direct-call property check (read-only) ---'
python3 - <<'PY'
from pathlib import Path
import re
files = [
Path("mobile/src/session/use-mobile-native-chat-session.test.ts"),
Path("mobile/src/session/use-mobile-native-chat-controller.ts"),
]
pattern = re.compile(r"useMobileNativeChatSession\s*\(\s*\{(?P<body>.*?)\}\s*\)", re.S)
for path in files:
text = path.read_text()
for match in pattern.finditer(text):
line = text.count("\n", 0, match.start()) + 1
body = match.group("body")
properties = re.findall(r"(?m)^\s*([A-Za-z_$][\w$]*)\s*:", body)
print(f"{path}:{line}: properties={properties}; paneKey={'present' if 'paneKey' in properties else 'MISSING'}")
PYRepository: stablyai/orca
Length of output: 3370
Add paneKey to the second test harness.
The hook requires paneKey, but the call at mobile/src/session/use-mobile-native-chat-session.test.ts:472 omits it. Add paneKey: null or the fixture pane key to restore type-checking.
| it('does not replay native-chat subscriptions across an unproven generation', async () => { | ||
| const oldSession = new FakeSession('connected') | ||
| const replacement = new FakeSession('connected') | ||
| const client = createStableLogicalRpcClient(oldSession, 'lan') | ||
| client.subscribe('nativeChat.subscribe', { sessionId: 'session-1' }, vi.fn()) | ||
|
|
||
| await client.migrateTo(replacement, 'relay') | ||
|
|
||
| expect(replacement.subscribe).not.toHaveBeenCalledWith( | ||
| 'nativeChat.subscribe', | ||
| expect.anything(), | ||
| expect.any(Function), | ||
| expect.anything() | ||
| ) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does Vitest expect.anything() match undefined arguments in toHaveBeenCalledWith?
💡 Result:
No, Vitest's expect.anything does not match undefined arguments [1][2]. By official definition, expect.anything matches any value except null or undefined [1][2]. Therefore, if you pass undefined as an argument to a function and attempt to match it using expect.anything within toHaveBeenCalledWith, the assertion will fail [3].
Citations:
- 1: https://vitest.dev/api/expect.html
- 2: https://github.com/vitest-dev/vitest/blob/206e8cff/docs/api/expect.md
- 3: Undefined arguments do not work with toHaveBeenCalledWith and asymmetric matchers vitest-dev/vitest#7573
🏁 Script executed:
#!/bin/bash
set -eu
file="mobile/src/transport/stable-logical-rpc-client.test.ts"
printf '%s\n' '--- test file ---'
sed -n '1,190p' "$file"
printf '%s\n' '--- related symbols ---'
rg -n --glob '*.{ts,tsx,js,jsx}' \
'createStableLogicalRpcClient|attachSubscription|migrateTo|nativeChat\.subscribe|class FakeSession' \
mobile/srcRepository: stablyai/orca
Length of output: 16404
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- migration and subscription implementation ---'
sed -n '200,335p' mobile/src/transport/stable-logical-rpc-client.ts
printf '%s\n' '--- RPC subscription type and relevant tests ---'
rg -n -A18 -B8 --glob '*.{ts,tsx}' \
'subscribe\s*[:=]|interface RpcClient|type RpcClient|nativeChat\.subscribe' \
mobile/src/transport mobile/src/session | head -240Repository: stablyai/orca
Length of output: 25998
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- subscription registration and record shape ---'
sed -n '1,175p' mobile/src/transport/stable-logical-rpc-client.ts
printf '%s\n' '--- RpcClient declarations ---'
rg -n -A45 -B8 --glob '*.ts' \
'export interface RpcClient|interface RpcClient|subscribe\s*\(' \
mobile/src/transport | head -220Repository: stablyai/orca
Length of output: 23800
Make the negative assertion non-vacuous.
expect.anything() does not match undefined, so the matcher cannot detect a replay. Assert directly that replacement.subscribe was not called.
| // Why: native-chat ownership is generation-bound; its hook reprobes status before resubscribing. | ||
| for (const record of subscriptions.values()) { | ||
| const disposePrevious = record.disposePhysical | ||
| attachSubscription(record, nextSession, nextGeneration) | ||
| if (record.method === 'nativeChat.subscribe') { | ||
| record.disposePhysical = null | ||
| } else { | ||
| attachSubscription(record, nextSession, nextGeneration) | ||
| } | ||
| disposePrevious?.() | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether any consumer input changes on migration for locally owned native chat.
set -euo pipefail
rg -n -C6 "nativeChat.subscribe" mobile/src | head -80
rg -n -C10 "getGeneration" mobile/src
rg -n -C6 "transcriptTransportAuthorized|proven-local" mobile/srcRepository: stablyai/orca
Length of output: 34384
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- native chat hook ---'
sed -n '1,190p' mobile/src/session/use-mobile-native-chat-session.ts
printf '%s\n' '--- native chat controller ---'
sed -n '1,180p' mobile/src/session/use-mobile-native-chat-controller.ts
printf '%s\n' '--- migration implementation ---'
sed -n '210,275p' mobile/src/transport/stable-logical-rpc-client.ts
printf '%s\n' '--- controller client and capability state references ---'
rg -n -C8 "setClient|client:|nativeChatTranscriptOwnerCapabilityPending|nativeChatTranscriptOwnerCapable|transcriptTransportAuthorized|useMobileNativeChatSession" mobile/src/session mobile/src/transportRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- hook effects and dependency arrays ---'
rg -n -C12 "useEffect|\\[client|\\[.*paneKey|transcriptPath" mobile/src/session/use-mobile-native-chat-session.ts
printf '%s\n' '--- controller implementation ---'
sed -n '1,125p' mobile/src/session/use-mobile-native-chat-controller.ts
printf '%s\n' '--- controller hook invocation ---'
sed -n '90,112p' mobile/src/session/use-mobile-native-chat-controller.ts
printf '%s\n' '--- migration implementation ---'
sed -n '235,267p' mobile/src/transport/stable-logical-rpc-client.tsRepository: stablyai/orca
Length of output: 16792
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
hook = Path("mobile/src/session/use-mobile-native-chat-session.ts").read_text()
controller = Path("mobile/src/session/use-mobile-native-chat-controller.ts").read_text()
migration = Path("mobile/src/transport/stable-logical-rpc-client.ts").read_text()
deps = re.search(
r"\},\s*\[client, agent, sessionId, transcriptPath, paneKey, identity, setList\]\)",
hook,
)
identity_fields = re.search(
r"const identity = encodeNativeChatTranscriptIdentity\(\[\s*"
r"sourceIdentity,\s*agent,\s*sessionId,\s*transcriptPath,\s*paneKey\s*\]\)",
hook,
)
local_auth = re.search(
r"const transcriptTransportAuthorized =\s*"
r"transcriptOwnership === 'proven-local'",
controller,
)
native_cutover = re.search(
r"if \(record\.method === 'nativeChat\.subscribe'\) \{\s*"
r"record\.disposePhysical = null",
migration,
re.S,
)
assert deps, "native chat effect dependency list changed or was not found"
assert identity_fields, "native chat identity fields changed or were not found"
assert local_auth, "proven-local authorization rule changed or was not found"
assert native_cutover, "native-chat cutover behavior changed or was not found"
deps_text = deps.group(0)
assert "generation" not in deps_text, deps_text
assert "sourceIdentity" in identity_fields.group(0)
assert "generation" not in identity_fields.group(0)
# React's dependency comparison is identity/value equality for these primitive
# inputs. A migration keeps the stable logical client and chat inputs unchanged.
before = ("logical-client", "claude", "session-1", "/tmp/transcript.json", "pane-1")
after = before
assert before == after
# The proven-local branch does not depend on capability-pending state.
transcript_ownership = "proven-local"
authorized_before = transcript_ownership == "proven-local"
authorized_after = transcript_ownership == "proven-local"
assert authorized_before and authorized_after
print("effect dependencies:", deps_text.split("[", 1)[1].split("]", 1)[0])
print("identity excludes generation: yes")
print("proven-local authorization before/after migration: true/true")
print("native-chat cutover clears physical attachment: yes")
print("effect rerun from migration-only changes: no")
PYRepository: stablyai/orca
Length of output: 433
Reattach locally owned native-chat subscriptions after migration.
migrateTo clears the physical attachment but keeps the logical record. The hook effect does not depend on getGeneration(), so a proven-local session remains unsubscribed until another dependency changes. Reattach the subscription during migration, or resubscribe when the generation changes.
| awaitTranscriptOwnerHydration(): Promise<void> { | ||
| if (this.transcriptOwnerHydrated) { | ||
| return Promise.resolve() | ||
| } | ||
| return new Promise((resolve) => this.transcriptOwnerHydrationWaiters.add(resolve)) | ||
| } | ||
|
|
||
| private markTranscriptOwnerHydrated(): void { | ||
| this.transcriptOwnerHydrated = true | ||
| for (const resolve of this.transcriptOwnerHydrationWaiters) { | ||
| resolve() | ||
| } | ||
| this.transcriptOwnerHydrationWaiters.clear() | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Resolve or reject hydration waiters when the server stops.
stop() sets transcriptOwnerHydrated = false and clears the owner maps, but it leaves transcriptOwnerHydrationWaiters populated and never calls markTranscriptOwnerHydrated(). Two consequences follow:
- Waiters registered before
stop()never settle. Their resolvers stay referenced in the set. - Any
awaitTranscriptOwnerHydration()call afterstop()and before a newstart()returns a promise that never settles.resolveHydratedNativeChatTranscriptOwnerawaits that promise before it checks the abort signal, so a native-chat read or subscription started in that window hangs with no timeout.
Settle the waiters in stop() and keep the set empty.
🔧 Proposed fix
this.transcriptOwnersByPaneKey.clear()
this.unresolvedRemoteTranscriptOwnersByPaneKey.clear()
+ // Why: a stopped server hydrates nothing more; settle waiters so readers fail fast instead of hanging.
+ this.markTranscriptOwnerHydrated()
this.transcriptOwnerHydrated = falseAlso applies to: 2582-2582, 2742-2744
| if ( | ||
| entry?.providerSession && | ||
| entry.payload.agentType && | ||
| entry.payload.agentType !== 'unknown' | ||
| ) { | ||
| this.transcriptOwnersByPaneKey.set( | ||
| resolvedPaneKey, | ||
| Object.freeze({ | ||
| paneKey: resolvedPaneKey, | ||
| agentType: entry.payload.agentType, | ||
| sessionId: entry.providerSession.id, | ||
| ...(entry.providerSession.transcriptPath | ||
| ? { transcriptPath: entry.providerSession.transcriptPath } | ||
| : {}), | ||
| connectionId: entry.connectionId, | ||
| observedAt: entry.receivedAt | ||
| }) | ||
| ) | ||
| } |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Bound the persisted transcript-owner maps.
Status entries are pruned by ttlCutoff, but owner evidence is not. Line 3159 derives owner evidence from every sanitized entry, including entries that are then dropped for age, and lines 3233-3252 rehydrate every persisted owner and marker without an age or size limit. serializeStatusFile writes the whole map back. A pane that ever reported a provider session therefore keeps a record in last-status.json forever, and the file and the in-memory maps grow without a ceiling across restarts.
observedAt is already available on both record types. Apply the same cutoff used for entries, or cap the maps like PANE_KEY_ALIASES_MAX, so growth stays bounded while recent ownership still survives row expiry.
Also applies to: 3233-3252
| await agentHookServer.awaitTranscriptOwnerHydration() | ||
| setupSignal?.throwIfAborted() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Make owner hydration abortable.
At Line 293, an aborted setupSignal cannot stop awaitTranscriptOwnerHydration(). The server registers an unremovable hydration waiter, so IPC and RPC teardown leave each canceled setup pending until hydration completes. If hydration stalls, canceled subscriptions retain handlers and waiters. Update the hydration API to remove its waiter on abort, and pass setupSignal to it.
| // A reconnect gap has no provider session by construction; retain the last complete identity. | ||
| return { | ||
| ...currentResolution, | ||
| sessionId: previousResolution.sessionId, | ||
| transcriptPath: previousResolution.transcriptPath | ||
| transcriptPath: previousResolution.transcriptPath, | ||
| connectionId: previousResolution.connectionId |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Preserve transcript ownership during the reconnect fallback.
When the replacement status has no connectionId, currentResolution has transcriptOwnership: 'unknown'. Lines 33-37 restore the prior session identity but retain that unknown verdict. NativeChatView then disables useNativeChatRetainedSession, so a previously proven transcript stops reading during the reconnect gap.
Retain the previous verdict only when the current verdict is unknown.
Proposed fix
return {
...currentResolution,
sessionId: previousResolution.sessionId,
transcriptPath: previousResolution.transcriptPath,
- connectionId: previousResolution.connectionId
+ connectionId: previousResolution.connectionId,
+ transcriptOwnership:
+ currentResolution.transcriptOwnership === 'unknown'
+ ? previousResolution.transcriptOwnership
+ : currentResolution.transcriptOwnership
}📝 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.
| // A reconnect gap has no provider session by construction; retain the last complete identity. | |
| return { | |
| ...currentResolution, | |
| sessionId: previousResolution.sessionId, | |
| transcriptPath: previousResolution.transcriptPath | |
| transcriptPath: previousResolution.transcriptPath, | |
| connectionId: previousResolution.connectionId | |
| // A reconnect gap has no provider session by construction; retain the last complete identity. | |
| return { | |
| ...currentResolution, | |
| sessionId: previousResolution.sessionId, | |
| transcriptPath: previousResolution.transcriptPath, | |
| connectionId: previousResolution.connectionId, | |
| transcriptOwnership: | |
| currentResolution.transcriptOwnership === 'unknown' | |
| ? previousResolution.transcriptOwnership | |
| : currentResolution.transcriptOwnership |
| args.transcriptPath ?? null, | ||
| args.transcriptConnectionId ?? null |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Hide retained transcript messages when ownership is unknown.
When transcriptOwnership becomes unknown, NativeChatResolvedView passes enabled: false but can keep this identity unchanged. useNativeChatLiveSession preserves same-source state while disabled. This hook can then return cached transcript messages after provenance is no longer verified.
Return an empty loading session when args.enabled === false, or include an ownership gate in retention. Add a regression test for a ready session that becomes disabled without changing its session or connection ID.
| const session = captureSession() | ||
| void assertOwnerCapability(session.call) | ||
| .then(() => { | ||
| session.assertCurrent() | ||
| return session.client.subscribe( |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm getClientForEnvironment throws for manually disconnected environments and that
# no caller of nativeChat.subscribe guards against a synchronous throw.
set -euo pipefail
rg -n -C6 "manuallyDisconnectedEnvironmentIds" src/renderer/src/web/web-preload-api.ts
rg -n -C6 "nativeChat\.subscribe\(|\.subscribe\(\s*\{" src/renderer/src/components/native-chatRepository: stablyai/orca
Length of output: 19579
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- web-preload-api.ts: subscribe implementation ---'
sed -n '1260,1385p' src/renderer/src/web/web-preload-api.ts
printf '%s\n' '--- session helpers and captureSession references ---'
rg -n -C8 "captureSession|assertOwnerCapability|session\.client\.subscribe|error snapshot|unsubscribe" src/renderer/src/web/web-preload-api.ts
printf '%s\n' '--- native chat transport implementation and callers ---'
sed -n '1,150p' src/renderer/src/components/native-chat/native-chat-session-transport.ts
rg -n -C8 "getNativeChatSessionTransport|nativeChatSessionTransport|\.subscribe\(" src/renderer/src/components/native-chat -g '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
path = Path("src/renderer/src/web/web-preload-api.ts")
text = path.read_text()
subscribe = text[text.index("subscribe: (args, onFrame) => {"):text.index(
"\n }\n }\n}", text.index("subscribe: (args, onFrame) => {")
) + 6]
checks = {
"capture_session_precedes_chain": subscribe.index("const session = captureSession()")
< subscribe.index("void assertOwnerCapability(session.call)"),
"capture_session_is_outside_try": "try" not in subscribe[:subscribe.index("const session = captureSession()")],
"catch_emits_initial_error_snapshot": (
".catch((err: unknown) => {" in subscribe
and "if (!cancelled && !receivedInitial)" in subscribe
and "type: 'snapshot'" in subscribe[subscribe.index(".catch((err: unknown) => {"):]
),
"manual_disconnect_guard_throws": (
"if (manuallyDisconnectedEnvironmentIds.has(environment.id))" in text
and "throw new Error('runtime_manually_disconnected')" in text
),
}
for name, result in checks.items():
print(f"{name}={result}")
if not all(checks.values()):
raise SystemExit("control-flow invariant failed")
PYRepository: stablyai/orca
Length of output: 299
Move captureSession() inside the promise chain.
When the environment is manually disconnected, captureSession() throws before .catch() runs. The caller receives no error snapshot or teardown function.
…annot read On a Model-A SSH worktree (desktop owns the runtime, the agent runs on the SSH target) Claude and Codex tabs were admitted into file-backed native chat, but the host resolves the transcript against its own filesystem, never finds it, and settles into an empty pending snapshot. Gate every transcript agent on host readability, as Grok/omp already were; local, WSL (connectionId null) and Model B (`runtime-ssh-`) are unchanged. The source-control launch dialog now derives readability from the worktree's connection instead of `!isRemote`, so Model B keeps its chat default there. Stopgap for stablyai#13663 until stablyai#15672 reads the transcript on the execution host. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Hi! Is there an ETA for when this could land in a release? We hit #13663 every day and it's quite disruptive: Orca desktop on macOS with two SSH targets (one macOS, one Linux), phone paired to the desktop. Every Claude session in an SSH worktree spins forever in Chat UI, while the raw terminal view of the same tab works fine. Still reproduces on 1.4.215: |
… them Mobile native chat for a Claude/Codex session in an SSH worktree showed an empty "start a conversation" view: nativeChat.readSession/subscribe resolved the transcript on the desktop's disk, while the agent writes it on the SSH host. The RPC now imports its transcript functions from ssh-aware-transcript-watch, which picks the owner from the agent-hook rows (session id / transcript path, best match across hosts). SSH-owned sessions are read with ranged reads through the connection's filesystem provider and followed by polling; local and WSL sessions keep the existing reader. A dropped connection surfaces as an error frame and recovers on reconnect instead of rendering an empty conversation. Kept to a one-line change in an upstream file so the fork rebases cleanly; upstream stablyai#15672 is the full fix. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thank you @brennanb2025. Native chat for SSH sessions now reads the transcript on the execution host (#26334, |



ELI5
Native chat for an agent running through SSH was sometimes looking for the transcript on the laptop. The transcript belongs to the host that ran the agent, so Orca now remembers that ownership across disconnects and restarts and refuses to substitute a same-looking local file when the remote host cannot be verified.
What Changed
last-status.jsonledger independently of the seven-day hook-row retention window. The evidence records pane, agent, provider session, transcript path, execution connection, and observation time.unverifiable; it never authorizes local fallback or implies the processexited.native-chat.transcript-owner.v1. Mobile, renderer remote-runtime, and web paths prove both ownership and host capability before issuing native-chat RPCs; unknown/old-host states make zero native-chat calls.Why
The transcript lives where the agent runs. A disconnected SSH host is not evidence that its process or transcript disappeared, and a local file with the same session id must never become a substitute. Durable host-owned evidence and fail-closed capability gates preserve that boundary across restart, reconnect, web pairing changes, and mixed client/host versions.
Linked Issue
Fixes #13663
STA-3846
Supersedes #13687 and #15515.
Visual Proof
N/A — no UI chrome changed. The existing native-chat view receives the same snapshot/append frames after ownership is proven; unknown or incompatible ownership remains gated without transcript IO.
Testing
pnpm typechecknode config/scripts/check-changed-code-quality.mjsnode config/scripts/check-react-doctor-changed.mjsgit diff --checkmobile/pnpm-lock.yamlunchangedNon-vacuity was proved by temporarily changing the SSH owner verdict to
legacy-local: the receiver-sensitive test failed because it expected[{ id: 'bound-remote' }]and received{ error: 'Transcript unavailable', notFound: true }. Restoring the owner verdict made the same test pass; the temporary mutation is not present in this branch.AI Disclosure
Internal contributor.
Remote wire compatibility
native-chat.transcript-owner.v1is an optional status capability, so older decoders ignore it safely.SSH / folder workspaces / mobile
Ownership follows the execution connection and pane identity, so SSH folder workspaces are covered without assuming a git worktree. WSL relay ownership remains local/UNC-backed, while SSH transport loss remains
unverifiable. Mobile and web use the same gated native-chat RPC surface as desktop remote runtimes.Checklist