Skip to content

fix(ci): route the worktree ready toast's host check by its owner, not the Active Server setting - #28265

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-focus-read-worktree-toast
Oct 13, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-focus-read-worktree-toast

Conversation

@nwparker

@nwparker nwparker commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

Main's CI is red for every PR. The "worktree is ready" notification asked "which server is selected in settings?" to decide whether you are already looking at the new worktree. A repo guard forbids that question in new code; it must ask "which host owns this worktree?" instead. This PR makes it ask the owner.

What Changed

src/renderer/src/lib/worktree-creation-ready-toast.tsx: the check that dismisses the ready notification once you open the new workspace now compares against the open workspace's own host (activeWorkspaceExecutionHostId), falling back to the host recorded on the worktree/repo row (getResolvedExecutionHostIdForWorktree). Previously it used getKnownExecutionHostIdForWorktree, whose last fallback reads the Active Server setting.

For users nothing changes in the normal cases: the notification still disappears when you open the workspace on its host and stays when the same id is open on another host. The only difference is the edge case where neither the open workspace nor its rows name a host: we now use the row's default (local) instead of whichever server happens to be selected in settings.

Why

#28238 added one focus read to a file the focus-read ratchet allows zero for, breaking "static analysis and typecheck" on main. The ratchet's documented remedy is routing by the resource's owner (only row-less creation flows may use defaultCreationHost); this toast has a worktree row, so owner routing is correct. Bumping the baseline would re-legitimize the pattern the ratchet exists to remove.

Linked Issue

None — fixes main CI broken by #28238.

Visual Proof

N/A — no visual change; only which host the dismiss check compares against.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Added a test: with the Active Server setting pointing at a remote, opening a worktree whose rows name no host still dismisses its local ready notification. pnpm check:focus-read-ratchet, pnpm tc, the two ready-toast test files, oxlint and check:code-quality:changed pass locally (macOS).

AI Disclosure

Review

Agent skill upstream boundary

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

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)

The ready toast added in #28238 read the Active Server setting through
getKnownExecutionHostIdForWorktree, which the focus-read ratchet rejects,
so every PR's static-analysis job failed on main.
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The toast host check now uses activeWorkspaceExecutionHostId when available. Otherwise, it resolves the active worktree host with getResolvedExecutionHostIdForWorktree. A regression test covers an unqualified worktree selection when the Active Server setting is remote-a.

Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: 🔵 Low · up to 24b47

A restored runtime workspace may leave its ready toast onscreen after opening. This is a localized notification issue, but the host lookup should be corrected.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: routing the worktree-ready toast host check by the worktree owner instead of the Active Server setting.
Description check Passed The description follows the required structure and explains the user impact, implementation, rationale, testing, and scope. It states that no linked issue exists and that manual testing was not perfor…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • 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: db2a5854-3a29-4ae2-832b-51763077e3dc
📥 Commits

Reviewing files that changed from the base of the PR and between 8cd5bb2 and 24b470f.

📒 Files selected for processing (2)
  • src/renderer/src/lib/worktree-creation-ready-toast.test.tsx
  • src/renderer/src/lib/worktree-creation-ready-toast.tsx

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

Comment on lines 35 to +39
executionHostId !== null &&
(executionHostId === undefined ||
getKnownExecutionHostIdForWorktree(state, state.activeWorktreeId) === executionHostId)
// Owner rows only: the Active Server setting never says which host's workspace is open.
(state.activeWorkspaceExecutionHostId ??
getResolvedExecutionHostIdForWorktree(state, state.activeWorktreeId)) === executionHostId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- toast at merge base ---'
git show 8cd5bb2a742f778c520b37f6542ec0d6c6b6fb54:src/renderer/src/lib/worktree-creation-ready-toast.tsx | nl -ba | sed -n '1,90p'
printf '%s\n' '--- toast at reviewed head ---'
git show 24b470fcaf5c185173e95d058113044557de3869:src/renderer/src/lib/worktree-creation-ready-toast.tsx | nl -ba | sed -n '1,90p'
printf '%s\n' '--- resolved host helper ---'
sed -n '1,150p' src/renderer/src/lib/resolved-worktree-execution-host.ts
printf '%s\n' '--- placeholder hydration ---'
sed -n '1,130p' src/renderer/src/store/terminals/workspace-terminal-placeholders.ts
printf '%s\n' '--- workspace host hydration ---'
sed -n '70,130p' src/renderer/src/store/terminals/workspace-terminal-hydration.ts
sed -n '80,130p' src/renderer/src/lib/workspace-session-host-hydration.ts
printf '%s\n' '--- ready-toast references and tests ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'showWorktreeCreationReadyToast' -e 'getResolvedExecutionHostIdForWorktree' -e 'activeWorkspaceExecutionHostId' src/renderer/src | head -160

Repository: stablyai/orca

Length of output: 43302


🏁 Script executed:

set -eu
printf '%s\n' '--- old known-host helper ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'function getKnownExecutionHostIdForWorktree' -e 'getKnownExecutionHostIdForWorktree' src/renderer/src
printf '%s\n' '--- helper implementation ---'
sed -n '1,180p' src/renderer/src/lib/worktree-runtime-owner.ts
printf '%s\n' '--- resolved-host tests ---'
sed -n '1,150p' src/renderer/src/lib/resolved-worktree-execution-host.test.ts
printf '%s\n' '--- ready-toast tests ---'
sed -n '1,260p' src/renderer/src/lib/worktree-creation-ready-toast.test.tsx
printf '%s\n' '--- owner state ---'
sed -n '1,140p' src/renderer/src/lib/worktree-runtime-owner-state.ts
printf '%s\n' '--- restored owner map references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'restoredRuntimeHostIdByWorkspaceSessionKey' -e 'runtimeHostIdByWorkspaceSessionKey' src/renderer/src/lib src/renderer/src/store | head -120

Repository: stablyai/orca

Length of output: 41940


🏁 Script executed:

set -eu
printf '%s\n' '--- complete known-host helper target ---'
sed -n '170,270p' src/renderer/src/lib/worktree-runtime-owner.ts
printf '%s\n' '--- known-host tests around target ---'
sed -n '600,675p' src/renderer/src/lib/worktree-runtime-owner.test.ts
printf '%s\n' '--- owner-map key construction ---'
rg -n -F --glob '*.ts' -e 'function addWorkspaceSessionKeyForOwnerMap' -e 'addWorkspaceSessionKeyForOwnerMap' src/renderer/src/lib/workspace-session-host-hydration.ts
sed -n '1,95p' src/renderer/src/lib/workspace-session-host-hydration.ts
printf '%s\n' '--- hydration output and map assignment ---'
sed -n '150,185p' src/renderer/src/store/terminals/workspace-terminal-hydration.ts
sed -n '230,260p' src/renderer/src/lib/workspace-session-host-hydration.ts
printf '%s\n' '--- current PR diff for implicated files ---'
git diff --stat 8cd5bb2a742f778c520b37f6542ec0d6c6b6fb54 24b470fcaf5c185173e95d058113044557de3869 -- src/renderer/src/lib/worktree-creation-ready-toast.tsx src/renderer/src/lib/resolved-worktree-execution-host.ts src/renderer/src/store/terminals/workspace-terminal-placeholders.ts
git diff --unified=30 8cd5bb2a742f778c520b37f6542ec0d6c6b6fb54 24b470fcaf5c185173e95d058113044557de3869 -- src/renderer/src/lib/worktree-creation-ready-toast.tsx src/renderer/src/lib/resolved-worktree-execution-host.ts

Repository: stablyai/orca

Length of output: 16800


🏁 Script executed:

set -eu
printf '%s\n' '--- ready-toast callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' 'showWorktreeCreationReadyToast(' src/renderer/src
printf '%s\n' '--- resolver with line numbers ---'
nl -ba src/renderer/src/lib/resolved-worktree-execution-host.ts | sed -n '65,105p'
printf '%s\n' '--- owner-map normalization declaration ---'
rg -n -F --glob '*.ts' 'function normalizeWorkspaceSessionKeyToWorktreeId' src/renderer/src shared src

Repository: stablyai/orca

Length of output: 4853


🏁 Script executed:

set -eu
nl -ba src/renderer/src/lib/worktree-creation-flow-execute.ts | sed -n '270,330p'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'creationHostId' -e 'worktree-creation-flow-execute' src/renderer/src/lib/worktree-creation-flow-execute.ts | head -40

Repository: stablyai/orca

Length of output: 2632


Resolve restored git-worktree ownership before the catalog fallback.

When a restored runtime workspace has no activeWorkspaceExecutionHostId, an equal-ID local catalog row prevents runtime placeholder insertion. The fallback then resolves the active worktree as local, so the runtime ready toast can remain visible after the matching workspace opens. The base helper used the focused Active Server fallback, which could instead dismiss the toast for the wrong host. Use the restored owner map at the resolver boundary.

Suggested fix
diff --git a/src/renderer/src/lib/resolved-worktree-execution-host.ts b/src/renderer/src/lib/resolved-worktree-execution-host.ts
@@
   const worktree = preferredHostId
     ? findIndexedWorktreeOwnerForHost(state.worktreesByRepo, worktreeId, preferredHostId)
     : findIndexedWorktreeOwner(state.worktreesByRepo, worktreeId)
+  const restoredHost = parseExecutionHostId(
+    state.restoredRuntimeHostIdByWorkspaceSessionKey?.[worktreeId]
+  )
+  if (restoredHost?.kind === 'runtime') {
+    return restoredHost.id
+  }
   const worktreeHost = parseExecutionHostId(worktree?.hostId)

@nwparker
nwparker merged commit 4857afd into main Oct 13, 2026
50 of 53 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