Repository navigation
fix(ci): route the worktree ready toast's host check by its owner, not the Active Server setting - #28265
Conversation
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.
📝 Walkthrough
Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
db2a5854-3a29-4ae2-832b-51763077e3dc
📒 Files selected for processing (2)
src/renderer/src/lib/worktree-creation-ready-toast.test.tsxsrc/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.
| 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) |
There was a problem hiding this comment.
🎯 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 -160Repository: 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 -120Repository: 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.tsRepository: 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 srcRepository: 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 -40Repository: 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)
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 usedgetKnownExecutionHostIdForWorktree, 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
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 andcheck:code-quality:changedpass locally (macOS).AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)