Skip to content

fix(files): links to this computer in a remote terminal open on the client with trusted provenance - #27234

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/d4-d4-v1c
Oct 10, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/d4-d4-v1c

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

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.html underlined, 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:

  • Cmd/Ctrl-click on a text file opens a read-only editor tab in the current workspace (read-only because the tab belongs to this computer, not to the server that owns the workspace). If a local workspace already holds that file open, it opens there, editable.
  • Cmd/Ctrl-click on an .html file 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.
  • Shift-click and the popover's default-app row open it with this computer's default app instead of trying to download it from the server.
  • If this computer does not have the file either, the toast still says the path is outside every workspace on its host.

Mechanism. resolveHostWorkspaceFile already asks the server (files.resolveTerminalPath with crossWorkspace) 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. openDetectedFilePath then 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:

  • The server must advertise files.resolve-terminal-path.cross-workspace.v1. Servers that predate it may ignore crossWorkspace and refuse a path that actually sits in another of their workspaces, so their refusal never reaches this computer.
  • Paired web clients never take the fallback: their file bridge answers from the server, not from the browser's computer.
  • The read-only tab stays this computer's after a reload or restart: a read-only tab named by absolute path is treated like an AI Vault log tab (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

  • Why not loosen the "outside the owning runtime worktree" guard? That guard keeps a remote workspace from reading this computer's disk by accident. This change keeps it, and asks the server first so a path it owns is never shadowed by a local file of the same name.
  • Why fall back only after the server answers? A dropped connection is not evidence that the path belongs to this computer; only an explicit "not mine" from the server is.
  • Why read-only in the server workspace? An editor tab's owner must match its workspace's; the same rule already applies to AI Vault log tabs.
  • Known tradeoff: if both machines have the same out-of-workspace path (say /tmp/out.log on 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.
  • Compatibility: one new host capability string, nothing else on the wire. A client paired to an older server keeps today's refusal toast; an older client ignores the capability.

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 on origin/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:changed

  • New 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough

Walkthrough

Remote terminal file links can resolve to client-local files when the host declines an ungranted path and client stat succeeds. Routing uses client-local settings and a null runtime environment for these files. The system-default action now calls openDetectedFilePath instead of the remote download helper. Editor loading uses user-file access for matching read-only local tabs. Tests cover resolution, routing, failure cases, and local-file access.



Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to ac7d6

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 12 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 The changes satisfy the coding requirements in [#23463]. resolveHostWorkspaceFile asks the paired host first and uses client user-file access only after an explicit host refusal without a host gra…
Out of Scope Changes check Passed The changes stay within [#23463]. The capability, routing, editor access, and tab ownership changes support trusted client-local file opening. The added tests verify the requested behavior and securit…
Title check Passed The title clearly summarizes the main change: client-local file links from remote terminals now open on the client with trusted routing.
Description check Passed The description is complete and closely follows the repository template. It explains the user impact, implementation, security boundaries, compatibility, linked issue, testing, and checklist status. T…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · 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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5bfabd26-5b68-4a07-bd7e-bb548f853300
📥 Commits

Reviewing files that changed from the base of the PR and between 9d43038 and 9baa0a3.

📒 Files selected for processing (6)
  • src/renderer/src/components/terminal-pane/terminal-file-link-actions.test.ts
  • src/renderer/src/components/terminal-pane/terminal-file-link-actions.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-host-workspace-file.ts
  • src/renderer/src/components/terminal-pane/terminal-link-client-local-file.test.ts
  • src/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.

Comment on lines +47 to +49
} catch {
// Why: absent here too, so the host may still hold it outside its workspaces.
throw hostRefusal

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' '--- 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'
fi

Repository: 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/src

Repository: 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 -80

Repository: 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'
fi

Repository: 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

@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: 6b77a398-3249-4ff9-a01d-ad882f169650
📥 Commits

Reviewing files that changed from the base of the PR and between 9baa0a3 and ac7d631.

📒 Files selected for processing (8)
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/components/editor/useEditorPanelFileLoadRetry.host-connection.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-host-workspace-file.ts
  • src/renderer/src/components/terminal-pane/terminal-link-client-local-file.test.ts
  • src/renderer/src/lib/local-file-access.test.ts
  • src/renderer/src/lib/local-file-access.ts
  • src/shared/protocol-version.ts
  • src/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)

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 | 🟠 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/src

Repository: 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 || true

Repository: 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 -240

Repository: 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.

@OrcaWin
OrcaWin merged commit f361455 into main Oct 10, 2026
41 checks passed
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]: File links to this computer do nothing in a remote server's terminal

1 participant