Skip to content

refactor(files): file reads and edits route by the file's owner - #27278

Merged
OrcaWin merged 5 commits into
mainfrom
OrcaWin/d4-g1-files
Oct 10, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
OrcaWin/d4-g1-files

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 74 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​591 $\color{#cf222e}{\Huge{\mathbf{−}}}$​261 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​330
Prod 79 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​499 $\color{#cf222e}{\Huge{\mathbf{−}}}$​473 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

ELI5

When Orca reads, saves, lists or searches a file on a remote server, it has to pick which machine to ask. Until now the file code asked the machine named by the "Active Server" setting, and trusted each caller to swap in the right one first. Most callers did, but some didn't. Now the file code is given the machine that owns the file, and it can no longer be handed the setting by mistake.

Builds on #27275 (merged), which added the shared helpers and the focus-read lint counter.

What Changed

  • Before (user): if you had more than one host, a few file paths followed whichever server was focused when the action ran, not the workspace the file belongs to:

    • an editor tab restored without an owner stamp
    • a terminal file link from a pane that has no owning runtime
    • an OS file drop onto an editor group
    • a notebook link opened in a browser tab

    Switching the Active Server could make those read the same path on the wrong machine.

  • After (user): each of these goes to the file's own host: the owner stamped on the tab, or else the workspace's owner, worked out from the rows alone. A row from before owner stamping now counts as this computer, even while a single saved server is focused. If the rows disagree about the owner, the action refuses with "Couldn't verify which host owns this file" instead of guessing. Single-host (local-only) users see no change.

  • Mechanism:

    • RuntimeFileReadArgs and RuntimeFileOperationArgs replace settings with target: RuntimeClientTarget. The read, range, search, watch, metadata, import and mutation clients, and runtime-file-routing, read context.target directly. getRuntimeFileReadScope takes a target, so cache and dedupe keys keep the same strings.
    • New lib/file-owner-runtime-target.ts with getRuntimeTargetForWorktreeOwner, getRuntimeTargetForFileOwner and requireRuntimeTargetForFileOwner. They read the tab's stamped owner first, else the foundation's focus-free runtimeTargetForWorkspaceOwner (resolveOwner). The cases are:
      • No workspace, or a workspace with no row yet: this computer. Tabs and drops already record a server owner whenever there is one, so a missing row means a local file.
      • Rows that disagree: null. Callers with an error path refuse. Render paths treat it as "not this computer": editor and preview images get the readers' do-not-load context (runtimeContext: null, never undefined, which would read the image from this machine), and the rename folder picker and client-side file checks are turned off.
      • useFileOwnerRuntimeTarget is the hook version, with a value that stays stable across renders.
    • Callers that already had an owner now pass it as a target: the file-explorer operation route, getEditorFileOperationContext, native-chat image contexts, quick-open, MCP config, terminal drops, and the composer attachment upload.
    • The rich-markdown editor gets runtimeTarget in place of the whole settings object.
    • Deleted getEditorFileDropSettingsForWorktree and the native-chat "settings clone" cache. createFileSearchResultOwner now takes the owner id. createUntitledMarkdownFile takes a target.
    • Ratchets: owner-routing goes 209 → 173. The focus-read counter goes 1476 → 1232 on the current foundation baseline.

Why

Requiring a target means a raw settings object no longer compiles at a file call site. This is why the remaining wrong-host paths came to light; they would have stayed hidden otherwise.

Alternatives considered:

  • Keep the settings-shaped argument but build it only from owner helpers. Nothing would then stop the next caller from passing the setting directly.
  • Have each file client look up the owner from worktreeId itself. Worktree ids can repeat across hosts, and callers often already hold the exact owner, so this would sometimes pick a different host than the caller meant.

This PR changes about 1,450 lines; I kept it as one PR on purpose. Changing the type forces every caller to change at the same time, so it cannot be split into PRs that each still compile. About 690 of those lines are tests, almost all one-for-one settings: {...} → target: {...} swaps.

Linked Issue

None. This is part of the host-ownership routing stack (D4 G1, files area).

Visual Proof

N/A. Routing only; nothing on screen changes. The machine is load-capped, so the app wasn't launched.

Testing

  • I manually tested these changes locally

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

  • file-owner-runtime-target.test.ts:

    • The owner wins while another server is focused.
    • A row from before owner stamping, with a single saved and focused server, is now this computer. On main, getRuntimeEnvironmentIdForWorktree answers focused-env for that same state.
    • A stamped tab keeps its stamp.
    • A worktree with no row stays local.
    • Rows that disagree return null, and requireRuntimeTargetForFileOwner throws.
  • rich-markdown-image-context.test.ts: when the document's owner can't be resolved, image loading and preloading never call window.api.fs.readFile.

  • terminal-link-remote-runtime-ssh-open.test.ts: the test that expected a terminal link to follow the focused server now gives the workspace an owner (env-1) and focuses a different server (env-2). The link is read from env-1.

  • editor-dropped-file-open.test.ts: drops follow the worktree owner, not focus.

  • All other test edits update fixtures and assertions from settings to target, with no change in what they check.

  • Ran: pnpm tc:web, oxlint, oxfmt, pnpm run check:code-quality:changed, and pnpm check:owner-routing-ratchet (both OK). Also ran pnpm test over editor, right-sidebar, terminal-pane, runtime, native-chat, tab-bar, hooks, editor slice, browser-pane, floating-terminal, lib, settings, quick-open, store, sidebar, automations, agent, status-bar and web: about 36,600 tests pass. The one failure is ai-vault-session-worktree-map "builds the map at scale", a timing bound (208ms vs 150ms) that broke because the machine was loaded. It passes when run alone.

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

No wire change; renderer only. Direct SSH still goes through this app with connectionId. Folder workspaces resolve through the same owner resolver as before (getRuntimeEnvironmentIdForWorktree handles folder: keys). Windows path handling is 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)

@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: ad2bb621-a1c4-415f-9445-937396f1fd52

📥 Commits

Reviewing files that changed from the base of the PR and between 283c2aafd3c8378c0cea6a6a1ba88ed00fe88329 and 7a7daa9.


📒 Files selected for processing (3)
  • config/focus-setting-read-baseline.txt
  • config/owner-routing-baseline.txt
  • src/renderer/src/components/editor/rich-markdown-image-context.ts

💤 Files with no reviewable changes (1)
  • config/owner-routing-baseline.txt

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

Runtime file operations now receive explicit local or environment targets. New helpers resolve targets from file and worktree ownership. Runtime clients and renderer features pass those targets to file reads, writes, searches, imports, watches, previews, and related routing. Markdown image contexts distinguish unresolved ownership from the absence of a workspace. Tests and routing baselines now use the target-based contexts.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 7a7da

In the inspected paths, file operations use the file’s owner rather than the focused server, and unresolved image ownership does not trigger a local read. No actionable PR-introduced risk remains in the reviewed evidence; normal checks still apply.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 32.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 61 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: routing file reads and edits by file ownership instead of the focused server.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility notes, and checklist. It explicitly states that no linked issue exists, which is…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 32.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 61 files. (1 skipped: 1 unsupported.)


  • 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: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 341ca995-e0ae-4c59-b18d-97e94db1d56c
📥 Commits

Reviewing files that changed from the base of the PR and between 5c7c493 and 6a6e097312cd0df6b99fba5d7ce19dc517fcc4f9.

📒 Files selected for processing (157)
  • config/focus-setting-read-baseline.txt
  • config/owner-routing-baseline.txt
  • config/scripts/check-owner-routing-ratchet.mjs
  • config/scripts/check-owner-routing-ratchet.test.mjs
  • src/renderer/src/components/browser-pane/navigate/navigate-browser-page-url.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-document-actions.test.ts
  • src/renderer/src/components/editor/EditorPanel.tsx
  • src/renderer/src/components/editor/ExternalFileChangeBanner.tsx
  • src/renderer/src/components/editor/ExternalFileChangeCompareDialog.tsx
  • src/renderer/src/components/editor/MarkdownPreview.image-access.test.tsx
  • src/renderer/src/components/editor/MarkdownPreview.link-routing.interaction.test.tsx
  • src/renderer/src/components/editor/MarkdownPreview.toc-visibility-gate.test.tsx
  • src/renderer/src/components/editor/RichMarkdownEditor.tsx
  • src/renderer/src/components/editor/csv/CsvPagedViewer.tsx
  • src/renderer/src/components/editor/csv/csv-paged-preview.test.ts
  • src/renderer/src/components/editor/csv/useCsvPagedPreview.test.tsx
  • src/renderer/src/components/editor/editor-dropped-file-open.escaping-link.test.ts
  • src/renderer/src/components/editor/editor-dropped-file-open.test.ts
  • src/renderer/src/components/editor/editor-dropped-file-open.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts
  • src/renderer/src/components/editor/markdown-document-list-request.test.ts
  • src/renderer/src/components/editor/markdown-document-list-request.ts
  • src/renderer/src/components/editor/markdown-preview-link-actions.ts
  • src/renderer/src/components/editor/markdown-preview-local-images.test.ts
  • src/renderer/src/components/editor/restored-editor-workspace-runtime-owner.test.tsx
  • src/renderer/src/components/editor/rich-markdown-async-image-paste.test.ts
  • src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts
  • src/renderer/src/components/editor/rich-markdown-editor-config.test.ts
  • src/renderer/src/components/editor/rich-markdown-editor-config.ts
  • src/renderer/src/components/editor/rich-markdown-image-context.ts
  • src/renderer/src/components/editor/rich-markdown-image-insert.ts
  • src/renderer/src/components/editor/rich-markdown-large-text-paste.selection.test.ts
  • src/renderer/src/components/editor/rich-markdown-paste-image.ts
  • src/renderer/src/components/editor/use-editor-group-file-drop-owner.remote.test.tsx
  • src/renderer/src/components/editor/use-editor-group-file-drop-owner.test.tsx
  • src/renderer/src/components/editor/use-markdown-preview-source-foundation.ts
  • src/renderer/src/components/editor/useEditorPanelContentState.test.tsx
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/components/editor/useEditorPanelRemoteSiblingContentState.test.tsx
  • src/renderer/src/components/editor/useLocalImageSrc.test.ts
  • src/renderer/src/components/editor/useLocalImageSrc.ts
  • src/renderer/src/components/editor/useMarkdownDocuments.navigation.test.ts
  • src/renderer/src/components/editor/useMarkdownDocuments.ownership.test.tsx
  • src/renderer/src/components/editor/useMarkdownDocuments.ts
  • src/renderer/src/components/editor/useMarkdownDocuments.watch.test.ts
  • src/renderer/src/components/editor/useRichMarkdownEditorInstance.test.tsx
  • src/renderer/src/components/editor/useRichMarkdownProgrammaticSync.test.ts
  • src/renderer/src/components/editor/useRichMarkdownProgrammaticSync.ts
  • src/renderer/src/components/editor/useRichMarkdownReconcileRoundTrip.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.bounds.test.tsx
  • src/renderer/src/components/floating-terminal/use-floating-terminal-create-actions.ts
  • src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.test.tsx
  • src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptChrome.test.tsx
  • src/renderer/src/components/native-chat/native-chat-file-link-existence.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link-existence.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.test.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.ts
  • src/renderer/src/components/quick-open-file-list-remote-catalog.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/quick-open-file-navigation.test.ts
  • src/renderer/src/components/quick-open-file-navigation.ts
  • src/renderer/src/components/quick-open-recent-validation.test.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.actions.test.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-deletion-editors.ts
  • src/renderer/src/components/right-sidebar/file-explorer-directory-listing.ts
  • src/renderer/src/components/right-sidebar/file-explorer-instant-dir-toggle.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-generation.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-pane-state.ts
  • src/renderer/src/components/right-sidebar/useFileDeletion.ts
  • src/renderer/src/components/right-sidebar/useFileDuplicate.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerHandlers.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerImport.remote.test.tsx
  • src/renderer/src/components/right-sidebar/useFileExplorerImport.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerInlineInput.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerMoveDrop.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.ts
  • src/renderer/src/components/right-sidebar/useFileSearchPanel.lifecycle.test.tsx
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.test.tsx
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.ts
  • src/renderer/src/components/settings/McpConfigSection.host-owner.test.tsx
  • src/renderer/src/components/settings/McpConfigSection.tsx
  • src/renderer/src/components/settings/mcp-config-inspection.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-action.test.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-local-path.ts
  • src/renderer/src/components/terminal-pane/terminal-drop-handler.test.ts
  • src/renderer/src/components/terminal-pane/terminal-drop-runtime-catalog-owner.test.ts
  • src/renderer/src/components/terminal-pane/terminal-file-link-target.test.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-file-path-mapping.ts
  • src/renderer/src/components/terminal-pane/terminal-host-workspace-file.ts
  • src/renderer/src/components/terminal-pane/terminal-link-remote-runtime-ssh-open.test.ts
  • src/renderer/src/components/terminal-pane/terminal-native-file-drop-destination.ts
  • src/renderer/src/components/terminal-pane/terminal-native-file-drop.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-element-file-drop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-path-existence-batch.test.ts
  • src/renderer/src/components/terminal-pane/terminal-path-existence-batch.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-path-link.test.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-path-link.ts
  • src/renderer/src/hooks/composer-state/attachment-drop-state.ts
  • src/renderer/src/hooks/editor-external-watch-disk-verification.ts
  • src/renderer/src/hooks/editor-runtime-file-watch.test.ts
  • src/renderer/src/hooks/editor-runtime-file-watch.ts
  • src/renderer/src/lib/create-untitled-markdown.test.ts
  • src/renderer/src/lib/create-untitled-markdown.ts
  • src/renderer/src/lib/default-creation-host.test.ts
  • src/renderer/src/lib/default-creation-host.ts
  • src/renderer/src/lib/editor-file-operation-owner.test.ts
  • src/renderer/src/lib/editor-file-operation-owner.ts
  • src/renderer/src/lib/execute-open-editor-path-move.test.ts
  • src/renderer/src/lib/file-search-result-owner.test.ts
  • src/renderer/src/lib/file-search-result-owner.ts
  • src/renderer/src/lib/floating-workspace-tab-creation.ts
  • src/renderer/src/lib/floating-workspace-terminal-actions.test.ts
  • src/renderer/src/lib/local-file-access.ts
  • src/renderer/src/lib/markdown-document-templates.test.ts
  • src/renderer/src/lib/markdown-document-templates.ts
  • src/renderer/src/lib/rename-file.ts
  • src/renderer/src/lib/resolve-owner.test.ts
  • src/renderer/src/lib/resolve-owner.ts
  • src/renderer/src/lib/user-opened-local-path.test.ts
  • src/renderer/src/lib/workspace-file-host-routing.ts
  • src/renderer/src/lib/worktree-runtime-owner.test.ts
  • src/renderer/src/lib/worktree-runtime-owner.ts
  • src/renderer/src/runtime/mobile-markdown-bridge.ts
  • src/renderer/src/runtime/remote-host-file-open-repro.test.ts
  • src/renderer/src/runtime/runtime-client-target.test.ts
  • src/renderer/src/runtime/runtime-client-target.ts
  • src/renderer/src/runtime/runtime-file-client-download.test.ts
  • src/renderer/src/runtime/runtime-file-client-external-import.test.ts
  • src/renderer/src/runtime/runtime-file-client-mutation-ownership.test.ts
  • src/renderer/src/runtime/runtime-file-client-search-listing.test.ts
  • src/renderer/src/runtime/runtime-file-client-types.ts
  • src/renderer/src/runtime/runtime-file-client-watch.test.ts
  • src/renderer/src/runtime/runtime-file-client.test.ts
  • src/renderer/src/runtime/runtime-file-import-client.ts
  • src/renderer/src/runtime/runtime-file-import-pairing-revision.test.ts
  • src/renderer/src/runtime/runtime-file-metadata-client.ts
  • src/renderer/src/runtime/runtime-file-mutation-client.ts
  • src/renderer/src/runtime/runtime-file-range-client.test.ts
  • src/renderer/src/runtime/runtime-file-range-client.ts
  • src/renderer/src/runtime/runtime-file-read-client.ts
  • src/renderer/src/runtime/runtime-file-routing.ts
  • src/renderer/src/runtime/runtime-file-search-client.ts
  • src/renderer/src/runtime/runtime-file-watch-client.ts
  • src/renderer/src/runtime/runtime-legacy-recent-freshness.test.ts
  • src/renderer/src/runtime/runtime-path-existence-batch.test.ts
  • src/renderer/src/runtime/runtime-path-existence-error-parity.test.ts
  • src/renderer/src/runtime/runtime-path-existence-pairing.test.ts
  • src/renderer/src/runtime/runtime-path-existence-queue-pairing.test.ts
  • src/renderer/src/runtime/runtime-quick-open-version-compatibility.test.ts
  • src/renderer/src/runtime/use-worktree-runtime-target.ts
  • src/renderer/src/store/slices/editor/actions/markdown-link-action.ts
  • src/renderer/src/store/slices/editor/actions/markdown-preview-actions.ts
💤 Files with no reviewable changes (3)
  • src/renderer/src/components/editor/rich-markdown-editor-click-routing.ts
  • config/owner-routing-baseline.txt
  • src/renderer/src/components/terminal-pane/terminal-native-file-drop-destination.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 +30 to +31
const SETTING_MEMBER_READ =
/\??\.\s*activeRuntimeEnvironmentId\b|(?<!(?:\b[A-Z][\w$]*|>)\s*)\[\s*['"]activeRuntimeEnvironmentId['"]\s*\]/g

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

Exclude plain setting assignments from read counts.

If code assigns settings.activeRuntimeEnvironmentId = id, SETTING_MEMBER_READ counts the assignment as a read. A new setting write can therefore fail the focus-setting ratchet without adding a focus read. Exclude plain = assignments for both member and element access, while retaining compound assignments that read the old value.

Comment on lines +35 to +36
const SETTING_DESTRUCTURE_READ =
/\{[^{}]*\bactiveRuntimeEnvironmentId\b[^{}]*\}(?:\s*\})*\s*(?::[^=;{}]*)?=(?![=>])/g

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

Count parenthesized destructuring assignments.

If code uses ({ activeRuntimeEnvironmentId } = settings), the ) between } and = prevents a match. The ratchet then accepts a new setting read without counting it. Cover this assignment form and add a matching test.

Comment on lines +82 to +86
for (const { name, exported, text: body } of topLevelDeclarations(
text.replace(IMPORT_EXPORT_LIST, '')
)) {
seedUse.lastIndex = 0
if (exported && (countSettingReads(body) > 0 || seedUse.test(body))) {

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

Discover readers exported in a separate statement.

If a file declares function selectHost(settings) { return settings.activeRuntimeEnvironmentId } and later uses export { selectHost }, exported remains false. Calls to selectHost in other renderer files then contribute zero to their focus-setting counts. Resolve local export lists when building the reader set, and test a separately exported reader.

@OrcaWin
OrcaWin force-pushed the OrcaWin/d4-g1-files branch 2 times, most recently from f3d000a to 283c2aa Compare October 10, 2026 17:36

@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: 493aad20-fa59-4595-ae8f-9c7601213099
📥 Commits

Reviewing files that changed from the base of the PR and between 6a6e097312cd0df6b99fba5d7ce19dc517fcc4f9 and 283c2aafd3c8378c0cea6a6a1ba88ed00fe88329.

📒 Files selected for processing (38)
  • config/focus-setting-read-baseline.txt
  • src/renderer/src/components/browser-pane/navigate/navigate-browser-page-url.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-document-actions.test.ts
  • src/renderer/src/components/editor/EditorPanel.tsx
  • src/renderer/src/components/editor/ExternalFileChangeBanner.tsx
  • src/renderer/src/components/editor/ExternalFileChangeCompareDialog.tsx
  • src/renderer/src/components/editor/MarkdownPreview.image-access.test.tsx
  • src/renderer/src/components/editor/MarkdownPreview.link-routing.interaction.test.tsx
  • src/renderer/src/components/editor/MarkdownPreview.toc-visibility-gate.test.tsx
  • src/renderer/src/components/editor/editor-dropped-file-open.escaping-link.test.ts
  • src/renderer/src/components/editor/editor-dropped-file-open.test.ts
  • src/renderer/src/components/editor/editor-dropped-file-open.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts
  • src/renderer/src/components/editor/markdown-preview-link-actions.ts
  • src/renderer/src/components/editor/markdown-preview-local-images.ts
  • src/renderer/src/components/editor/rich-markdown-editor-config.ts
  • src/renderer/src/components/editor/rich-markdown-extensions.ts
  • src/renderer/src/components/editor/rich-markdown-image-context.test.ts
  • src/renderer/src/components/editor/rich-markdown-image-context.ts
  • src/renderer/src/components/editor/rich-markdown-image-insert.ts
  • src/renderer/src/components/editor/rich-markdown-paste-image.ts
  • src/renderer/src/components/editor/use-editor-group-file-drop-owner.test.tsx
  • src/renderer/src/components/editor/use-markdown-preview-source-foundation.ts
  • src/renderer/src/components/editor/useEditorPanelContentState.test.tsx
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/components/editor/useEditorPanelRemoteSiblingContentState.test.tsx
  • src/renderer/src/components/editor/useMarkdownDocuments.navigation.test.ts
  • src/renderer/src/components/editor/useMarkdownDocuments.ts
  • src/renderer/src/components/editor/useMarkdownDocuments.watch.test.ts
  • src/renderer/src/components/editor/useRichMarkdownProgrammaticSync.ts
  • src/renderer/src/components/terminal-pane/terminal-file-path-mapping.ts
  • src/renderer/src/lib/file-owner-runtime-target.test.ts
  • src/renderer/src/lib/file-owner-runtime-target.ts
  • src/renderer/src/lib/local-file-access.ts
  • src/renderer/src/lib/workspace-file-host-routing.ts
  • src/renderer/src/runtime/mobile-markdown-bridge.ts
  • src/renderer/src/runtime/runtime-client-target.ts
  • src/renderer/src/runtime/use-worktree-runtime-target.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.

m4air added 5 commits October 10, 2026 10:58
The runtime file clients took a settings object and turned its Active Server
field into a connection, so any caller that passed raw settings silently read
or wrote on the focused server. They now take `target: RuntimeClientTarget`,
and every caller derives it from the owner: the tab's stamped owner, else its
worktree's owner (getRuntimeTargetForFileOwner / getRuntimeTargetForWorktreeOwner),
the file-explorer operation owner, or an already captured owner id.

Behavior: single-host (local-only) users see no change. An editor tab opened
without an owner stamp, a terminal link with no PTY owner, an OS file drop and
a notebook link now go to the workspace's owner instead of whichever server is
focused when the read happens.

Removes getEditorFileDropSettingsForWorktree and the native-chat settings clone
cache; settingsForWorktreeOperationRoute loses its editor caller.
…server

getRuntimeTargetForWorktreeOwner/getRuntimeTargetForFileOwner move to
lib/file-owner-runtime-target.ts and resolve through the focus-free
resolveOwner. A workspace with no row yet stays on this app (tabs and drops
stamp a server owner when one exists); rows that disagree return null, and
callers with an error path refuse via requireRuntimeTargetForFileOwner.
A null owner target became runtimeContext undefined, which image readers take
as a plain local file, so a server-owned document's images were read from this
machine. It is now runtimeContext null, the readers' do-not-load sentinel, in
the rich editor and the preview, and prewarm skips it.
@OrcaWin
OrcaWin force-pushed the OrcaWin/d4-g1-files branch from edfb648 to 7a7daa9 Compare October 10, 2026 18:01
@OrcaWin
OrcaWin merged commit 7de3710 into main Oct 10, 2026
38 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.

1 participant