Skip to content

fix(terminal): a file link opens in the workspace it was clicked in - #32320

Merged
nwparker merged 3 commits into
mainfrom
nwparker/terminal-link-stay-in-workspace
Oct 24, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/terminal-link-stay-in-workspace

Conversation

@nwparker

@nwparker nwparker commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​585 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​549
Prod 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​450 $\color{#cf222e}{\Huge{\mathbf{−}}}$​92 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358

ELI5

Clicking a terminal or chat file link used to switch you to whichever workspace contains that file. On this computer, the file now opens right where you clicked, as a read-only view. A toast tells you which workspace the file belongs to and has an Open there button to go there. SSH and server workspaces still switch as before.

What Changed

Before: in workspace A, Cmd/Ctrl-clicking a link to a file that another workspace B also holds moved you to B. B might be a sibling worktree, the main repo, or a folder workspace rooted at ~, which holds almost every file. On this computer, the click opened an absolute-path tab in A, and then the editor loader moved that tab into B and activated B.

After, on this computer (local, WSL and folder workspaces):

  • The file opens read-only in A, next to the terminal that printed it. The editor header shows a Read-only badge.
  • A toast says "This file is in repo-b · main" and "Opened here as read-only", and has an Open there button.
    • It names the project for git worktrees, because worktrees in different projects are often all called main.
    • Open there switches to B and opens the file there as an editable file of B, keeping the line reveal.
    • The next click supersedes it, both the toast and its line reveal.
  • The view stays live: it is watched with B, so external edits, deletes and re-creates reach it, including after a restart.
  • A phone doesn't mirror plain-text tabs that name a file outside their workspace. The phone reads files by workspace-relative path, so those tabs only ever showed an error card. Markdown views still mirror.

Unchanged:

  • Files inside A, and files outside every workspace.
  • SSH and server (paired or managed) workspaces still switch to the owning workspace. A server reads files only by workspace-relative path, so a view in A of B's server file would need owner-addressed reads on every read path: the editor, the conflict compare dialog, Markdown for phones, and so on. Supporting that is a follow-up. The loader still moves any restored read-only server tab for another workspace's file into that workspace, so no server view can come back after a restart.

Mechanism:

  • terminal-file-open-routing.ts looks up the owning workspace with the existing findWorkspaceFileRoute, which covers git worktrees and folder workspaces. On this computer, it opens the file read-only in A and shows the hint. On SSH it opens the file in the owner, which also reuses a tab already open there.
  • New modules:
    • terminal-file-link-owner-resolution.ts: the link-owner resolution, extracted to keep the routing file under the line limit;
    • terminal-file-other-workspace-owner.ts and terminal-file-other-workspace-hint.ts;
    • lib/open-file-owner-scope.ts: works out which workspace watches a view, from the catalog. Every watch matcher uses it, and the result is cached per route inputs.
  • The Read-only badge is in EditorPanelHeaderPath.tsx. Strings are in all 7 locales.
  • This PR builds on refactor(terminal): split terminal-file-open-routing.ts back under the line limit #32932, which moved the open-turn and HTML-browser-open helpers out of the routing file.

Why

  • Read-only keeps what the old switch protected. The file is edited only through the workspace that owns it, so there are no duplicate editable buffers. This computer reads the absolute path directly with the user's own access.
  • Scope. The reporter uses both local and SSH workspaces. An earlier revision also opened server files in place, reading them through B's scope. Every review round then found another server read path addressing files by A plus an absolute path. So this PR ships the change on this computer only, and leaves server and SSH as today.
    • Follow-up: open in place on SSH and servers, with owner-addressed reads on every read path (editor loader, compare dialog, main's Markdown disk host for phones, and so on).
  • Toast, not banner. STYLEGUIDE maps transient confirmations to sonner, and this reuses the existing toast-with-action pattern. The lasting read-only state is a Badge.
  • Watch scope. It is derived from the catalog rather than stored, so restored and reused views need nothing persisted.
  • Compatibility. There is no wire change, and old hosts and clients are unaffected.

Linked Issue

Fixes #32158

Thanks to @quzard for the clear report and the "open there?" suggestion.

Visual Proof

This was checked rendered on a hidden dev build with an isolated profile and two local repos, in both light and dark themes. The steps: in repo-a, Cmd-click a terminal path into repo-b, then click Open there. The screenshots are kept locally and not committed:

  • Toast: "This file is in repo-b · main", with "Opened here as read-only" and Open there.
  • Read-only view: the file shows in repo-a with a "Read-only" badge in the header. It stayed read-only in repo-a after a renderer reload.
  • After Open there: repo-b is active, with the file open editable.

The rendered check led to two changes:

  • the toast now names the project, because it first said "This file is in main";
  • the header now shows the Read-only badge, because nothing persistent marked the tab as read-only.

Testing

  • terminal-link-other-workspace-hint.sonner.test.tsx (component test with the real Toaster):

    • a link inside A shows no hint;
    • B's file opens read-only in A, the hint reads "This file is in project-b · feature-b", and Open there opens it editable in B;
    • a reused editable tab gets no hint;
    • a second click while the hint shows keeps the new hint.
  • Routing tests:

    • a folder-workspace sibling opens read-only here, with the hint;
    • a direct-SSH sibling opens in its owner;
    • a server host's link to a known workspace still opens there, with no view and no hint;
    • a file outside every workspace stays editable;
    • "Open there" yields to a later click.
  • Loader: a restored read-only server tab for another workspace's file is moved to that workspace, as on main.

  • Watch tests:

    • a restored view matches its owner's watch;
    • delete marks it and re-create clears it;
    • overflow/resync re-reads it;
    • the watch target follows catalog changes.
  • Mobile: an outside-workspace plain-text tab is held back, and Markdown still publishes.

  • e2e: golden-terminal-file-link.spec.ts is updated. It runs in CI.

  • Rendered check: done on a hidden dev build in light and dark, covering the toast, the Read-only badge and Open there. Screenshots are kept locally.

  • Local runs: the new specs fail on main. The test files that import the changed modules pass, and the full static job passes.

  • I manually tested these changes locally

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

AI Disclosure

Review

Several Opus and Codex rounds. Findings were fixed or led to scope cuts:

  • the Markdown owner-scoping was dropped;
  • server views were dropped, per the coordinator, because each review round found another server read path that couldn't read them;
  • the watch scope is derived from the catalog instead of stored;
  • an import cycle was removed;
  • the hint gets a fresh toast id per open;
  • owner lookups are cached.

The final head is Opus-approved and Codex-clean (see the handoff).

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

  • SSH and server workspaces: they keep switching. Open-in-place there is a follow-up, as explained under Why.
  • Mobile: a phone tap still opens a preview over the current session.
  • Cross-platform: WSL paths go through this computer's host, and owner matching is separator-insensitive.
  • Agent chat links share this path.

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 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65043bda-9891-461e-8c5c-e75b7c59ecbe
📥 Commits

Reviewing files that changed from the base of the PR and between 0e872e2 and d350f92.

📒 Files selected for processing: 8
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes: 7
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ko.json

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

📝 Walkthrough

Terminal file links can open files owned by another workspace as read-only views in the current workspace. A hint can activate the owning workspace and open the file there. Editor content loading and external file handling now resolve eligible views through their owner worktree. The editor header shows a read-only badge. Mobile session snapshots now publish Markdown files or files whose relative path differs from their file path.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to d350f

Local sibling links retain the intended in-place behavior. A narrow owner-cache case and a gap in visible read-only test coverage remain; these warrant owner awareness and follow-up, but do not currently establish a broad failure that blocks merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #32158 expects a terminal file link to stay in the clicked workspace and provide an owner hint when another workspace owns the file. The PR implements this for local, WSL, and folder workspaces.… Implement the in-place read-only view and owner hint for SSH and server workspaces. Add owner-scoped reads for every affected read path and automated coverage. If SSH and server workspaces are intentionally excluded, record an approved scop…
Docstring Coverage Warning Docstring coverage is 56.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 33 files. (7 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly describes the primary behavior change: terminal file links open in the workspace where the link was clicked.
Description check Passed The description is complete and follows the template. It explains the user-facing behavior, scope, rationale, linked issue, visual validation, tests, compatibility considerations, and checklist status…
Out of Scope Changes check Passed The production changes support issue #32158. Routing, owner resolution, the read-only view, the owner hint, the editor badge, owner-scoped watching, loader handling, mobile tab filtering, locale strin…
Full details: Description check

Explanation

The description is complete and follows the template. It explains the user-facing behavior, scope, rationale, linked issue, visual validation, tests, compatibility considerations, and checklist status.

Full details: Out of Scope Changes check

Explanation

The production changes support issue #32158. Routing, owner resolution, the read-only view, the owner hint, the editor badge, owner-scoped watching, loader handling, mobile tab filtering, locale strings, and tests implement or validate the cross-workspace file-link behavior. No unrelated change is established.

Full details: Linked Issues check

Explanation

Issue #32158 expects a terminal file link to stay in the clicked workspace and provide an owner hint when another workspace owns the file. The PR implements this for local, WSL, and folder workspaces. The current code explicitly routes non-local hosts to the owner, and the SSH test preserves that behavior. The issue description includes SSH workspaces, so the requirement is not complete. The suggested preference setting is optional and does not affect this result.

Resolution

Implement the in-place read-only view and owner hint for SSH and server workspaces. Add owner-scoped reads for every affected read path and automated coverage. If SSH and server workspaces are intentionally excluded, record an approved scope change for issue #32158.

Full details: Docstring Coverage

Explanation

Docstring coverage is 56.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 33 files. (7 skipped: 7 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

🧹 Nitpick comments: 1
tests/e2e/golden-terminal-file-link.spec.ts: 1

313-322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the read-only state through the DOM, not through window.__store.

This block reads openFiles[].readOnly from the store to confirm the view is read-only. The e2e guideline says to assert user-visible behavior through the DOM. A store-only check passes even if the editor renders the file as editable. Replace it with a DOM assertion on the rendered editor. For example, check that the editor reports read-only or rejects typing. If the DOM has no read-only signal, keep the store check as a secondary assertion.

As per path instructions: "Use window.__store for setup; assert user-visible behavior through the DOM (getByRole, toBeVisible, toHaveText)."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4961ab3c-7b78-43f7-83a1-9508066cd064
📥 Commits

Reviewing files that changed from the base of the PR and between 8d94ed0 and 50a8377.

📒 Files selected for processing: 27
  • src/renderer/src/components/editor/editor-autosave.ts
  • src/renderer/src/components/editor/editor-external-watch-path-index.ts
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/components/editor/useEditorPanelRemoteSiblingContentState.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-hint.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-link-file-open-routing.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers-test-fixtures.ts
  • src/renderer/src/components/terminal-pane/terminal-link-host-workspace-file.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-open-beside-source.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-other-workspace-hint.sonner.test.tsx
  • src/renderer/src/hooks/editor-external-watch-background-trim.test.ts
  • src/renderer/src/hooks/editor-external-watch-event-reconciliation.ts
  • src/renderer/src/hooks/editor-external-watch-other-workspace-view.test.ts
  • src/renderer/src/hooks/editor-external-watch-overflow.test.ts
  • src/renderer/src/hooks/editor-external-watch-overflow.ts
  • src/renderer/src/hooks/editor-external-watch-targets.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/open-file-watch-scope.ts
  • tests/e2e/golden-terminal-file-link.spec.ts

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

@nwparker
nwparker force-pushed the nwparker/terminal-link-stay-in-workspace branch from dc98aa3 to 2135892 Compare October 23, 2026 20:50

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Keep local sibling tabs in the clicked workspace. · useEditorPanelFileContentLoader.ts:168-172

src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts:168-172
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep local sibling tabs in the clicked workspace.

A local sibling terminal link creates a read-only tab with runtimeEnvironmentId: null. The loader treats that value as a re-own trigger, so the tab moves to the owning workspace instead of loading through the owner while remaining in the clicked workspace.

This affects the ordinary cross-workspace local-link case, but it does not block file viewing. The tab is recoverable through the existing Open there action. Classify this as a minor functional issue.

Suggested fix
               if (
                 !restoredOpenFile.readOnly ||
-                !runtimeEnvironmentId ||
                 restoredOpenFile.terminalArtifactGrantId
               ) {

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 27b7d8c8-b965-4af9-a5e4-24eb5d9f954d
📥 Commits

Reviewing files that changed from the base of the PR and between 50a8377 and 2135892.

📒 Files selected for processing: 24
  • src/renderer/src/components/editor/editor-autosave-holds.ts
  • src/renderer/src/components/editor/editor-autosave.ts
  • src/renderer/src/components/editor/editor-buffer-adapter.ts
  • src/renderer/src/components/editor/editor-external-change-tab-reset.ts
  • src/renderer/src/components/editor/editor-external-watch-path-index.ts
  • src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-turn.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-hint.test.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-hint.ts
  • src/renderer/src/hooks/editor-external-watch-background-trim.test.ts
  • src/renderer/src/hooks/editor-external-watch-disk-verification.ts
  • src/renderer/src/hooks/editor-external-watch-event-reconciliation.ts
  • src/renderer/src/hooks/editor-external-watch-other-workspace-view.test.ts
  • src/renderer/src/hooks/editor-external-watch-overflow.ts
  • src/renderer/src/hooks/editor-external-watch-targets.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/open-file-owner-scope.ts
🚧 Files skipped from review as they are similar to previous changes: 7
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ko.json

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Use the owner route for self-write verification. · editor-external-watch-disk-verification.ts:283-301

src/renderer/src/hooks/editor-external-watch-disk-verification.ts:283-301
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the owner route for self-write verification.

An owner-scoped event can select a read-only tab whose file.worktreeId and file.relativePath still identify the source workspace. For environment targets, readRuntimeFileContent sends those values to files.read; it does not use filePath for that RPC. The verification can therefore read the source workspace instead of the owner workspace. A matching source file can suppress the owner reload, while a missing or different source file can cause a false verification result.

Use the owner-scoped notification values at this boundary:

Suggested fix
-    relativePath: file.relativePath,
-    worktreeId: file.worktreeId,
+    relativePath: notification.relativePath,
+    worktreeId: notification.worktreeId,

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1bbe7af7-af65-4e8e-98ce-22093f610f26
📥 Commits

Reviewing files that changed from the base of the PR and between 2135892 and 1664d41.

📒 Files selected for processing: 11
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-hint.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers-test-fixtures.ts
  • src/renderer/src/components/terminal-pane/terminal-link-other-workspace-hint.sonner.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes: 7
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json

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

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 060455bc-fd42-49fe-bbd6-b3cd07d13d7c
📥 Commits

Reviewing files that changed from the base of the PR and between 1664d41 and 0e872e2.

📒 Files selected for processing: 13
  • src/renderer/src/components/editor/useEditorPanelRemoteSiblingContentState.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-file-link-owner-resolution.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-hint.ts
  • src/renderer/src/components/terminal-pane/terminal-file-other-workspace-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-html-file-browser-open.ts
  • src/renderer/src/components/terminal-pane/terminal-link-file-open-routing.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-host-workspace-file.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-other-workspace-hint.sonner.test.tsx
  • src/renderer/src/hooks/editor-external-watch-background-trim.test.ts
  • src/renderer/src/lib/open-file-owner-scope.ts
  • src/renderer/src/runtime/sync-runtime-graph-outside-workspace-file-tabs.test.ts
  • src/renderer/src/runtime/sync-runtime-graph/mobile-session-surfaces.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 +46 to +53
const epoch = editorBufferRouteEpochOf(state)
const cached = ownerScopeCache.get(file)
if (cached?.epoch === epoch) {
return cached.scope
}
const route = findWorkspaceFileRoute(state, LOCAL_EXECUTION_HOST_ID, file.filePath)
const scope = route ? { worktreeId: route.worktreeId, relativePath: route.relativePath } : own
ownerScopeCache.set(file, { epoch, scope })

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:

#!/bin/bash
# Compare epoch inputs with the catalog fields read by the route lookup.
rg -nP -C8 'function routeInputsOf' src/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.ts
rg -nP -C12 'function workspaceMatchesExecutionHost' src/renderer/src
rg -nP -C4 'function findWorkspaceFileRoute|function findRuntimeWorkspaceFileOwner' src/renderer/src/lib

Repository: stablyai/orca

Length of output: 4091


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- epoch declaration and implementation ---'
nl -ba src/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.ts | sed -n '1,100p'
printf '%s\n' '--- route lookup and host matching ---'
nl -ba src/renderer/src/lib/runtime-workspace-file-route.ts | sed -n '1,180p'
printf '%s\n' '--- direct helper definitions ---'
rg -n -F --glob '*.ts' -e 'function resolveExplicitWorktreeOperationRouteResult' -e 'function getExecutionHostIdForWorktree' -e 'function runtimeEnvironmentIdUnlessTwin' -e 'function selectWorktreesByRepo' -e 'function selectFolderWorkspaces' src/renderer/src

Repository: stablyai/orca

Length of output: 7682


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- route state type ---'
rg -n -F --glob '*.ts' -e 'export type WorktreeOperationRouteState' -e 'interface WorktreeOperationRouteState' src/renderer/src
printf '%s\n' '--- direct helper bodies ---'
nl -ba src/renderer/src/lib/resolve-owner.ts | sed -n '190,245p'
nl -ba src/renderer/src/lib/worktree-runtime-owner.ts | sed -n '80,145p'
nl -ba src/renderer/src/lib/worktree-operation-catalog-route.ts | sed -n '1,100p'
nl -ba src/renderer/src/store/workspace-record-selectors.ts | sed -n '1,70p'
nl -ba src/renderer/src/store/worktree-repo-index.ts | sed -n '1,180p'

Repository: stablyai/orca

Length of output: 18140


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- complete route-state declaration ---'
nl -ba src/renderer/src/lib/worktree-operation-route.ts | sed -n '1,95p'
printf '%s\n' '--- runtime owner implementation ---'
nl -ba src/renderer/src/lib/worktree-runtime-owner.ts | sed -n '1,130p'
printf '%s\n' '--- explicit route helper remainder ---'
nl -ba src/renderer/src/lib/worktree-operation-catalog-route.ts | sed -n '90,260p'
printf '%s\n' '--- resolve-owner direct dependencies ---'
rg -n -F --glob '*.ts' -e 'function runtimeEnvironmentIdForWorkspaceOwner' -e 'function restoredFolderEnvironmentId' -e 'function getRuntimeEnvironmentIdForFolderWorkspace' -e 'function getUnstampedExecutionHostId' -e 'function getSingleFocusedRuntimeEnvironmentId' src/renderer/src/lib

Repository: stablyai/orca

Length of output: 15152


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- inherited state types ---'
rg -n -F --glob '*.ts' -e 'export type FolderWorkspaceRuntimeOwnerState' -e 'export type WorktreeRuntimeOwnerState' -e 'interface FolderWorkspaceRuntimeOwnerState' -e 'interface WorktreeRuntimeOwnerState' src/renderer/src
printf '%s\n' '--- inherited type declarations and ownership helpers ---'
nl -ba src/renderer/src/lib/folder-workspace-runtime-owner.ts | sed -n '1,135p'
nl -ba src/renderer/src/lib/worktree-runtime-owner-state.ts | sed -n '1,180p'
nl -ba src/renderer/src/lib/active-workspace-host.ts | sed -n '1,150p'
nl -ba src/renderer/src/lib/paired-web-client-host.ts | sed -n '1,130p'
nl -ba src/renderer/src/lib/single-runtime-legacy-owner.ts | sed -n '1,80p'

Repository: stablyai/orca

Length of output: 13545


Include active workspace ownership in the route epoch.

findWorkspaceFileRoute can read activeWorktreeId and activeWorkspaceExecutionHostId through its ownership helpers. These fields are missing from EDITOR_BUFFER_ROUTE_INPUT_KEYS, so openFileOwnerScope can keep a stale owner after the active workspace changes.

🐛 Suggested fix
   'runtimeEnvironments',
   'settings',
+  'activeWorktreeId',
+  'activeWorkspaceExecutionHostId',
   'editorBufferIdentityRevision'

A terminal or chat link to a file another workspace on the same host holds used to switch to that workspace. It now opens as a plain read-only file in the workspace it was clicked in (local and WSL read on this computer; paired and managed servers read through the owning workspace's scope), with a toast naming the owner and an Open there action, and a Read-only badge in the editor header. HTML on server hosts, server workspaces the client does not know, directories, shift-click download and direct-SSH workspaces keep the switch. The view is watched with its owner through one derived scope (lib/open-file-owner-scope.ts); phones skip plain file tabs they cannot read by workspace-relative path.

Fixes #32158
…er links keep opening in their workspace

Servers read files only by workspace-relative path, so a read-only view of another workspace's server file needed owner rerouting in every read path. Paired and managed servers keep today's switch; the loader moves any restored read-only server tab of another workspace's file there as before.
@nwparker
nwparker force-pushed the nwparker/terminal-link-stay-in-workspace branch from 0e872e2 to d350f92 Compare October 24, 2026 00:53
@nwparker
nwparker merged commit 359fec1 into main Oct 24, 2026
45 checks passed
nwparker added a commit that referenced this pull request Oct 25, 2026
…ked in (#32320)" (#33304)

* Revert "fix(terminal): a file link opens in the workspace it was clicked in (#32320)"

This reverts commit 359fec1.

* test: drop redundant openFiles cast restored by the revert
audichuang added a commit to audichuang/orca that referenced this pull request Oct 25, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 26, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 27, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 28, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 29, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 30, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 2, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 3, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 4, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 5, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 5, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 6, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 7, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 12, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 13, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 14, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 16, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 19, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 21, 2026
v1.4.240 reverted stablyai#32320, so getOpenFilesForExternalFileChange takes two
arguments again; the folder discard seam test still passed the store as a
third one and broke the web typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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]: Clicking a file link in a terminal switches to a different workspace

1 participant