Skip to content

feat(sidebar): main keeps a registry of workspace creations in progress, checked against the window in dev and test - #30021

Merged
Jinwoo-H merged 9 commits into
mainfrom
jinwoo/sidebar-creation-registry
Oct 17, 2026
Merged

Jinwoo-H merged 9 commits into
mainfrom
jinwoo/sidebar-creation-registry

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​472 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​472
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​302 $\color{#cf222e}{\Huge{\mathbf{−}}}$​64 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​238

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

  • Before: the window kept its own pending creations. Main only sent progress events. Main had no record of a creation it was running, so the phone could not show a desktop creation, and the desktop could not show a phone or command-line creation.
  • After: nothing changes for the user, and shipped builds are untouched. Everything here is behind the ORCA_SIDEBAR_INPUTS dark build switch (src/shared/sidebar-inputs-switch.ts). Only an ORCA_SIDEBAR_INPUTS=main test build compiles it in. In that build, main keeps a registry of creations in progress, keyed by creationId, and serves it over the new RPC sidebarInputs.workspaceCreations.
    • Switch points: the runtime field workspaceCreations is null with 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 its creationId to paired servers and web-client hosts, when the switch is on. A host still accepts the optional field and ignores it when off.
    • The window's own creates are listed in the worktrees:create handler, for git and folder workspaces.
    • Every runtime create is listed by the base createManagedWorktree. That covers the phone, the command line, agent launches, paired web clients and orchestration. The create opens one registry handle (open({ creationId, repoId }) returns named and close) 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 a finally. A phone create is keyed by its retry key. A caller that sends no id gets a new one.
    • To keep workspace-creation.ts under its line limit, its startup resolution moved unchanged into managed-worktree-create-startup.ts. That is the disabled-agent checks plus working out what the first terminal launches.
    • Completion with no gap and no overlap. When main saves the new workspace, the entry records the workspace's id. That happens before main announces the workspace. The entry is removed when the create finishes or fails. A reader that already lists that workspace shows the workspace instead of the "creating..." row. So no moment shows both, and no moment shows neither.
    • Preflight. Work the window does before it asks main is not in main's registry and stays in the window's own pending row. That includes script-trust prompts, VM provisioning and work-item lookups, including the cases where they fail. Main's entry starts when the request reaches main.
    • Window requests to a paired server and web-client requests now send the window's 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.
  • Shadow check (dev and test builds only): the window remembers each create request it sends to its own host. The check compares the requests still waiting for a reply with main's registry. It flags a request main never listed, and a main entry that outlived its request. The check skips phone and command-line creations and paired-server rows. The shared check loop now counts a round only when every domain compared, so the e2e helper's "two comparisons" really means two checks per domain.

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.

  • One choke point per entry path, not per caller. Hooking each RPC method, agent launch and orchestration caller separately would miss paths.
  • Recording the workspace's id, not timing the removal. The runtime path announces the workspace before its terminals start. Removing the entry at the announcement would need a second close point in each path. Recording the id at save time makes the handoff exact on every path.
  • Comparing requests, not the window's pending rows. A pending row also covers preflight and the window's own work after main replied. Comparing those rows would give false mismatches, or would need timing allowances.
  • Not tracked: provisioned-root adoption. The desktop's version always refuses today.

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:

    • The registry: listing, naming, removal on success and failure, a new id when the caller sends none, and a concurrent retry under the same id.
    • The window create handler: the entry records its workspace before main sends worktrees:changed, and a failed create is dropped.
    • The runtime create: a phone create is keyed by its retry key and named before the announcement; also failure and folder workspaces.
    • The shadow check: it agrees with main's list, ignores other callers' creations, and flags both kinds of drift.
  • e2e (tests/e2e/sidebar-creation-registry.spec.ts, hidden window):

    • A git hook holds git worktree add for 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.
    • Positive control, not committed: main recorded a different id, and the check reported the mismatch.
    • The golden create-and-switch and folder keyboard specs still pass.
  • 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.ts and orcad-forked-child-paths.test.ts fail 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:

    • Preload: byte-identical.
    • Renderer (built unminified for the comparison): beyond renamed export aliases and the embedded build commit, the only additions are unused leftovers. They are the request tracker's empty Map with its reader, and the creations schema object. Nothing reads or calls either.
    • Main (ORCA_UNMINIFIED_MAIN=1): the registry class is gone, and workspaceCreations = null.
    • What remains in main does nothing when off: optional-chained open/named/close calls, an undefined optional argument to createLocalWorktree, and the optional creationId the host accepts.
    • Main also shows the move of the startup resolution into its own module, needed to stay under the line limit. The logic is the same code, in the same order.
  • Hidden-app e2e (ORCA_BACKGROUND_LAUNCH=1):

    • Switch on (ORCA_SIDEBAR_INPUTS=main): sidebar-creation-registry, golden-worktree-create-switch and sidebar-review-facts all pass, with 0 shadow mismatches.
    • Switch off: the golden spec passes, and sidebar-creation-registry skips cleanly.
  • Unit tests:

    • The registry tests mock the switch on. The switch-off test asserts workspaceCreations is null.
    • The IPC test stub mirrors the switch, so every other create test runs the off path.
    • A new payload test checks that creationId reaches a paired server only with the switch on.
    • runtime-created-worktree-terminal-target.test.ts passes unchanged.

Review

An independent review of the diff and of the fix delta. Applied:

  • the e2e helper could pass after one check of the new domain;
  • dropped the tracking of provisioned-root adoption, which can never succeed;
  • one callback name for both paths;
  • a comment on why the window side is the request rather than the pending row.

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

  • SSH: an SSH create still fails before anything is created, and that entry is dropped.
  • Folder workspaces: covered on both paths.
  • Paired servers: each server lists its own creations.
  • Mixed versions: the new parameter is optional and safe in both directions.
  • Cost: in production, one map entry and one revision bump per create.

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)

…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
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ca55836-cb20-4291-b72c-109d7296b9d9
📥 Commits

Reviewing files that changed from the base of the PR and between c2df685 and a3072ac.

📒 Files selected for processing: 5
  • src/main/ipc/worktrees/create/register-worktree-create-handlers.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.test.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.ts
  • src/main/runtime/workspaces/managed-worktree-create-startup.ts
  • src/main/runtime/workspaces/workspace-creation.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.

📝 Walkthrough

The change adds creationId to worktree creation requests and tracks active creations in the main process. The registry records repository IDs, adds worktree IDs after metadata persistence, and removes entries when creation settles. A new RPC method returns registry snapshots. The renderer tracks in-flight host requests and compares them with snapshots through sidebar shadow checks. Managed worktree startup resolution now uses a dedicated function. Tests cover registry lifecycle, request matching, startup-related creation behavior, and sidebar state.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to a3072

This change adds a registry that tracks in-progress workspace creations and compares it with the window's requests in dev and test builds. No concrete merge-blocking risk remains in the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 25 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly summarizes the main change: a main-process registry for in-progress workspace creations with dev and test verification.
Description check Passed The description follows the required structure and provides clear user impact, implementation details, rationale, testing evidence, compatibility notes, and checklist status. It marks the linked issue…
Full details: Description check

Explanation

The description follows the required structure and provides clear user impact, implementation details, rationale, testing evidence, compatibility notes, and checklist status. It marks the linked issue as N/A while referencing #29980; confirm that this satisfies the repository's issue-link policy.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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: 5d671e87-5b26-4452-b5ad-9be6ad5cfd17
📥 Commits

Reviewing files that changed from the base of the PR and between 6c7ed18 and bc929b3.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 23
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees-create-registry.test.ts
  • src/main/ipc/worktrees-test-runtime-stub.ts
  • src/main/ipc/worktrees-windows.test.ts
  • src/main/ipc/worktrees/create/register-worktree-create-handlers.ts
  • src/main/runtime/managed-worktree-create-registry.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/sidebar-inputs.ts
  • src/main/runtime/rpc/methods/worktree-create-args.ts
  • src/main/runtime/runtime-managed-worktree-create-types.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-workspace-creations.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.test.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.ts
  • src/renderer/src/lib/sidebar-shadow/host-creation-requests.ts
  • src/renderer/src/lib/sidebar-shadow/workspace-creations-shadow.test.ts
  • src/renderer/src/lib/sidebar-shadow/workspace-creations-shadow.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/store/slices/worktrees/create/create-worktree.ts
  • src/renderer/src/store/slices/worktrees/create/worktree-create-payload.ts
  • src/renderer/src/web/preload-api/web-worktrees-api.ts
  • src/shared/rpc-contract/worktree-create-params.ts
  • src/shared/sidebar-list/workspace-creations.ts
  • tests/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.

Comment on lines +30 to +33
// 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)

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:

#!/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 -60

Repository: 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 -120

Repository: 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 -120

Repository: 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 -160

Repository: 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 -120

Repository: 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 -160

Repository: 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 -100

Repository: 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

@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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed2037b8-974a-4020-8b37-982b0c8ff56c
📥 Commits

Reviewing files that changed from the base of the PR and between bc929b3 and c2df685.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 6
  • src/main/runtime/managed-worktree-create-registry.test.ts
  • src/main/runtime/rpc/methods/sidebar-inputs.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.test.ts
  • src/main/runtime/sidebar-inputs/workspace-creation-registry.ts
  • src/main/runtime/workspaces/workspace-creation.ts
  • src/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
@Jinwoo-H
Jinwoo-H merged commit cd29f5f into main Oct 17, 2026
40 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