Skip to content

fix(files): a paired-server link outside its workspace opens in the host workspace that holds it - #27226

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-v1a
Oct 10, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-v1a

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When Orca is connected to a paired Orca server, clicking a file link that points into a different workspace on that server (for example the main repo while you work in a worktree, or a sibling worktree) did nothing useful. Now Orca asks the server which of its workspaces holds that file and opens it there.

What Changed

Before (paired server, desktop or web): an agent or terminal link such as /repo/src/index.ts, clicked from the worktree /repo/.orca/worktrees/feat-x, showed "Couldn't check /repo/src/index.ts: Remote file is outside the owning runtime worktree" and opened nothing.

After:

  • A link into another workspace on the same server opens the file in that workspace (it switches to the workspace, as a cross-workspace link does locally), with the line reveal still applied.
  • A link into another workspace whose file the server says is gone reports "File not found".
  • A link to a path outside every workspace on the server is refused with "… is outside every workspace on its host", instead of the old internal error.
  • Shift-click ("open with default app") on such a server file downloads it first, and a server directory link never opens on this computer. The check for "can this computer's OS open this path" now looks at who owns the workspace (paired server or SSH), not whether the path sits inside the source workspace; before, a server path outside its workspace read as a local path (unreachable in practice until this PR, because the open was refused earlier).

Mechanism: the link-open flow (openDetectedFilePath, used by terminal links and agent chat links) previously stat'ed the path against the source workspace only; for a paired-server owner the client refuses any path outside that workspace, because it may not read server files outside a workspace. Now, for a paired-server owner and a path outside the source workspace, it first calls the server's existing files.resolveTerminalPath with the existing crossWorkspace: true option. The server picks the workspace on the same host that contains the path (worktrees and folder workspaces, ambiguous candidates dropped) and stats it there. The client then opens the file as a normal file of that workspace, so later reads go through the server's ordinary workspace-contained files.read. The call goes through the host-route adapter, so a reply that arrives after the server identity changed is not applied.

Why

  • Host decides, not the client's copy of the catalog. The server already resolves cross-workspace paths for phones; reusing it keeps one rule on the execution host and covers server workspaces this client has not loaded.
  • No new read authority. Nothing here lets a client read an arbitrary server path. Reads stay inside a workspace on the server, which already enforces that. Opening files outside every workspace needs a grant whose origin the server can check (like the existing terminal-output and agent-chat grants); adding a grant issuer for editor links without such a check would be the unchecked read that the design rejects. That part, and showing grant-backed files in the desktop editor, is left for a follow-up. This PR adapts the plan accordingly: the reported cases (main repo, sibling worktree) need no grant.
  • No wire change. files.resolveTerminalPath and its optional crossWorkspace field already exist (since fix(runtime): make sibling-workspace terminal-path resolution an explicit client opt-in #12616). A server older than that ignores the field and answers "outside the workspace", which now shows the "outside every workspace" refusal: the same outcome as before, with a clearer message. Old clients are unaffected.

Linked Issue

Fixes #23218

Visual Proof

N/A: the change is which file a click opens and the error text; it is covered by routing tests (no layout change). Machine is load-capped, so no app launch.

Testing

  • New terminal-link-host-workspace-file.test.ts (3 of its 4 cases fail on origin/main): main-repo link opens in the workspace the host names, with the server's host id; a path outside every workspace is refused with the new message; a sibling file the host says is missing reports missing; a file inside the source workspace still uses the plain files.stat path.

  • Shift-click on a server file downloads instead of opening the same path locally; a server directory link opens nothing locally (both fail without the owner check).

  • src/renderer/src/components/terminal-pane, browser-pane/workspace-doc, native-chat (920 files), native-chat link click, host-route adapter tests pass.

  • pnpm tc, oxlint, check:code-quality:changed, owner-routing ratchet, localization checks pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Independent P0/P1 review found one P1 (a server path outside its workspace could open with this computer's default app); fixed at the ownership check and confirmed by a delta 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: no new method, permission or grant; reads remain workspace-contained on the server.
  • Cross-platform: the workspace root is derived from the server's own absolute and relative path (separator-insensitive), so Windows servers work.
  • SSH: direct SSH links are unchanged (they already stat on the SSH host). A paired server's own SSH workspaces are resolved by the server.
  • Folder workspaces: the server's lookup includes them, and their ids match the client's.
  • Mobile: unchanged.

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)

m4air added 2 commits October 10, 2026 03:56
…ost workspace that holds it

Links an agent or terminal prints for a paired server's file in another
workspace (the main repo, a sibling worktree) failed with "Remote file is
outside the owning runtime worktree". The link now asks the host through
files.resolveTerminalPath with crossWorkspace, and opens the file in the
workspace the host names. A path outside every host workspace is refused
with a message that says so; a sibling file the host verified absent
reports not found.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67b1e290-3d97-4ecd-9ac4-6fe408b91ef9

📥 Commits

Reviewing files that changed from the base of the PR and between fff0bb0 and 37b613f.


📒 Files selected for processing (7)
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-document-actions.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-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-link-host-workspace-file.test.ts
  • src/renderer/src/lib/workspace-file-host-routing.ts

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



📝 Walkthrough

Walkthrough

Terminal file opening can resolve detected paths through the host and use the returned worktree, absolute path, execution-host ID, and directory status for routing. OS-open eligibility checks now use file context rather than a file path. Tests cover host-resolved files, failure cases, and files in the active workspace.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 37b61

Terminal file links on paired servers now resolve to the correct workspace, and paths outside every workspace get a clearer refusal. No merge-blocking risk was identified in the reviewed changes.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#23218] requires file links outside the current worktree to resolve to an appropriate workspace and specifically expects a main-repository path to remap to the current worktree when the relativ… Implement and test the [#23218] main-repository path rule: when the linked main-repository path has a matching relative file in the current worktree, open the current-worktree file. Preserve the existing host-resolution and user-feedback be…
Docstring Coverage Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: paired-server links outside the current workspace now open in the host workspace that contains the file.
Description check Passed The description covers the required sections, user-visible behavior, implementation, rationale, linked issue, testing, security, platform impact, and checklist. It clearly states that manual testing w…
Out of Scope Changes check Passed The changed files remain within paired-server file-link routing, host-workspace resolution, system-default handling, download behavior, and automated tests. The changes support [#23218], including wor…

Full details: Linked Issues check

Explanation

Issue [#23218] requires file links outside the current worktree to resolve to an appropriate workspace and specifically expects a main-repository path to remap to the current worktree when the relative file exists there. The new tests and resolveHostWorkspaceFile implementation use the host-selected workspace instead. openDetectedFilePath replaces worktreeId and worktreePath with the host response before opening, so this PR does not implement the main-repository-to-current-worktree remap requirement. The implementation does add host resolution, failure reporting, line-preserving editor routing, and tests for sibling, missing, and outside-workspace cases.

Resolution

Implement and test the [#23218] main-repository path rule: when the linked main-repository path has a matching relative file in the current worktree, open the current-worktree file. Preserve the existing host-resolution and user-feedback behavior for other paths.


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

…efault app

The client-OS open decision looked at whether the path sat inside the source
workspace, so a server path outside it read as local. Decide by owner: any
paired-server or SSH workspace downloads first.
@OrcaWin
OrcaWin merged commit 9d43038 into main Oct 10, 2026
39 checks passed
nwparker added a commit that referenced this pull request Oct 23, 2026
Clicking a terminal (or chat) file link to a file that another workspace on the
same host holds switched to that workspace: paired and managed hosts named the
owning workspace and the link activated it (#27226), and on this computer the
editor loader moved the absolute-path tab into the owning workspace and
activated it. The link now opens the file read-only in the source workspace,
read through the owning host and, on a server, through the owning workspace's
scope, and a toast names the owning workspace with an "Open there" action that
opens it there editable. Files inside the source workspace are unchanged. HTML
on a paired or managed host, and workspaces this client's catalog does not
know, keep the switch: their reads are scoped to the workspace they open in.

Fixes #32158
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 outside current worktree fail silently in WebUI and remote runtime clients

1 participant