Repository navigation
[hardening 4/5] fix(sidebar): confirm before sleeping a workspace that another host's copy shares - #30047
Conversation
e3625de to
7c3cf40
Compare
73239d0 to
53aaf9e
Compare
871fab9 to
65689bf
Compare
436045b to
ef28e88
Compare
65689bf to
59fda1b
Compare
135c6fa to
516f433
Compare
516f433 to
9cabc62
Compare
9732228 to
81fd4e5
Compare
9cabc62 to
acee149
Compare
858e871 to
98a5426
Compare
acee149 to
75a8c16
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · 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:
194981e4-052e-4755-a2a6-70f605e9ec2b
📒 Files selected for processing: 19
src/renderer/src/components/sidebar/SleepTwinWorkspaceDialog.tsxsrc/renderer/src/components/sidebar/index.tsxsrc/renderer/src/components/sidebar/sleep-failure-message.tssrc/renderer/src/components/sidebar/sleep-twin-confirmation.test.tssrc/renderer/src/components/sidebar/sleep-twin-confirmation.tssrc/renderer/src/components/sidebar/sleep-worktree-flow.test.tssrc/renderer/src/components/sidebar/sleep-worktree-flow.tssrc/renderer/src/components/sidebar/use-worktree-context-menu-commands.tssrc/renderer/src/components/sidebar/use-worktree-context-menu-model.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/host-twin-isolation.test.tssrc/renderer/src/store/repos/host-twin-terminal-evidence.tssrc/renderer/src/store/repos/repo-removal-host-twin-attribution.tssrc/renderer/src/store/slices/ui/ui-slice-contract-contextual.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| const handleConfirm = useCallback(() => { | ||
| closeModal() | ||
| void runSleepWorktrees(worktreeIds) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
sed -n '120,225p' src/renderer/src/components/sidebar/sleep-worktree-flow.ts
sed -n '155,205p' src/renderer/src/store/host-twin-isolation.test.ts
rg -n 'collectTwinPurgeScopes|sleepWorktree|hasWorktreeSleepIntent|shutdownTerminalsForWorktree' src/renderer/src/components/sidebar/sleep-worktree-flow.ts src/renderer/src/store src/renderer/src/lib | head -130Repository: stablyai/orca
Length of output: 10016
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- dialog and callers ---'
sed -n '1,125p' src/renderer/src/components/sidebar/SleepTwinWorkspaceDialog.tsx
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'confirm-sleep-twin' -e 'SleepTwinWorkspaceDialog' -e 'runSleepWorktrees(' -e 'openModal' src/renderer/src/components/sidebar src/renderer/src/store src/renderer/src/lib | head -220
printf '%s\n' '--- sleep flow and terminal teardown ---'
sed -n '1,125p' src/renderer/src/components/sidebar/sleep-worktree-flow.ts
sed -n '125,225p' src/renderer/src/components/sidebar/sleep-worktree-flow.ts
sed -n '1,220p' src/renderer/src/store/terminals/terminal-shutdown.ts
printf '%s\n' '--- purge and sleep-intent consumers ---'
sed -n '1,280p' src/renderer/src/store/host-twin-worktree-purge.test.ts
sed -n '1,150p' src/renderer/src/store/terminals/terminal-pty-release.ts
sed -n '1,130p' src/renderer/src/lib/worktree-sleep-intent.ts
printf '%s\n' '--- browser shutdown ---'
sed -n '220,285p' src/renderer/src/store/slices/browser/browser-close-actions.tsRepository: stablyai/orca
Length of output: 43605
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- exact definitions and consumers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'type Modal' -e 'confirm-sleep-twin' -e 'SleepTwinWorkspaceDialog' -e 'runSleepWorktrees' -e 'shutdownWorktreeTerminals' -e 'purgeWorktreeTerminalState' -e 'browserTabsByWorktree' src/renderer/src/components/sidebar src/renderer/src/store src/renderer/src/lib | head -260
printf '%s\n' '--- dialog ---'
sed -n '1,110p' src/renderer/src/components/sidebar/SleepTwinWorkspaceDialog.tsx
printf '%s\n' '--- sleep flow ---'
sed -n '90,225p' src/renderer/src/components/sidebar/sleep-worktree-flow.ts
printf '%s\n' '--- terminal shutdown owner and implementation ---'
sed -n '1,260p' src/renderer/src/store/terminals/terminal-shutdown.ts
sed -n '1,220p' src/renderer/src/store/terminals/terminal-teardown-owner.ts
printf '%s\n' '--- browser close implementation ---'
sed -n '220,285p' src/renderer/src/store/slices/browser/browser-close-actions.ts
printf '%s\n' '--- purge implementation and relevant tests ---'
rg -n -F --glob '*.ts' -e 'purgeWorktreeTerminalState' -e 'hostWorktreeTarget' -e 'survivorStopped' src/renderer/src/store | head -120
sed -n '1,120p' src/renderer/src/store/host-twin-worktree-purge.test.tsRepository: stablyai/orca
Length of output: 42914
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- dialog and callers ---'
sed -n '1,125p' src/renderer/src/components/sidebar/SleepTwinWorkspaceDialog.tsx
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'confirm-sleep-twin' -e 'SleepTwinWorkspaceDialog' -e 'runSleepWorktrees(' -e 'openModal' src/renderer/src/components/sidebar src/renderer/src/store src/renderer/src/lib | head -220
printf '%s\n' '--- sleep flow ---'
sed -n '90,225p' src/renderer/src/components/sidebar/sleep-worktree-flow.ts
printf '%s\n' '--- terminal shutdown ---'
rg -n -F --glob '*.ts' -e 'shutdownWorktreeTerminals' -e 'purgeWorktreeTerminalState' src/renderer/src/store | head -120
sed -n '1,260p' src/renderer/src/store/terminals/terminal-shutdown.ts
printf '%s\n' '--- browser shutdown ---'
sed -n '220,285p' src/renderer/src/store/slices/browser/browser-close-actions.ts
printf '%s\n' '--- sleep intent ---'
sed -n '1,130p' src/renderer/src/lib/worktree-sleep-intent.tsRepository: stablyai/orca
Length of output: 42898
Recheck the affected hosts before confirming workspace sleep.
SleepTwinWorkspaceDialog uses hostIds only for the message. Confirmation passes raw worktreeIds to runSleepWorktrees. That flow can stop live PTYs from a newly published host and suspend the shared workspace without renewed confirmation.
Recalculate the affected hosts before teardown. If the host set changed, request confirmation for the new scope. Keep the final teardown workspace-wide after consent; replacing it with host-qualified targets would break the intended shared-workspace behavior.
Stack (unmerged, for review): 1/5 #30030 → 2/5 #30035 → 3/5 #30059 → 4/5 this PR → 5/5 #30060.
ELI5
The same project folder can be open twice in Orca: once on this computer and once on a remote machine. Both copies share one workspace. Putting either copy to sleep puts the whole workspace to sleep, as it does on main today. Now Orca asks first when you picked only one of the two copies, so you aren't surprised when the other copy sleeps too.
What Changed
Before: in the sidebar, "Sleep" on one copy of a workspace that two hosts publish silently stopped the other copy's shells and agents as well.
After:
Mechanism:
sleep-twin-confirmation.tsfinds the copies the selection leaves out, using the twin detection added in fix(worktrees): a host-scoped purge leaves a surviving twin's tabs and edits alone #30030 (collectHostTwinPurgeScopes). The sidebar's sleep command opens the newconfirm-sleep-twindialog (SleepTwinWorkspaceDialog.tsx) only when there are such copies.sleepWorktreesReportingFailuresremoves duplicate worktree ids before any teardown, so a workspace selected through both copies sleeps once.store/repos/host-twin-terminal-evidence.ts, which [hardening 5/N] refactor(projects): shrink twin-removal teardown to the attributed close actions #30060 uses.sleep-failure-message.tsholds the failure text, including the newambiguous_terminal_ownermessage.Twin suite: the kill, sleep and select cells now assert the documented whole-workspace behaviour (user decision 2026-10-17):
Why
Sleeping per copy needed a separate per-tab fence system, which the earlier version of this PR built and Codex kept finding gaps in. Sleeping the whole workspace with a confirmation keeps main's simple shared marker, and the user sees the cost before accepting it.
The earlier version also moved legacy remote-terminal closes and terminal identity onto the focus-free owner resolver. Codex found twice that this routes an older, unstamped row's remote terminal to the local runtime. Those files stay as on main for now.
No wire or persisted change.
Linked Issue
Stage 1 row 1.3 of the SSH hardening design. No public issue.
Visual Proof
A new confirmation dialog built from the existing shadcn
Dialogpattern, the same oneRemoveFolderDialoguses. Live verify: none; covered by unit tests only.Testing
src/renderer/src/components/sidebar/sleep-twin-confirmation.test.tscovers three cases: one copy selected, every copy selected, and a single-host workspace.sleep-worktree-flow.test.tschecks that a workspace named twice sleeps once.host-twin-isolation.test.ts: the kill, sleep and select cells assert the whole-workspace behaviour.Local runs:
pnpm tc;src/renderer/src/store,lib,components/sidebarandhooks/ipc-events;components/terminal-panefolder (531 files);I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)