Repository navigation
fix(files): links to this computer in a remote terminal open on the client with trusted provenance - #27234
Conversation
… here when the host disowns it
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to A file tab can read from the wrong computer in a paired workspace, and some local file errors can appear as host refusals. Resolve the tab ownership issue before merging. Pre-merge checks |
|
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:
5bfabd26-5b68-4a07-bd7e-bb548f853300
📒 Files selected for processing (6)
src/renderer/src/components/terminal-pane/terminal-file-link-actions.test.tssrc/renderer/src/components/terminal-pane/terminal-file-link-actions.tssrc/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/components/terminal-pane/terminal-host-workspace-file.tssrc/renderer/src/components/terminal-pane/terminal-link-client-local-file.test.tssrc/renderer/src/components/terminal-pane/terminal-link-host-workspace-file.test.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.
| } catch { | ||
| // Why: absent here too, so the host may still hold it outside its workspaces. | ||
| throw hostRefusal |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- target file ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-host-workspace-file.ts | sed -n '1,130p'
printf '%s\n' '--- helper references ---'
rg -n -F -- 'isMissingRuntimePathError' src/renderer/src/components/terminal-pane src/renderer/src | head -40
printf '%s\n' '--- routing helper context ---'
routing=$(rg -l -F -- 'isMissingRuntimePathError' src/renderer/src/components/terminal-pane src/renderer/src | head -1)
if [ -n "$routing" ]; then
nl -ba "$routing" | sed -n '1,180p'
fiRepository: stablyai/orca
Length of output: 15150
🏁 Script executed:
nl -ba src/renderer/src/components/terminal-pane/terminal-host-workspace-file.ts | sed -n '1,100p'
printf '%s\n' '--- helper definition and uses ---'
rg -n -F -- 'isMissingRuntimePathError' src/renderer/srcRepository: stablyai/orca
Length of output: 6397
🏁 Script executed:
set -eu
printf '%s\n' '--- missing-path helper ---'
nl -ba src/renderer/src/runtime/runtime-file-metadata-client.ts | sed -n '1,105p'
printf '%s\n' '--- statRuntimePath export and implementation ---'
rg -n -F -- 'statRuntimePath' src/renderer/src/runtime/runtime-file-client.ts src/renderer/src/runtime
nl -ba src/renderer/src/runtime/runtime-file-client.ts | sed -n '1,100p'Repository: stablyai/orca
Length of output: 5637
🏁 Script executed:
set -eu
printf '%s\n' '--- fallback guard ---'
rg -n -F -- 'assertLocalFilesystemFallbackAllowed' src/renderer/src
printf '%s\n' '--- fs.stat declarations and implementations ---'
rg -n -F -- 'fs: {' src src/shared src/preload src/main 2>/dev/null || true
rg -n -F -- 'stat:' src src/shared src/preload src/main 2>/dev/null | head -80Repository: stablyai/orca
Length of output: 26185
🏁 Script executed:
set -eu
printf '%s\n' '--- fallback guard implementation ---'
nl -ba src/renderer/src/runtime/runtime-file-routing.ts | sed -n '85,125p'
printf '%s\n' '--- preload filesystem API stat ---'
nl -ba src/preload/api/filesystem-api.ts | sed -n '135,175p'
printf '%s\n' '--- preload fs bridge stat ---'
nl -ba src/preload/api/fs-bridge.ts | sed -n '135,175p'Repository: stablyai/orca
Length of output: 4763
🏁 Script executed:
set -eu
printf '%s\n' '--- fs:stat handlers ---'
rg -n -F -- "'fs:stat'" src/main src/preload src/renderer
rg -n -F -- '"fs:stat"' src/main src/preload src/renderer
printf '%s\n' '--- stat handler context ---'
handler=$(rg -l -F -- "'fs:stat'" src/main | head -1)
if [ -n "$handler" ]; then
nl -ba "$handler" | sed -n '1,240p'
fiRepository: stablyai/orca
Length of output: 820
🏁 Script executed:
nl -ba src/main/ipc/filesystem/filesystem-read-handlers.ts | sed -n '115,160p'Repository: stablyai/orca
Length of output: 2225
Rethrow unexpected local stat errors.
The local fallback guard cannot throw here because activeRuntimeEnvironmentId and worktreeId are both null. However, the fs:stat handler calls stat(filePath), and its failures still reach the bare catch and become hostRefusal. Recognize ENOTDIR in the existing helper, then rethrow other errors.
🐛 Suggested fix
-import { statRuntimePath } from '@/runtime/runtime-file-client'
+import {
+ isMissingRuntimePathError,
+ statRuntimePath
+} from '@/runtime/runtime-file-client'
...
- } catch {
+ } catch (error) {
+ if (!isMissingRuntimePathError(error)) {
+ throw error
+ }
// Why: absent here too, so the host may still hold it outside its workspaces.
throw hostRefusal- message.includes('enoent') || message.includes('not found') || message.includes('no such file')
+ message.includes('enoent') ||
+ message.includes('enotdir') ||
+ message.includes('not found') ||
+ message.includes('no such file')Source: Learnings
…llback on host support and native clients
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:
6b77a398-3249-4ff9-a01d-ad882f169650
📒 Files selected for processing (8)
src/renderer/src/components/editor/useEditorPanelFileContentLoader.tssrc/renderer/src/components/editor/useEditorPanelFileLoadRetry.host-connection.test.tsxsrc/renderer/src/components/terminal-pane/terminal-host-workspace-file.tssrc/renderer/src/components/terminal-pane/terminal-link-client-local-file.test.tssrc/renderer/src/lib/local-file-access.test.tssrc/renderer/src/lib/local-file-access.tssrc/shared/protocol-version.tssrc/shared/runtime-file-contracts.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.
| export function isClientLocalReadOnlyTab( | ||
| file: Pick<OpenFile, 'filePath' | 'relativePath' | 'readOnly' | 'liveTail'> | ||
| ): boolean { | ||
| return file.readOnly === true && (file.liveTail === true || file.relativePath === file.filePath) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect read-only tab producers and restored-tab ownership fields.
rg -n -C 4 --glob '*.ts' --glob '*.tsx' \
'readOnly:\s*true|externalSshTargetId|suppressActiveRuntimeFallback|relativePath:\s*filePath' \
src/renderer/srcRepository: stablyai/orca
Length of output: 43348
🏁 Script executed:
set -eu
printf '%s\n' '--- local-file-access.ts ---'
nl -ba src/renderer/src/lib/local-file-access.ts | sed -n '1,110p'
printf '%s\n' '--- useEditorPanelFileContentLoader.ts references ---'
rg -n -C 10 --glob '*.ts' --glob '*.tsx' 'isClientLocalReadOnlyTab|editorTabFileAccess|clear.*Connection|connectionId' src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts src/renderer/src/lib src/renderer/src
printf '%s\n' '--- terminal-file-open-routing.ts ---'
nl -ba src/renderer/src/lib/terminal-file-open-routing.ts | sed -n '250,320p'
printf '%s\n' '--- OpenFile declaration and SSH ownership fields ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' 'export (interface|type) OpenFile|externalSshTargetId' src/renderer/src/store/slices/editor src/renderer/src/lib | head -240
printf '%s\n' '--- restore owner handling ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' 'externalSshTargetId|readOnly|relativePath' src/renderer/src/store/slices/editor/restored-editor-owner-transition.ts src/renderer/src/store/slices/editor/hydrate-editor-session.ts src/renderer/src/store/slices/editor/workspace-session.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 45668
🏁 Script executed:
set -eu
nl -ba src/renderer/src/lib/local-file-access.ts | sed -n '1,100p'
nl -ba src/renderer/src/lib/terminal-file-open-routing.ts | sed -n '270,310p'
rg -n -C 12 --glob '*.ts' --glob '*.tsx' 'isClientLocalReadOnlyTab|editorTabFileAccess' src/renderer/src
rg -n -C 10 --glob '*.ts' --glob '*.tsx' 'externalSshTargetId' src/renderer/src/store/slices/editor | head -240Repository: stablyai/orca
Length of output: 42100
Verify client provenance before routing a read-only tab locally.
isClientLocalReadOnlyTab ignores externalSshTargetId, so a restored SSH-owned tab with readOnly: true and relativePath === filePath is classified as client-local. The loader then clears readConnectionId, and editorTabFileAccess returns user-file before checking SSH ownership. This can route the read to the client instead of the SSH host.
Persist explicit client-local provenance and require that provenance here. Do not infer host ownership from path equality alone.
ELI5
An agent running on a paired Orca server can print the path of a file that lives on your computer (for example a review page it wrote to your Desktop). Clicking that link used to do nothing useful. Now, when the server says the path is not one of its files, and your computer has it, the click opens it from your computer.
What Changed
Before: in a terminal (or native chat) of a workspace on a paired Orca server, a link such as
/Users/me/Desktop/review.htmlunderlined, but Cmd/Ctrl-click, Shift-click and both popover rows failed. Since #27226 they at least showed "… is outside every workspace on its host", but nothing opened.After: the same click opens the file from this computer:
.htmlfile renders it in a browser tab that this computer owns, so the server runtime never tries to load the server's copy of that path.Mechanism.
resolveHostWorkspaceFilealready asks the server (files.resolveTerminalPathwithcrossWorkspace) which of its workspaces holds a clicked path. When the server answers that none does and it issued no read grant for the path, the function now stats the path on this computer (as a user-named file) and returns a "client" owner.openDetectedFilePaththen switches the open to a client-only file context, so the default-app check, the HTML browser tab and the editor tab all treat it as this computer's file. The popover's default-app row now goes through the same open flow instead of calling the server download directly; for server files that flow still downloads first.Three guards decide when "not mine" is trustworthy:
files.resolve-terminal-path.cross-workspace.v1. Servers that predate it may ignorecrossWorkspaceand refuse a path that actually sits in another of their workspaces, so their refusal never reaches this computer.isClientLocalReadOnlyTab), so the editor never infers the workspace's SSH or server owner for it.The rule that keeps this safe: this computer is only read after the user clicks the link here, and only for a path the server disowned. A host-granted path, a server that cannot be reached, or a sibling-workspace file the server says is missing never falls back to this computer. Printed output alone still never opens or reads anything.
Why
/tmp/out.logon two Linux machines), the click opens this computer's copy. The server cannot read outside its workspaces, so it cannot tell us whether it also has one.Linked Issue
Fixes #23463
Visual Proof
N/A — routing change behind a click; covered by an acceptance test that drives the real open flow (
terminal-link-client-local-file.test.ts). It fails onorigin/main(3 of 6 cases: read-only open, Shift-click default app, HTML browser tab) and passes here.Testing
pnpm test src/renderer/src/components/terminal-pane/ src/renderer/src/components/native-chat(912 files pass)pnpm tc:web,oxlint,pnpm run check:code-quality:changedNew cases also prove the boundary: no client read when the host is unreachable, when the host granted the path, when the host lacks the capability, or in a paired web client; a read-only client tab in an SSH-backed workspace reads this computer with user-file access.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Security: the client file system is read only on a user click on this client, and only for a path the server explicitly disowned without a grant. SSH: direct SSH workspaces do not take this path (no paired server); a paired server's SSH-backed workspace follows the same server answer. Windows/WSL: paths are compared and stat'ed as given; a WSL path on a Windows client is simply absent, so the server's refusal stands. Paired web clients never take the fallback. Folder workspaces use the same flow.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)