Repository navigation
feat(sidebar): one lifecycle line per workspace in main, with in-progress hints (switch-gated) - #31553
Conversation
…lip) The fixes found while the sidebar ran from main's feed, without turning that on: ORCA_SIDEBAR_INPUTS_IS_MAIN stays false, and none of flip-a's stop-gaps come along. - Main stops counting a closed tab's terminal once it was asked to stop and no pane shows it; a failed or refused stop takes the request back, and a host out of contact stays unverifiable. - Main fetches a paired server's rows with the transport's normal bound, so a server slower than 5 s still lists. - A deferred unread raise flips the folder row it was decided for, and a read while the owner check is out cancels it. - Phone: no worktree.ps flash before the feed; a host's last installed feed stands in while a fresh read is out; it highlights its own last-opened workspace and a fold never scrolls; projects file under their project group with the desktop's indent; the collapse spinner shows only after 500 ms; "Reopen to update" keeps the rows on screen. - e2e helpers and journeys for the switch-on suite.
…d prune pending unread raises - A stop-and-wait that throws takes its stop request back, like one that fails. - A final stop the legacy relay still owes stays marked, since the relay retries it. - Pending unread raises are tracked only while one waits, so the map no longer grows. - The paired-server fallback poll test gives its third fetch a reply and asserts live.
…stores; detected, view and live-content domains (inert)
…n metadata writes, no phone wait on detected checkouts
…gress hints (switch-gated) Create, delete, terminal.closeAll, terminal.sleep and worktree.sleep now run through one first-in, first-out queue per host-qualified workspace: strict order, no merging, delete cancels what has not started and waits for what has, an unconfirmed outcome pauses until the host's own answer. Hints publish in a new inProgress feed domain (no reader yet); the creations domain is its projection. A finished create or delete keeps its hint until a scan started after it applies, in the same revision. Adds the paired-server metadata serializer (saving domain, no caller yet). Replaces the creation registry.
- A command issued while paused waits behind the pause; when the owner answers again main re-reads terminal liveness and the listing, then carries on. A forced delete runs past it. - Commands keep their arrival order across a workspace lookup; deletes by name key by the resolved id, so they wait for that workspace's running sleep. - A second delete with different options is refused as already in progress. - Close and delete read lost contact as sleep does. - A create always frees its own queue entry, even after a retry took over its id. - Drops the unused opId, and the paired-server write serializer and its feed section, which land with their first caller. Co-Authored-By: Claude <[email protected]>
Also: split the workspace-wide terminal stops into their own RPC module (line limit), and let a pending name lookup hold other workspaces' commands only briefly. Co-Authored-By: Claude <[email protected]>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
45806f0b-9730-4116-8f03-c88c1d0aa378
📒 Files selected for processing: 30
src/main/ipc/worktrees-create-registry.test.tssrc/main/ipc/worktrees-test-runtime-stub.tssrc/main/ipc/worktrees/create/register-worktree-create-handlers.tssrc/main/ipc/worktrees/removal/register-worktree-removal-handlers.tssrc/main/runtime/managed-worktree-create-registry.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/sidebar-inputs.tssrc/main/runtime/rpc/methods/terminal/terminal-lifecycle-methods.tssrc/main/runtime/rpc/methods/terminal/terminal-workspace-stop-methods.tssrc/main/runtime/rpc/methods/worktree-sleep-method.tssrc/main/runtime/rpc/methods/worktree.tssrc/main/runtime/sidebar-inputs/cached-scan.test.tssrc/main/runtime/sidebar-inputs/cached-scan.tssrc/main/runtime/sidebar-inputs/orca-runtime-sidebar-inputs-feed.test.tssrc/main/runtime/sidebar-inputs/sidebar-inputs-feed-announcements.test.tssrc/main/runtime/sidebar-inputs/sidebar-inputs-feed-domains.tssrc/main/runtime/sidebar-inputs/sidebar-inputs-switch-off.test.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.test.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.tssrc/main/runtime/sidebar-inputs/workspace-git-identity.test.tssrc/main/runtime/sidebar-inputs/workspace-rows-producer.tssrc/main/runtime/sidebar-inputs/workspace-rows-publish-cost.test.tssrc/main/runtime/workspaces/workspace-creation.tssrc/main/runtime/workspaces/workspace-lifecycle-command.tssrc/main/runtime/workspaces/workspace-lifecycle-commands.test.tssrc/main/runtime/workspaces/workspace-lifecycle-commands.tssrc/main/runtime/workspaces/workspace-lifecycle-creations.tssrc/main/runtime/workspaces/workspace-lifecycle-queue.test.tssrc/main/runtime/workspaces/workspace-lifecycle-queue.tssrc/shared/sidebar-list/workspace-lifecycle-hints.ts
💤 Files with no reviewable changes: 2
- src/main/runtime/sidebar-inputs/workspace-creation-registry.test.ts
- src/main/runtime/sidebar-inputs/workspace-creation-registry.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| }) | ||
| .catch((error: unknown) => { | ||
| console.warn(`[${this.deps.label}] scan failed`, error) | ||
| this.settleFresh(version) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect whether membership completion removes settling create/delete hints.
ast-grep outline src/main/runtime/workspaces/workspace-lifecycle-queue.ts --match WorkspaceLifecycleQueue
ast-grep outline src/main/runtime/workspaces/workspace-lifecycle-creations.ts --match WorkspaceLifecycleCreations
rg -n -C 6 'membership\(|settling|finishEntry|settlingKeys' \
src/main/runtime/workspaces/workspace-lifecycle-queue.ts \
src/main/runtime/workspaces/workspace-lifecycle-creations.tsRepository: stablyai/orca
Length of output: 15678
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- cached-scan.ts ---'
nl -ba src/main/runtime/sidebar-inputs/cached-scan.ts | sed -n '1,220p'
printf '%s\n' '--- WorkspaceRowsProducer references ---'
rg -n -F --glob '*.ts' -e 'new CachedScan' -e 'afterFresh' -e 'setMembership' -e 'membership:' src/main/runtime/sidebar-inputs src/main/runtime/workspaces
printf '%s\n' '--- lifecycle queue completion blocks ---'
nl -ba src/main/runtime/workspaces/workspace-lifecycle-queue.ts | sed -n '285,365p'
printf '%s\n' '--- lifecycle creation completion block ---'
nl -ba src/main/runtime/workspaces/workspace-lifecycle-creations.ts | sed -n '45,112p'Repository: stablyai/orca
Length of output: 12021
Do not settle lifecycle membership after a failed scan.
When scan() rejects, CachedScan calls settleFresh(version) without applying a new listing. WorkspaceRowsProducer connects this callback to the lifecycle queue, so a failed scan can clear a create or delete hint while rows still show the previous membership. Settle membership only after an applied result. Provide a retry or explicit failure path for the waiter.
| private enqueue<T>(key: string, command: LifecycleCommand<T>, seq: number): Promise<T> { | ||
| const queue = this.queueFor(key) | ||
| const pendingDelete = queue.entries.find((entry) => entry.kind === 'delete') | ||
| if (pendingDelete) { | ||
| const pending = pendingDelete.command?.delete | ||
| if (command.kind !== 'delete') { | ||
| return Promise.reject(new Error(WORKSPACE_DELETED_ERROR)) | ||
| } | ||
| if (pendingDelete.reply && pending?.key === command.delete?.key) { | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: an equal delete shares the pending delete's reply, as a removal in flight always has. | ||
| return pendingDelete.reply as Promise<T> | ||
| } | ||
| // A forced delete replaces an unforced one still waiting (behind a pause); never a running one. | ||
| if (!command.delete?.force || pendingDelete.state === 'running') { | ||
| const label = command.delete?.label ?? key | ||
| return Promise.reject(new Error(`Worktree deletion already in progress: ${label}`)) | ||
| } | ||
| } | ||
| if (command.kind === 'delete') { | ||
| this.cancelQueued(queue) | ||
| } | ||
| let settle!: (attempt: LifecycleAttempt) => void | ||
| const reply = new Promise<unknown>((resolve, reject) => { | ||
| settle = (result) => (result.threw ? reject(result.error) : resolve(result.value)) | ||
| }) | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: widened only to be stored; run's result is handed back to this command's own caller. | ||
| const stored = command as LifecycleCommand<unknown> | ||
| const entry: Entry = { | ||
| kind: command.kind, | ||
| seq, | ||
| state: 'queued', | ||
| command: stored, | ||
| reply, | ||
| settle | ||
| } | ||
| // In arrival order among what has not started; a late lookup goes ahead of later arrivals. | ||
| const after = queue.entries.findIndex((queued) => queued.state === 'queued' && queued.seq > seq) | ||
| queue.entries.splice(after === -1 ? queue.entries.length : after, 0, entry) | ||
| this.revision.bump() | ||
| if (command.delete?.force) { | ||
| queue.wake?.() | ||
| } | ||
| void this.drain(key) | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: settled only with this command's run result. | ||
| return reply as Promise<T> | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'optionKey|options|key' src/main/runtime/workspaces/workspace-lifecycle-queue.ts | sed -n '1,60p'
sed -n '130,170p' src/main/ipc/worktrees/removal/register-worktree-removal-handlers.ts
rg -n 'queueWorkspaceDelete' -A40 src/main/runtime/workspaces/workspace-lifecycle-commands.tsRepository: stablyai/orca
Length of output: 5090
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- helper references ---'
rg -n -F --glob '*.ts' -e 'getWorktreeRemovalOptionsKey' -e 'getRuntimeWorktreeRemovalOptionsKey' -e 'type RemoveWorktreeArgs' -e 'interface RemoveWorktreeArgs' src
printf '%s\n' '--- imports and helper definitions ---'
rg -n -F --glob '*.ts' -e 'getWorktreeRemovalOptionsKey' -e 'getRuntimeWorktreeRemovalOptionsKey' src/main | head -80
printf '%s\n' '--- command tail ---'
sed -n '180,245p' src/main/runtime/workspaces/workspace-lifecycle-commands.ts
printf '%s\n' '--- removal handler context ---'
sed -n '1,180p' src/main/ipc/worktrees/removal/register-worktree-removal-handlers.ts
printf '%s\n' '--- queue type definitions ---'
sed -n '1,115p' src/main/runtime/workspaces/workspace-lifecycle-queue.tsRepository: stablyai/orca
Length of output: 17174
🏁 Script executed:
rg -n -F --glob '*.ts' -e 'getWorktreeRemovalOptionsKey' -e 'getRuntimeWorktreeRemovalOptionsKey' -e 'interface RemoveWorktreeArgs' -e 'type RemoveWorktreeArgs' src; sed -n '180,235p' src/main/runtime/workspaces/workspace-lifecycle-commands.ts; sed -n '1,180p' src/main/ipc/worktrees/removal/register-worktree-removal-handlers.ts; sed -n '1,115p' src/main/runtime/workspaces/workspace-lifecycle-queue.tsRepository: stablyai/orca
Length of output: 15231
🏁 Script executed:
rg -n -F --glob '*.ts' -e 'getWorktreeRemovalOptionsKey' -e 'getRuntimeWorktreeRemovalOptionsKey' -e 'interface RemoveWorktreeArgs' -e 'type RemoveWorktreeArgs' srcRepository: stablyai/orca
Length of output: 2029
🏁 Script executed:
set -o pipefail
sed -n '1,80p' src/main/ipc/worktrees/removal/worktree-removal-coordinator.ts
sed -n '1,65p' src/main/runtime/runtime-worktree-selection.ts
sed -n '1,55p' src/main/ipc/worktrees/ipc-context-schemas.ts
sed -n '1,45p' src/main/runtime/workspaces/workspace-lifecycle-commands.tsRepository: stablyai/orca
Length of output: 8519
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- queueWorkspaceDelete callers ---'
rg -n -F --glob '*.ts' -e 'queueWorkspaceDelete(' src/main
printf '%s\n' '--- runtime removal consumers ---'
sed -n '85,130p' src/main/runtime/workspaces/workspace-removal.ts
rg -n -F --glob '*.ts' -e 'runHooks' -e 'skipArchive' src/main/runtime src/main/ipc/worktrees/removal | head -100
printf '%s\n' '--- key resolution ---'
rg -n -F --glob '*.ts' -e 'function explicitKey' -e 'function lookedUpKey' -e 'explicitKey(' -e 'workspaceLifecycleKey(' src/main/runtime/workspaces/workspace-lifecycle-commands.ts src/main/ipc/worktrees/removal/register-worktree-removal-handlers.ts
printf '%s\n' '--- IPC execution options ---'
rg -n -F --glob '*.ts' -e 'skipArchive' -e 'allowFailedArchiveHook' src/main/ipc/worktrees/removal/execute-worktree-removal.ts src/main/ipc/worktrees/removalRepository: stablyai/orca
Length of output: 16527
🏁 Script executed:
set -o pipefail
sed -n '90,155p' src/main/runtime/workspaces/workspace-lifecycle-commands.ts
sed -n '255,300p' src/main/runtime/rpc/methods/worktree.ts
sed -n '145,178p' src/main/ipc/worktrees/removal/execute-worktree-removal.ts
sed -n '65,100p' src/main/runtime/workspaces/workspace-removal.ts
sed -n '1,70p' src/main/runtime/rpc/methods/worktree.tsRepository: stablyai/orca
Length of output: 9961
🏁 Script executed:
sed -n '70,100p' src/main/runtime/runtime-registered-local-worktree-removal.tsRepository: stablyai/orca
Length of output: 1393
Use the same delete-option key format in both removal paths.
When an archive-enabled IPC delete and a hook-enabled RPC delete overlap for the same explicit worktree and host, the IPC key is normal:run-archive:require-pty-stop:require-archive, while the RPC key is normal:run-hooks:require-pty-stop:require-archive. The queue compares these keys directly, so the second request can throw Worktree deletion already in progress instead of joining the active delete.
Suggested fix
- const archiveKey = args.skipArchive === true ? 'skip-archive' : 'run-archive'
+ const archiveKey = args.skipArchive === true ? 'skip-hooks' : 'run-hooks'| if (answered === true) { | ||
| await new Promise<void>((done) => this.membership(done)) | ||
| if (queue.paused === paused) { | ||
| queue.paused = null | ||
| this.revision.bump() | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Does afterFresh request a scan itself, or only wait for one that demand allows?
fd cached-scan.ts src/main/runtime/sidebar-inputs --exec cat -n {}Repository: stablyai/orca
Length of output: 4367
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- queue target and related symbols ---'
rg -n -F -- 'awaitOwner' src/main/runtime/workspaces/workspace-lifecycle-queue.ts
rg -n -F -- 'wake()' src/main/runtime/workspaces/workspace-lifecycle-queue.ts
rg -n -F -- 'afterFresh' src/main/runtime/workspaces src/main/runtime/sidebar-inputs || true
sed -n '250,390p' src/main/runtime/workspaces/workspace-lifecycle-queue.ts
printf '%s\n' '--- queue callers and membership binding ---'
rg -n -F -- 'setMembership' src/main
rg -n -F -- 'WorkspaceRowsProducer' src/main
rg -n -F -- 'scans.afterFresh' src/mainRepository: stablyai/orca
Length of output: 335
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- target queue block ---'
nl -ba src/main/runtime/workspaces/workspace-lifecycle-queue.ts | sed -n '240,370p'
printf '%s\n' '--- queue symbols ---'
rg -n -F -e 'wake' -e 'membership' -e 'forced' -e 'force' -e 'delete' src/main/runtime/workspaces/workspace-lifecycle-queue.ts || true
printf '%s\n' '--- membership and queue wiring ---'
rg -n -F -e 'setMembership' -e 'WorkspaceRowsProducer' -e 'afterFresh' src/main || trueRepository: stablyai/orca
Length of output: 9820
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- forced-delete enqueue path ---'
nl -ba src/main/runtime/workspaces/workspace-lifecycle-queue.ts | sed -n '150,220p'
printf '%s\n' '--- WorkspaceRowsProducer membership binding ---'
nl -ba src/main/runtime/sidebar-inputs/workspace-rows-producer.ts | sed -n '77,105p'Repository: stablyai/orca
Length of output: 5080
Do not block forced delete on membership refresh.
awaitOwner races the owner observation against woken, but it does not race the subsequent this.membership(done) wait. A forced delete calls queue.wake?.(), yet the existing wait does not observe that signal. Race the membership wait against woken:
🐛 Suggested fix
--- "a/src/main/runtime/workspaces/workspace-lifecycle-queue.ts"
+++ "b/src/main/runtime/workspaces/workspace-lifecycle-queue.ts"
@@ -334,12 +334,15 @@
),
woken
])
if (answered === true) {
- await new Promise<void>((done) => this.membership(done))
- if (queue.paused === paused) {
+ const listed = await Promise.race([
+ new Promise<'listed'>((done) => this.membership(() => done('listed'))),
+ woken
+ ])
+ if (listed === 'listed' && queue.paused === paused) {
queue.paused = null
this.revision.bump()
}
} else if (answered === false) {
await Promise.race([this.retryDelay(OBSERVE_RETRY_MS), woken])
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (answered === true) { | |
| await new Promise<void>((done) => this.membership(done)) | |
| if (queue.paused === paused) { | |
| queue.paused = null | |
| this.revision.bump() | |
| } | |
| if (answered === true) { | |
| const listed = await Promise.race([ | |
| new Promise<'listed'>((done) => this.membership(() => done('listed'))), | |
| woken | |
| ]) | |
| if (listed === 'listed' && queue.paused === paused) { | |
| queue.paused = null | |
| this.revision.bump() | |
| } |
…tore-view-attach apply-mobile-session-tab-navigation.ts takes main's renamed selection-projection import; C1c's numbered-record lookup keeps replacing the stable-key read, so main's makePaneKey import is unused and dropped. Claude-Session: W5b
ELI5
When you create, sleep, wake, close or delete a workspace, the desktop's main process now handles those requests one at a time per workspace, in the order they arrived. It also tells the sidebar feed which workspace has something in flight. Before, two clients could ask for opposite things at the same moment (a phone sleeps while the window deletes), and nothing kept them in order.
This only happens when the sidebar build switch is on. It is off on main, so users see no change.
What Changed
One line per workspace (switch on)
WorkspaceLifecycleQueuein main. There is one first-in-first-out line per host and workspace. Commands start in the order they arrived, even when one first has to look up which workspace a name means. A later command waits at most 500 ms for an earlier one's lookup, so a name lookup stuck on a disconnected SSH host cannot stall other workspaces' lines. They run one at a time and are never merged.worktree rm <name>waits for that workspace's running sleep.--force) still runs at once, as today.worktrees:remove), the phone/CLIworktree.rm,worktree.sleep,terminal.sleepandterminal.closeAll. Metadata edits (rename, pin, comment) are not queued.In-progress hints in the feed (switch on)
inProgress: which workspace is creating, sleeping, waking, closing or deleting, how many commands wait behind it, and whether its line is paused.Why
Linked Issue
Part of the sidebar one-owner design (P3). Stacked on #31513.
Visual Proof
N/A: no reader shows the new sections yet, and the build switch is off.
Testing
pnpm tcpasses.workspace-git-identity.test.ts:19) comes from Sidebar P2: main publishes without waiting on git, and every source announces its changes (inert) #31513, not this PR.terminal-parked-memory, a renderer heap ceiling) failed once more, then passed 2 of 2 on this branch and 2 of 2 on the base.worktree-active-delete-scroll-position, which also fails on the base.What runs with the switch off: nothing new. The queue is not created and every path runs as before. The only switch-off changes are code moves:
worktree.sleepmoved to its own file, and the delete paths go through a helper that runs directly when there is no queue.The paired-server metadata write serializer that was in an earlier version of this PR moved out; it lands with its first caller.
Notes
SSH: the line is keyed by execution host plus workspace, so the same path on two hosts never shares a line. A lost connection pauses the line rather than marking a command done. Folder workspaces use the same keys as git worktrees.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)