Repository navigation
feat(sidebar): main keeps a registry of workspace creations in progress, checked against the window in dev and test - #30021
Conversation
…ss, checked against the window in dev and test
…on-registry # Conflicts: # src/main/runtime/rpc/methods/sidebar-inputs.ts # src/renderer/src/env.d.ts # src/renderer/src/lib/sidebar-shadow/sidebar-shadow-comparison.ts # src/renderer/src/main.tsx # src/shared/rpc-contract/rpc-params-catalog.generated.ts
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · 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:
5d671e87-5b26-4452-b5ad-9be6ad5cfd17
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 23
src/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-create-registry.test.tssrc/main/ipc/worktrees-test-runtime-stub.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees/create/register-worktree-create-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/worktree-create-args.tssrc/main/runtime/runtime-managed-worktree-create-types.tssrc/main/runtime/sidebar-inputs/orca-runtime-workspace-creations.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.test.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.tssrc/renderer/src/lib/sidebar-shadow/host-creation-requests.tssrc/renderer/src/lib/sidebar-shadow/workspace-creations-shadow.test.tssrc/renderer/src/lib/sidebar-shadow/workspace-creations-shadow.tssrc/renderer/src/main.tsxsrc/renderer/src/store/slices/worktrees/create/create-worktree.tssrc/renderer/src/store/slices/worktrees/create/worktree-create-payload.tssrc/renderer/src/web/preload-api/web-worktrees-api.tssrc/shared/rpc-contract/worktree-create-params.tssrc/shared/sidebar-list/workspace-creations.tstests/e2e/sidebar-creation-registry.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| // Holds `git worktree add` in main long enough for two shadow comparisons. | ||
| const hookPath = path.join(testRepoPath, '.git', 'hooks', 'post-checkout') | ||
| writeFileSync(hookPath, '#!/bin/sh\nsleep 8\n') | ||
| chmodSync(hookPath, 0o755) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 'consumePreparedWorktreeCreate\b' --type=ts -g '!**/*.test.ts' | head -80
rg -nP -C3 'hooksPath|--no-checkout|ORCA_E2E.*PREPAR|preparedCheckout.*(enabled|disable)' --type=ts src tests | head -60Repository: stablyai/orca
Length of output: 9006
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- test spec ---'
nl -ba tests/e2e/sidebar-creation-registry.spec.ts | sed -n '1,260p'
printf '%s\n' '--- local runtime create ---'
nl -ba src/main/runtime/runtime-local-git-worktree-create.ts | sed -n '80,230p'
printf '%s\n' '--- IPC worktree create ---'
nl -ba src/main/ipc/worktree-remote.ts | sed -n '1330,1465p'
printf '%s\n' '--- preparation implementation and callers ---'
nl -ba src/main/worktree-create-preparation.ts | sed -n '1,280p'
rg -n -F --glob '*.ts' -e 'prepareWorktreeCreate' -e 'preparing' -e 'worktree-create-preparation' tests/e2e src/main | head -120Repository: stablyai/orca
Length of output: 42504
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- test spec ---'
nl -ba tests/e2e/sidebar-creation-registry.spec.ts | sed -n '1,260p'
printf '%s\n' '--- local runtime create ---'
nl -ba src/main/runtime/runtime-local-git-worktree-create.ts | sed -n '80,230p'
printf '%s\n' '--- IPC worktree create ---'
nl -ba src/main/ipc/worktree-remote.ts | sed -n '1330,1465p'
printf '%s\n' '--- preparation implementation and callers ---'
nl -ba src/main/worktree-create-preparation.ts | sed -n '1,280p'
printf '%s\n' '--- preparation references ---'
rg -n -F --glob '*.ts' -e 'prepareWorktreeCreate' -e 'worktree-create-preparation' tests/e2e src/main | head -120Repository: stablyai/orca
Length of output: 42684
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- preparation callers outside tests ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -e 'prepareWorktreeCreateForRepo(' -e 'hasPendingWorktreeCreatePreparations' src tests
printf '%s\n' '--- addWorktree declaration and implementation ---'
rg -n -F --glob '*.ts' -e 'export async function addWorktree' -e 'function addWorktree' -e 'addWorktree = ' src/main
printf '%s\n' '--- e2e fixture and app helper references ---'
rg -n -F --glob '*.ts' -e 'testRepoPath' -e 'createTestRepo' -e 'openSidebarWorkspaceComposer' tests/e2e/helpers tests/e2e | head -160Repository: stablyai/orca
Length of output: 18459
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- prefetch handler ---'
nl -ba src/main/ipc/worktrees/create/register-worktree-prefetch-handler.ts | sed -n '1,180p'
printf '%s\n' '--- terminal provisioning caller ---'
nl -ba src/main/runtime/workspaces/startup/workspace-terminal-provisioning.ts | sed -n '70,135p'
printf '%s\n' '--- sidebar composer helper ---'
nl -ba tests/e2e/helpers/sidebar-project-dialog.ts | sed -n '1,120p'
printf '%s\n' '--- e2e fixture setup ---'
nl -ba tests/e2e/helpers/orca-app.ts | sed -n '120,190p'
printf '%s\n' '--- addWorktree implementation ---'
nl -ba src/main/git/worktree-add.ts | sed -n '160,280p'Repository: stablyai/orca
Length of output: 13272
🏁 Script executed:
set -o pipefail
rg -n -F --glob '*.ts' -e 'provideWorkerTestRepository' -e 'core.hooksPath' tests/e2e tests/shared src | head -120Repository: stablyai/orca
Length of output: 2978
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- prefetch IPC consumers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'prefetchCreateBase' -e 'worktrees:prefetchCreateBase' src tests | head -100
printf '%s\n' '--- worker repository fixture ---'
rg -n -F --glob '*.ts' -e 'provideWorkerTestRepository' -e 'core.hooksPath' tests/e2e tests/shared src | head -160Repository: stablyai/orca
Length of output: 6067
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- renderer prefetch helper ---'
nl -ba src/renderer/src/store/slices/worktrees/create/prefetch-worktree-create-base.ts | sed -n '1,120p'
printf '%s\n' '--- worker test repository fixture ---'
nl -ba tests/e2e/helpers/seeded-test-repo.ts | sed -n '1,180p'
printf '%s\n' '--- prefetch helper callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'prefetchWorktreeCreateBase' -e 'prefetchCreateBase(' src/renderer/src | head -100Repository: stablyai/orca
Length of output: 8658
Make the delay independent of prepared checkouts.
The composer prefetches a worktree create. A prepared-checkout hit returns before addWorktree, so post-checkout does not run on that path. The poll can then miss the pending state.
Disable prepared checkouts for this spec, or hold the create at a synchronization point shared by both prepared and normal create paths.
The --no-checkout example does not apply to the normal path. addWorktree adds that flag only when noCheckout is true, and the local create caller passes false.
…on-registry # Conflicts: # src/main/runtime/orca-runtime.ts # src/main/runtime/rpc/methods/sidebar-inputs.ts # src/renderer/src/main.tsx # src/shared/rpc-contract/rpc-params-catalog.generated.ts
…on-registry # Conflicts: # src/main/runtime/rpc/methods/sidebar-inputs.ts # src/renderer/src/main.tsx # src/shared/rpc-contract/rpc-params-catalog.generated.ts
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ed2037b8-974a-4020-8b37-982b0c8ff56c
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 6
src/main/runtime/managed-worktree-create-registry.test.tssrc/main/runtime/rpc/methods/sidebar-inputs.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.test.tssrc/main/runtime/sidebar-inputs/workspace-creation-registry.tssrc/main/runtime/workspaces/workspace-creation.tssrc/renderer/src/main.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
… lookup; move create startup resolution to its own module
…on-registry # Conflicts: # src/main/runtime/rpc/methods/sidebar-inputs.ts # src/renderer/src/main.tsx
…TS dark build switch
…e gated creation id
ELI5
When you create a workspace, the window shows a "creating..." row until the workspace exists. Only the window knew about those rows. Now the background process also keeps a list of the creations it is running, whoever started them: the window, the phone, or the command line. Nothing reads that list yet except a check in dev and test builds. The check confirms the list matches what the window shows. Later PRs will let the phone and the desktop show creations from both places.
What Changed
ORCA_SIDEBAR_INPUTSdark build switch (src/shared/sidebar-inputs-switch.ts). Only anORCA_SIDEBAR_INPUTS=maintest build compiles it in. In that build, main keeps a registry of creations in progress, keyed bycreationId, and serves it over the new RPCsidebarInputs.workspaceCreations.workspaceCreationsisnullwith the switch off, and every open, name and close call skips it. The RPC method and the shadow check join the gated lists. The window only tracks its requests, and only sends itscreationIdto paired servers and web-client hosts, when the switch is on. A host still accepts the optional field and ignores it when off.worktrees:createhandler, for git and folder workspaces.createManagedWorktree. That covers the phone, the command line, agent launches, paired web clients and orchestration. The create opens one registry handle (open({ creationId, repoId })returnsnamedandclose) right after its own single repo lookup, so a create refused before that is never listed. It names the workspace where it is saved and closes the handle in afinally. A phone create is keyed by its retry key. A caller that sends no id gets a new one.workspace-creation.tsunder its line limit, its startup resolution moved unchanged intomanaged-worktree-create-startup.ts. That is the disabled-agent checks plus working out what the first terminal launches.creationId. That server's registry then uses the same id as the window. The field is optional, so older hosts drop it and older clients get a new id.Why
The design gives main ownership of every sidebar input so the phone and desktop can build the same list. Creations in progress were the one input main did not track.
Linked Issue
N/A (internal sidebar producer series, follows #29980)
Visual Proof
N/A: no visible change. Main produces the list, and only a dev and test check reads it.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Unit tests:
worktrees:changed, and a failed create is dropped.e2e (
tests/e2e/sidebar-creation-registry.spec.ts, hidden window):git worktree addfor 8 seconds. Main lists the window's creation under the window's id. The shadow check finds 0 mismatches mid-create and after the workspace appears.Gates:
pnpm tc, oxlint,check:code-quality:changed, the focus-read ratchet, and the RPC catalog and ownership census. On macOS,orca-runtime.test.ts,orca-runtime-structured-agent-session-create-intent.test.tsandorcad-forked-child-paths.test.tsfail here, and fail the same way on the base commit (node:sqlite and temp-path differences in this environment).Switch off, before (6fcc183) vs after, built in the same lane path:
Mapwith its reader, and the creations schema object. Nothing reads or calls either.ORCA_UNMINIFIED_MAIN=1): the registry class is gone, andworkspaceCreations = null.open/named/closecalls, anundefinedoptional argument tocreateLocalWorktree, and the optionalcreationIdthe host accepts.Hidden-app e2e (
ORCA_BACKGROUND_LAUNCH=1):ORCA_SIDEBAR_INPUTS=main):sidebar-creation-registry,golden-worktree-create-switchandsidebar-review-factsall pass, with 0 shadow mismatches.sidebar-creation-registryskips cleanly.Unit tests:
workspaceCreationsis null.creationIdreaches a paired server only with the switch on.runtime-created-worktree-terminal-target.test.tspasses unchanged.Review
An independent review of the diff and of the fix delta. Applied:
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)