Skip to content

refactor(renderer): fold 13 sidebar, hook and chat readers off the deprecated owner resolver, and count the adapter as a focus read - #30478

Merged
nwparker merged 1 commit into
mainfrom
nwparker/r3-f2-right-sidebar-folds
Oct 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/r3-f2-right-sidebar-folds

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

ELI5

Thirteen places in the right sidebar, the editor watcher, native chat links and the doc-page preview asked an old helper "which server owns this workspace?". That helper is being retired. They now ask the replacement, which gives the same answer everywhere except for a few shapes the old one got wrong.

What Changed

  • The Files explorer (reveal, Open in), the Source Control entry menu, the Checks panel, the git-status file watch, file search, the editor's external-change watcher, the browser link-open bridge, terminal input platform detection, the native-chat link owners and the workspace doc page read their owner through runtimeEnvironmentIdWithLegacyFallbackUnlessTwin instead of the deprecated getRuntimeEnvironmentIdForWorktree (callers Add Ctrl+Click to open links in terminal #4, Fix PTY listener leak, use local restty with selection support #5 and Add card gap and quick-create in worktree dialog #10–P2-xs: we should add a “add new repo” button at the end of the “select repo” dropdown #20 in the round-3 classification).
  • User-visible changes, all deliberate (round-3 design §3–§5):
    • A folder workspace that two hosts publish (or whose project group two hosts publish) no longer follows the focused server. It reads as "no server", as repo twins already did.
    • Two paired servers proxying the same SSH host (or a server row contradicting a direct one) read as "no server" instead of picking one.
    • A worktree whose only repo row is a paired server proxying its SSH target now routes its reads through that server.
    • File search refuses to run for a workspace two hosts publish, and shows no results, instead of searching whichever copy happened to be picked.
  • Everything else, including rows that carry no host stamp, keeps the old answer (the adapter reproduces the legacy focused-runtime branch for those).
  • Focus-read ratchet: discovery skipped resolveOwnerWithLegacyFallback because its focused-runtime answer is returned inside an object literal. It is now a seed, so the adapter and every wrapper that returns its result count as focus reads. The five entries that refactor(renderer): fold four lib callers off the deprecated runtime-owner resolver #30458 pruned through that blind spot come back, annotated; F8 removes them when it deletes the legacy branch.
  • runtimeEnvironmentIdWithLegacyFallbackUnlessTwin accepts a null workspace id (no active workspace) and returns null, as the deprecated helper did.
  • Deprecated-resolver importers: 53 → 40.

Why

The deprecated resolver collapses "two hosts publish this" into "local" and guesses with the focused server. The replacement keeps both as distinct answers. Using the "unless twin" wrapper here keeps each reader's old meaning for a twin ("no server"), so only the rows the design marks as deliberate change. File search was the one reader where "no server" still meant "show results from some host", so it refuses instead. Counting the adapter in the focus ratchet stops the folds from looking like focus reads were removed when they were only hidden.

Linked Issue

Round 3 of the SSH/remote hardening (S6(b) F2+F3). No single issue.

Visual Proof

N/A: routing-only change with no new UI; the only visible difference is that file search shows nothing for a workspace published by two hosts.

Testing

  • New: file search does not run for a twin workspace (fails before); focus ratchet discovers a wrapper around the adapter.

  • pnpm test single worker over src/renderer/src/components/right-sidebar, src/renderer/src/lib, src/renderer/src/hooks, components/native-chat, components/terminal-pane, components/browser-pane and the ratchet tests.

  • Full local copy of the pr.yml static job.

  • ssh-orcad Docker lane dispatched on the exact head (link in a comment).

  • Live verification: unit-tested only. The changes are read-routing folds whose live paths the ssh-orcad lane covers.

  • I manually tested these changes locally

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

AI Disclosure

Review

Codex (gpt-6.1-sol, high): no findings.

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: the deliberate changes are exactly the twin, rival-server and stale-server-stamp rows of the round-3 acceptance table. Wire: none. Cross-platform: none.

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)

…-page readers off the deprecated owner resolver

Thirteen read-routing callers (#4, #5, #10-#20 of the round-3 caller list) read the owner through
runtimeEnvironmentIdWithLegacyFallbackUnlessTwin. A workspace two hosts publish is no longer
searched on either host. The focus-read ratchet now counts the legacy-fallback adapter, which
reads the focused runtime inside an object literal its discovery skipped; the five F1 entries
that blind spot pruned come back. Deprecated importers 53 -> 40.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Renderer consumers now resolve runtime environment IDs with runtimeEnvironmentIdWithLegacyFallbackUnlessTwin. The helper returns null when the workspace ID is absent. File search clears results and stops loading when ownership is ambiguous. Related tests and ratchet baselines are updated.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 36aee

Search results can remain visible when a workspace gains a conflicting host. The impact is limited to stale results, but the ownership transition should clear them and cancel an active search.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description clearly explains the scope, behavior changes, rationale, testing, and checklist status. However, the required Linked Issue section does not contain an actual issue link, and results fo… Add an actual linked issue under “Fixes #” or provide the required maintainer rationale. Report whether pnpm lint, pnpm typecheck, and pnpm build passed or will be covered by CI.
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 23 files. (1 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 identifies the main refactor: migrating renderer readers from the deprecated owner resolver and adding the adapter to focus-read tracking.
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: Description check

Explanation

The description clearly explains the scope, behavior changes, rationale, testing, and checklist status. However, the required Linked Issue section does not contain an actual issue link, and results for lint, typecheck, and build are not reported.

Resolution

Add an actual linked issue under “Fixes #” or provide the required maintainer rationale. Report whether pnpm lint, pnpm typecheck, and pnpm build passed or will be covered by CI.

Full details: Docstring Coverage

Explanation

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

Resolution

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

  • 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: fb894b31-6d2c-4a78-9dc5-1d83d9e3faf0
📥 Commits

Reviewing files that changed from the base of the PR and between 613c598 and 36aee92.

📒 Files selected for processing: 25
  • config/deprecated-runtime-owner-importers-baseline.txt
  • config/focus-setting-read-baseline.txt
  • config/scripts/check-focus-read-ratchet.mjs
  • config/scripts/check-focus-read-ratchet.test.mjs
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-deferred-lifecycle.test.tsx
  • src/renderer/src/components/browser-pane/workspace-doc/workspace-doc-page-pane.test.tsx
  • src/renderer/src/components/browser-pane/workspace-doc/workspace-doc-page-pane.tsx
  • src/renderer/src/components/native-chat/native-chat-file-link.ts
  • src/renderer/src/components/native-chat/native-chat-http-link-source-owner.test.ts
  • src/renderer/src/components/native-chat/native-chat-http-link-source-owner.ts
  • src/renderer/src/components/right-sidebar/FileExplorer.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-row-context-menu.tsx
  • src/renderer/src/components/right-sidebar/git-status-file-watch-refresh.ts
  • src/renderer/src/components/right-sidebar/source-control-entry-context-menu.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/listing/entry-context-menu.tsx
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.test.tsx
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.ts
  • src/renderer/src/components/right-sidebar/useFileSearchScope.ts
  • src/renderer/src/components/terminal-pane/terminal-input-host-platform.ts
  • src/renderer/src/hooks/editor-external-watch-targets.ts
  • src/renderer/src/hooks/ipc-events/browser-state-capture-paint-hold.test.ts
  • src/renderer/src/hooks/ipc-events/browser-state-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/browser-state-open-link-profile.test.ts
  • src/renderer/src/lib/worktree-runtime-owner.ts
💤 Files with no reviewable changes: 1
  • config/deprecated-runtime-owner-importers-baseline.txt

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

Comment on lines +54 to +58
const ownerIsTwin = useAppStore(
(state) =>
!!activeWorktreeId &&
resolveOwner(state, { workspaceId: activeWorktreeId }).kind === 'ambiguous'
)

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:

sed -n '65,225p' src/renderer/src/components/right-sidebar/useFileSearchRunner.ts
sed -n '1,120p' src/renderer/src/components/right-sidebar/useFileSearchScope.ts

Repository: stablyai/orca

Length of output: 7639


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- runner ---'
nl -ba src/renderer/src/components/right-sidebar/useFileSearchRunner.ts | sed -n '1,240p'
printf '%s\n' '--- search state symbols ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
  -e 'updateActiveSearchState' \
  -e 'fileSearchStateByWorktree' \
  -e 'seedRequestId' \
  -e 'executeSearch(' \
  src/renderer/src | sed -n '1,240p'
printf '%s\n' '--- relevant state declarations ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
  -e 'FileSearchState' \
  -e 'fileSearchStateByWorktree:' \
  -e 'setFileSearch' \
  src/renderer/src | sed -n '1,200p'

Repository: stablyai/orca

Length of output: 34644


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- panel ---'
nl -ba src/renderer/src/components/right-sidebar/useFileSearchPanel.ts | sed -n '1,340p'
printf '%s\n' '--- state action ---'
nl -ba src/renderer/src/store/slices/editor/actions/file-search-actions.ts | sed -n '1,135p'
printf '%s\n' '--- lifecycle tests ---'
nl -ba src/renderer/src/components/right-sidebar/useFileSearchPanel.lifecycle.test.tsx | sed -n '1,220p'
printf '%s\n' '--- runner tests around cancellation and twin ---'
nl -ba src/renderer/src/components/right-sidebar/useFileSearchRunner.test.tsx | sed -n '300,430p'

Repository: stablyai/orca

Length of output: 32583


Cancel the active search when ownership becomes ambiguous.

An in-flight search can finish after ownerIsTwin becomes true. Existing results remain current, so the scope hook does not cancel the search. Its completion can then publish visible results for a twin workspace, violating the no-results behavior.

This is a narrow stale-results issue. The inspected click path preserves the saved result owner, so no wrong-owner action is established.

🐛 Suggested fix
   useEffect(
     () => cancelPendingSearch,
     [cancelPendingSearch, worktreePath, executionHostId, runtimeEnvironmentId]
   )
+
+  useEffect(() => {
+    if (!ownerIsTwin) {
+      return
+    }
+    cancelPendingSearch()
+    updateActiveSearchState({ results: null, resultOwner: null, error: null })
+  }, [ownerIsTwin, cancelPendingSearch, updateActiveSearchState])
 
   return { executeSearch, cancelPendingSearch }

@nwparker

Copy link
Copy Markdown
Contributor Author

Codex (gpt-6.1-sol, high) on 36aee92: no findings. pr.yml 39186155917 success; ssh-orcad Docker lane (e2e.yml dispatch, all tests/e2e/ssh-orcad-* specs) 39186109625 success on the exact head. Local static job: 0 failures. Units: 2,240 files single-worker (right-sidebar, lib, hooks, native-chat, terminal-pane, browser-pane).

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