Repository navigation
fix(worktree): never reissue a generated workspace name - #14350
Conversation
Generated workspace names were deduped only against currently-live worktrees, so deleting a workspace returned its name to the pool. A later workspace could draw the same name, land on the same directory path, and inherit the previous occupant's agent conversation history — coding-agent CLIs key their prompt history and transcripts by cwd. Names are now retired permanently per repo. The registry is written in main with the name Git actually used (the create loop can advance past a requested name on collision), and seeded once per run from workspace directories and surviving agent transcript buckets so already-spent names are excluded from the start. Suggestions degrade to -2, -3 variants instead of recycling, and those variants retire too. User-typed names are untouched: retirement filters suggestions only.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds shared worktree-name normalization and selection utilities with cross-platform path handling. It discovers and persists retired generated names by workspace key, backfills them from workspace and Claude project paths, and exposes repository-scoped lookup through runtime, RPC, IPC, preload, and web APIs. Worktree creation skips retired names for generated requests and records successful generated names. Mobile and renderer clients load retired names and include generated-name provenance in creation requests. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve 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. Comment |
Mobile hand-duplicated the desktop name-suggestion algorithm and deduped only against live workspaces, so a phone could still be offered a name whose deleted workspace left agent conversation state behind at that path. Both platforms now call one shared selector in src/shared, so the two can no longer drift. The host publishes retired names as an optional field on the existing worktree.list response, and mobile fetches them per selected repo while the create sheet is open — mirroring the desktop hook. Mobile never calls worktree.list for its catalog (it uses worktree.ps, which carries rows only), so this is a targeted request rather than a change to the catalog or its cache. Hosts predating the field omit it and mobile falls back to live-only dedupe, which is the pre-change behavior.
…enerated-workspace-names
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/shared/worktree-name-suggestion.ts (2)
17-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a cross-platform path utility.
stripTrailingSeparatorsandsuggestionPathBasenameparse/and\directly. Use a cross-platform path helper that is available in every desktop and mobile bundle. Retain the POSIX and Windows fixture coverage.Verify bundle compatibility before selecting the utility. As per coding guidelines, “Use
path.joinor Electron/Node path utilities for file paths; never assume/or\.”Source: Coding guidelines
3-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the API comments.
These blocks repeat implementation and product history. Keep only the non-obvious contract, such as requiring
usedNamesto include retired names. As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”Also applies to: 33-39
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 67a4b322-f227-43b2-8f76-38d1858e29af
📒 Files selected for processing (23)
mobile/src/components/NewWorktreeModal.tsxmobile/src/components/worktree-name-suggestion.test.tsmobile/src/components/worktree-name-suggestion.tsmobile/src/worktree/use-retired-worktree-names.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees.tssrc/main/persistence-worktree-name-retirement.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.tssrc/main/worktree-name-retirement.test.tssrc/main/worktree-name-retirement.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/sidebar/worktree-name-suggestions.test.tssrc/renderer/src/components/sidebar/worktree-name-suggestions.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/hooks/useRetiredWorktreeNames.tssrc/renderer/src/web/web-preload-api.tssrc/shared/constants.tssrc/shared/runtime-types.tssrc/shared/types.tssrc/shared/worktree-name-suggestion.test.tssrc/shared/worktree-name-suggestion.ts
0c13871 to
21a117a
Compare
STA-4189 validation evidence (PR #14350,
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 06b1dd9b-3764-493b-a11a-b5b776c625ca
📒 Files selected for processing (16)
mobile/src/components/NewWorktreeModal.tsxmobile/src/worktree/use-retired-worktree-names.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/persistence-worktree-name-retirement.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/worktree.test.tssrc/main/runtime/rpc/methods/worktree.tssrc/main/runtime/runtime-rpc.tssrc/main/worktree-name-retirement.test.tssrc/main/worktree-name-retirement.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/hooks/useRetiredWorktreeNames.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/main/persistence.ts
- mobile/src/components/NewWorktreeModal.tsx
- src/main/runtime/orca-runtime.ts
- src/main/ipc/worktrees.ts
- src/renderer/src/hooks/useComposerState.ts
Exact-final-head validation (PR #14350,
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d1118d46-84e4-4158-938c-91a492bf1d2d
📒 Files selected for processing (5)
src/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees.test.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/runtime/orca-runtime.ts
- src/main/ipc/worktrees-windows.test.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/ipc/worktrees.test.ts
Exact final head
|
The bucket-name encoder and its scope-boundary check were private to the session scanner, so a second consumer had to reimplement them — and got the per-character encoding wrong. Move both to a shared module with direct tests.
The bucket encoder collapsed runs of non-alphanumerics while the real one emits a dash per character, so every dot-path bucket missed and the Windows default workspace root (C:\...) matched nothing at all. Reuse the shared encoder and its boundary check, which also stops a repo absorbing a sibling whose path merely shares its prefix. Also: - Derive the workspace leaf by stripping the known encoded parent instead of guessing from trailing dash segments, which retired the parent directory's name whenever a workspace was named numerically. - Reuse isAutoGeneratedCreatureBranchName so the -10 and -100 tiers retire. - Drop the .codex/sessions root: Codex keeps the cwd inside the transcript rather than in a directory name, so the scan could only ever see a year folder. Reading transcript contents is not a trade this feature justifies, so the gap is documented instead. - Honor CLAUDE_CONFIG_DIR, which relocates the bucket root. - Delete the unused retirableLeafName export. Tests write buckets with the real per-character encoding against a fake home, covering POSIX, dot-directory, Windows drive and WSL UNC roots; all three platform cases fail against the previous encoder.
Two problems in the host-side registry.
Retirement fired for every create, including names the user typed. The
creature pool contains ordinary words — orca, runner, sole, molly, oscar — so
typing a retired 'nautilus' silently produced directory and branch
'nautilus-2' and burned the name for good. Creates now carry an explicit
nameWasGenerated flag; both the skip and the retire are gated on it, and it
defaults to false so CLI and automation callers are unaffected.
The registry was keyed by repo id, but both readers already discarded the id
and unioned by the cwd collision key, because the collision this prevents is
on the path. Keying by that namespace directly fixes several things at once:
entries no longer orphan when a repo is removed, remove/re-add no longer loses
every retirement for an unchanged path, the missing removeProject prune is
moot, and the backfill promise no longer merges into only the first repo id it
saw. The feature is unreleased, so no migration is needed.
Also:
- Memoize the collision key. It runs computeWorktreePath, which for a WSL repo
is a blocking execFileSync('wsl.exe') whose failure path is uncached, and
the previous code recomputed it once per repo on every create and every
listRetiredNames call.
- Drop retiredNamesByRepo from the worktree list result. It had no readers and
leaked onto 'orca worktree list --json', and its awaited backfill sat on CLI
selector resolution. The dedicated listRetiredNames RPC keeps its consumers.
- Make the three RuntimeStore methods required. RuntimeStore is file-private
with two constructors, so the 'older embedders' the optionality protected do
not exist, and the optional chain silently returned no retirements.
- Revert the unrelated forceDeleteBranch rewrite, and make room under the
file's line budget by extracting the create-args mapping instead.
Desktop and mobile now mark a create as generated-name only when the user typed nothing and the composer fell back to the suggestion, so the host knows which names it may retire. Remove the retired-names loading gate from every create path. The host already skips retired candidates before doing any git work, so the client gate bought nothing while it could disable Create for the length of a full mobile reconnect ladder (the wait had no timeout) and blank the desktop button between queued creates. The suggestion still waits; the button never does. Also make the web client call worktree.listRetiredNames instead of hardcoding an empty list — the method is registered and mobile-allowlisted, so the comment claiming no wire call existed was wrong — and filter the mobile response to strings so a malformed row cannot throw during normalization.
…enerated-workspace-names # Conflicts: # src/renderer/src/store/slices/worktree-helpers.ts
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/main/ai-vault/claude-project-dir-encoding.ts (1)
3-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the implementation comments.
Keep the non-obvious NFC and lossy-encoding rationale. Remove repeated encoding details.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”
Also applies to: 14-15, 23-24
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 52c39ac7-5fa8-44c6-9199-fa04250f26ed
📒 Files selected for processing (37)
mobile/src/components/NewWorktreeModal.tsxmobile/src/tasks/blank-workspace-create.test.tsmobile/src/tasks/blank-workspace-create.tsmobile/src/worktree/use-retired-worktree-names.tssrc/main/ai-vault/claude-project-dir-encoding.test.tssrc/main/ai-vault/claude-project-dir-encoding.tssrc/main/ai-vault/session-scanner-scope-discovery.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/persistence-worktree-name-retirement.test.tssrc/main/persistence.tssrc/main/runtime/fit-override-integration.test.tssrc/main/runtime/graph-sync-mobile-snapshot-gating.test.tssrc/main/runtime/graph-sync-payload-partition.test.tssrc/main/runtime/mobile-presence-lock.test.tssrc/main/runtime/mobile-subscribe-integration.test.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/remote-desktop-driver.test.tssrc/main/runtime/rpc/methods/worktree-create-args.test.tssrc/main/runtime/rpc/methods/worktree-create-args.tssrc/main/runtime/rpc/methods/worktree-schemas.tssrc/main/runtime/rpc/methods/worktree.tssrc/main/runtime/terminal-query-responder.test.tssrc/main/worktree-name-retirement.test.tssrc/main/worktree-name-retirement.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/lib/pending-worktree-creation.tssrc/renderer/src/lib/worktree-creation-flow.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.tssrc/renderer/src/web/web-preload-api.tssrc/shared/constants.tssrc/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/main/persistence.ts
- src/shared/constants.ts
- src/main/ipc/worktree-remote.ts
- src/main/persistence-worktree-name-retirement.test.ts
- mobile/src/worktree/use-retired-worktree-names.ts
- src/main/runtime/orca-runtime.ts
- src/main/ipc/worktrees.ts
- src/main/ipc/worktrees.test.ts
Reverts the collision-key storage key. It was a function of workspaceDir, nestWorkspaces, worktreeBasePath and repo.path, so toggling any one of those orphaned every retirement for every affected repo at once — trading a rare churn (remove/re-add) for a common one. The read path already unions by cwd namespace at query time, so cross-repo sharing never depended on the storage key. Instead, address the growth and orphaning directly: - Drop the registry in removeProject, and in removeProjectForHost once the last host's copy of the repo id is gone, alongside the sparse-preset deletes that already follow this convention. - Bound each repo's registry. The cap sits far above the 552-name pool because evicting inside it would reissue a name whose agent state is still on disk; only -2/-3 tier accumulation can ever reach it. - Carry retirements through profile transfer, re-keyed to the destination repo id and dropped from the source, mirroring sparsePresetsByRepo. Separately, fix the backfill merge: the scan promise is cached per cwd namespace, but it closed over the first repo id that triggered it, so a second repo in the same namespace received nothing. The scan stays shared; the merge moves out of the cached promise and runs for whichever repo asked. Local repos re-seed on re-add through that backfill. SSH repos do not — the scan cannot see the execution host — which is now stated in the module.
Names the trap directly: the neighbouring 50/200 bounds cap histories, so lowering this one to match them would silently start reissuing names whose agent state is still on disk. Also states that oldest-first eviction is a deliberate least-bad choice rather than a neutral one.
This client hand-enumerates worktree.create params, so the new optional field was silently dropped and typecheck could not see it. On web and paired-desktop the host therefore never received it: generated names were never retired, and the host-side skip that backstops a stale suggestion was disabled too. The same client does fetch retired names for suggestions, so it was filtering against a registry nothing ever wrote to. The test asserts both directions, and fails without the fix.
isAutoGeneratedCreatureBranchName strips exactly one trailing -N, which is right for auto-rename eligibility but wrong here. Once the pool is spent the suggester emits nautilus-2, and a collision on that yields nautilus-2-3 — which a single strip leaves as nautilus-2, not a pool name, so retirement no-opped at exactly the tier where every base name is already gone. Strip repeated suffixes locally rather than moving the auto-rename predicate.
The backfill runs on composer repo-select, not just at create time, and it
derived the probe path synchronously — which for a WSL repo with a mirrored
workspace dir reaches getWslHome and its blocking execFileSync('wsl.exe').
A stopped distro froze the main process for up to 5s on composer open.
Adds an async twin of computeWorktreePath and uses it for the probe. Resolving
the home there also warms the shared cache, so later sync callers are free.
Also stops memoizing the collision key when the WSL home is still unresolved:
only the success path is cached upstream, so caching the fallback namespace
would strand the repo there for the rest of the session.
refreshKey changes on every workspace-list mutation, so create-multiple refetches after each create and the hook returned an empty list until the refetch landed — precisely the window in which resetForNextCreate clears the name field and a fresh suggestion is drawn. Keep the previous answer while revalidating and reset only when the repo changes; a failed refresh keeps what was already loaded rather than un-retiring everything. Also makes the returned array referentially stable, so the suggestion memo downstream stops rerunning on every refetch.
Electron QA — worktree-name retirement (PR 14350)Dev build: What I exercisedOpened this PR's Electron dev build over CDP and used the real New Workspace composer plus the worktree create/delete path. Playwright pointer clicks and a live The name field does not show a pre-filled creature name. It stays blank with the Smart placeholder; the generated name is chosen at submit time when the field is empty. Observed1. Baseline composer. Create worktree dialog opens with an empty name field and an enabled Create worktree button. 2. No reissue (core fix). Generated create of 3. Repeat. Same pattern: generated 4. User-typed names still work (regression guard). After 5. Create-button steadiness. While the composer sat idle, Create worktree stayed enabled (not disabled). A second idle capture looked the same. I could not watch it across a live composer create/delete because CDP died once the composer mounted. Landing/context for the isolated instance: Could not verify
Bottom lineOn this tree, generated names were not reissued after delete ( |
…enerated-workspace-names # Conflicts: # src/preload/api-types.ts # src/shared/types.ts
…ation The desktop and mobile hooks that fetch retired names had already drifted four ways. The transports genuinely differ (IPC vs RPC), but the caching rules must not, and mobile's copy reset to [] on any error -- which un-retires every name for the rest of the sheet session, the one outcome retirement exists to prevent. Moves the rules into src/shared/worktree/retired-name-cache: response normalization, the never-leak-across-repos rule, and the hold-previous-on- failure rule. Pure, no React, because src/shared is on the main process's import graph. Each platform keeps its own transport and effect. Mobile moves up to desktop's behavior: it now holds the previous answer through a failed refresh, and refetches when the workspace list changes instead of never refetching after mount. Also drops the unused `loading` return. Neither platform consumed it; its only consumer was the Create-button gate reviewed out earlier, and removing it makes that regression unexpressible.
…enerated-workspace-names
Main dropped the src/shared/types barrel, so the retirement module's import resolved locally but not against the PR's merge base.
…enerated-workspace-names # Conflicts: # src/main/runtime/rpc/methods/worktree.ts
… not eviction Retirement is a correctness guarantee — a spent name's directory may still hold agent conversation state keyed by that cwd — so the 2000-entry cap was the wrong shape: reaching it handed a name back. At the owner's measured rate (~6.6 pool names retired per day in one repo) the cap was ~9 months out. Names come from a fixed 552-entry pool and the suggester only reaches tier N+1 once every tier-N name is taken, so a completed tier is exactly a set that no longer needs listing. A row is now a watermark plus the names above it: reads answer at-or-below the watermark with no lookup, and compaction drops the 552 entries the watermark now covers. Bounded at one pool per repo forever, with no eviction and nothing un-retired. Tiers can complete out of order (a create-time collision can spend `nautilus-2` while tier 1 is open), so compaction loops and higher-tier names simply wait. The RPC result carries the watermark beside the names as a new field; a client predating it reads the names only and under-retires the compacted tiers, which degrades to the pre-retirement behavior rather than breaking.
Desktop validation (PR commit
|
Windows QA @ 440419b (review-only)Confirmed HEAD Flow: empty-name create → shrimp → delete → next empty-name create → brill (not reused). Registry after delete still had WSL: added
|
…enerated-workspace-names # Conflicts: # src/renderer/src/store/slices/worktrees.ts
…e lane went silent STA-4471 is now proven: restoring the #14350 gate as a mutation turns four tests RED across the runtime, SSH and local create paths. fix-4472-4473 typechecks and its 63 tests pass at head, so the torn-write warning applies to its intermediate commits but not to its final state.
… (STA-4471) #14350 gated the whole of generated-name retirement on the new optional `nameWasGenerated` bit, conflating two decisions that pull in opposite directions: - *Which cwd a create may land on* genuinely belongs to the client. A generated name is one of ours — nothing was chosen — so folding it onto the canonical tier ladder and stepping over cwds this host already spent costs the user nothing. A name the user typed is a request; `nautilus` stays `nautilus` even where that cwd is retired, because silently handing back `nautilus-2` is the worse surprise. This half stays gated, and clients that predate the bit are read as typing users, exactly as before #14350. - *Whether the created name is recorded as spent* never belonged to the client. An older paired or mobile client omits the bit but still hands back pool-shaped names, and a registry that never learns about them lets the very next generated create collide with one. Recording is only ever a write — `addRetiredWorktreeName` self-gates on pool shape, so a coined name like `fix-login` is never recorded, and no recorded name ever redirects a typed one. The three create paths — `OrcaRuntimeService.createManagedWorktree` (runtime, mobile, CLI), `createRemoteWorktree` (SSH) and `createLocalWorktree` (desktop IPC) — each carried their own copy of the gate plus candidate selection, which is how one rule ended up applied inconsistently. They now share `planWorktreeCreateNames`, which is unit-tested directly. No wire change: no new field, no new opcode, nothing removed from what the host publishes. A name outside the creature pool never loads the registry, and neither does a typed name, so neither pays for the deadline-less backfill scan.
* fix(worktree): never reissue a generated workspace name
Generated workspace names were deduped only against currently-live
worktrees, so deleting a workspace returned its name to the pool. A later
workspace could draw the same name, land on the same directory path, and
inherit the previous occupant's agent conversation history — coding-agent
CLIs key their prompt history and transcripts by cwd.
Names are now retired permanently per repo. The registry is written in
main with the name Git actually used (the create loop can advance past a
requested name on collision), and seeded once per run from workspace
directories and surviving agent transcript buckets so already-spent names
are excluded from the start. Suggestions degrade to -2, -3 variants
instead of recycling, and those variants retire too.
User-typed names are untouched: retirement filters suggestions only.
* fix(mobile): honor retired workspace names, on one shared implementation
Mobile hand-duplicated the desktop name-suggestion algorithm and deduped
only against live workspaces, so a phone could still be offered a name
whose deleted workspace left agent conversation state behind at that path.
Both platforms now call one shared selector in src/shared, so the two can
no longer drift. The host publishes retired names as an optional field on
the existing worktree.list response, and mobile fetches them per selected
repo while the create sheet is open — mirroring the desktop hook.
Mobile never calls worktree.list for its catalog (it uses worktree.ps,
which carries rows only), so this is a targeted request rather than a
change to the catalog or its cache. Hosts predating the field omit it and
mobile falls back to live-only dedupe, which is the pre-change behavior.
* fix(worktree): close retirement consistency gaps
* test(worktree): cover retirement runtime contracts
* fix(worktree): retire generated collision names
* fix(worktree): enforce retired names at creation
* refactor(ai-vault): extract the Claude project-dir encoder
The bucket-name encoder and its scope-boundary check were private to the
session scanner, so a second consumer had to reimplement them — and got the
per-character encoding wrong. Move both to a shared module with direct tests.
* fix(worktree): make the retirement seed scan actually match buckets
The bucket encoder collapsed runs of non-alphanumerics while the real one
emits a dash per character, so every dot-path bucket missed and the Windows
default workspace root (C:\...) matched nothing at all. Reuse the shared
encoder and its boundary check, which also stops a repo absorbing a sibling
whose path merely shares its prefix.
Also:
- Derive the workspace leaf by stripping the known encoded parent instead of
guessing from trailing dash segments, which retired the parent directory's
name whenever a workspace was named numerically.
- Reuse isAutoGeneratedCreatureBranchName so the -10 and -100 tiers retire.
- Drop the .codex/sessions root: Codex keeps the cwd inside the transcript
rather than in a directory name, so the scan could only ever see a year
folder. Reading transcript contents is not a trade this feature justifies,
so the gap is documented instead.
- Honor CLAUDE_CONFIG_DIR, which relocates the bucket root.
- Delete the unused retirableLeafName export.
Tests write buckets with the real per-character encoding against a fake home,
covering POSIX, dot-directory, Windows drive and WSL UNC roots; all three
platform cases fail against the previous encoder.
* fix(worktree): retire only generated names, keyed by cwd namespace
Two problems in the host-side registry.
Retirement fired for every create, including names the user typed. The
creature pool contains ordinary words — orca, runner, sole, molly, oscar — so
typing a retired 'nautilus' silently produced directory and branch
'nautilus-2' and burned the name for good. Creates now carry an explicit
nameWasGenerated flag; both the skip and the retire are gated on it, and it
defaults to false so CLI and automation callers are unaffected.
The registry was keyed by repo id, but both readers already discarded the id
and unioned by the cwd collision key, because the collision this prevents is
on the path. Keying by that namespace directly fixes several things at once:
entries no longer orphan when a repo is removed, remove/re-add no longer loses
every retirement for an unchanged path, the missing removeProject prune is
moot, and the backfill promise no longer merges into only the first repo id it
saw. The feature is unreleased, so no migration is needed.
Also:
- Memoize the collision key. It runs computeWorktreePath, which for a WSL repo
is a blocking execFileSync('wsl.exe') whose failure path is uncached, and
the previous code recomputed it once per repo on every create and every
listRetiredNames call.
- Drop retiredNamesByRepo from the worktree list result. It had no readers and
leaked onto 'orca worktree list --json', and its awaited backfill sat on CLI
selector resolution. The dedicated listRetiredNames RPC keeps its consumers.
- Make the three RuntimeStore methods required. RuntimeStore is file-private
with two constructors, so the 'older embedders' the optionality protected do
not exist, and the optional chain silently returned no retirements.
- Revert the unrelated forceDeleteBranch rewrite, and make room under the
file's line budget by extracting the create-args mapping instead.
* fix(worktree): send name provenance and stop gating Create on the fetch
Desktop and mobile now mark a create as generated-name only when the user
typed nothing and the composer fell back to the suggestion, so the host knows
which names it may retire.
Remove the retired-names loading gate from every create path. The host already
skips retired candidates before doing any git work, so the client gate bought
nothing while it could disable Create for the length of a full mobile
reconnect ladder (the wait had no timeout) and blank the desktop button
between queued creates. The suggestion still waits; the button never does.
Also make the web client call worktree.listRetiredNames instead of hardcoding
an empty list — the method is registered and mobile-allowlisted, so the
comment claiming no wire call existed was wrong — and filter the mobile
response to strings so a malformed row cannot throw during normalization.
* fix(worktree): key retirement by repo id and prune it with the repo
Reverts the collision-key storage key. It was a function of workspaceDir,
nestWorkspaces, worktreeBasePath and repo.path, so toggling any one of those
orphaned every retirement for every affected repo at once — trading a rare
churn (remove/re-add) for a common one. The read path already unions by cwd
namespace at query time, so cross-repo sharing never depended on the storage
key.
Instead, address the growth and orphaning directly:
- Drop the registry in removeProject, and in removeProjectForHost once the last
host's copy of the repo id is gone, alongside the sparse-preset deletes that
already follow this convention.
- Bound each repo's registry. The cap sits far above the 552-name pool because
evicting inside it would reissue a name whose agent state is still on disk;
only -2/-3 tier accumulation can ever reach it.
- Carry retirements through profile transfer, re-keyed to the destination repo
id and dropped from the source, mirroring sparsePresetsByRepo.
Separately, fix the backfill merge: the scan promise is cached per cwd
namespace, but it closed over the first repo id that triggered it, so a second
repo in the same namespace received nothing. The scan stays shared; the merge
moves out of the cached promise and runs for whichever repo asked.
Local repos re-seed on re-add through that backfill. SSH repos do not — the
scan cannot see the execution host — which is now stated in the module.
* docs(worktree): spell out why the retirement bound sits above the pool
Names the trap directly: the neighbouring 50/200 bounds cap histories, so
lowering this one to match them would silently start reissuing names whose
agent state is still on disk. Also states that oldest-first eviction is a
deliberate least-bad choice rather than a neutral one.
* fix(worktree): send name provenance from the web runtime client
This client hand-enumerates worktree.create params, so the new optional field
was silently dropped and typecheck could not see it. On web and paired-desktop
the host therefore never received it: generated names were never retired, and
the host-side skip that backstops a stale suggestion was disabled too. The same
client does fetch retired names for suggestions, so it was filtering against a
registry nothing ever wrote to.
The test asserts both directions, and fails without the fix.
* fix(worktree): retire names that took more than one collision suffix
isAutoGeneratedCreatureBranchName strips exactly one trailing -N, which is
right for auto-rename eligibility but wrong here. Once the pool is spent the
suggester emits nautilus-2, and a collision on that yields nautilus-2-3 —
which a single strip leaves as nautilus-2, not a pool name, so retirement
no-opped at exactly the tier where every base name is already gone. Strip
repeated suffixes locally rather than moving the auto-rename predicate.
* perf(worktree): keep the retirement backfill off the blocking WSL probe
The backfill runs on composer repo-select, not just at create time, and it
derived the probe path synchronously — which for a WSL repo with a mirrored
workspace dir reaches getWslHome and its blocking execFileSync('wsl.exe').
A stopped distro froze the main process for up to 5s on composer open.
Adds an async twin of computeWorktreePath and uses it for the probe. Resolving
the home there also warms the shared cache, so later sync callers are free.
Also stops memoizing the collision key when the WSL home is still unresolved:
only the success path is cached upstream, so caching the fallback namespace
would strand the repo there for the rest of the session.
* fix(worktree): hold retired names across a refresh instead of blanking
refreshKey changes on every workspace-list mutation, so create-multiple
refetches after each create and the hook returned an empty list until the
refetch landed — precisely the window in which resetForNextCreate clears the
name field and a fresh suggestion is drawn. Keep the previous answer while
revalidating and reset only when the repo changes; a failed refresh keeps what
was already loaded rather than un-retiring everything.
Also makes the returned array referentially stable, so the suggestion memo
downstream stops rerunning on every refetch.
* refactor(worktree): put the retired-name cache rules on one implementation
The desktop and mobile hooks that fetch retired names had already drifted
four ways. The transports genuinely differ (IPC vs RPC), but the caching
rules must not, and mobile's copy reset to [] on any error -- which
un-retires every name for the rest of the sheet session, the one outcome
retirement exists to prevent.
Moves the rules into src/shared/worktree/retired-name-cache: response
normalization, the never-leak-across-repos rule, and the hold-previous-on-
failure rule. Pure, no React, because src/shared is on the main process's
import graph. Each platform keeps its own transport and effect.
Mobile moves up to desktop's behavior: it now holds the previous answer
through a failed refresh, and refetches when the workspace list changes
instead of never refetching after mount.
Also drops the unused `loading` return. Neither platform consumed it; its
only consumer was the Create-button gate reviewed out earlier, and removing
it makes that regression unexpressible.
* fix(worktree): import shared types from their real modules
Main dropped the src/shared/types barrel, so the retirement module's import
resolved locally but not against the PR's merge base.
* refactor(worktree): bound the retirement registry by tier compaction, not eviction
Retirement is a correctness guarantee — a spent name's directory may still hold
agent conversation state keyed by that cwd — so the 2000-entry cap was the wrong
shape: reaching it handed a name back. At the owner's measured rate (~6.6 pool
names retired per day in one repo) the cap was ~9 months out.
Names come from a fixed 552-entry pool and the suggester only reaches tier N+1
once every tier-N name is taken, so a completed tier is exactly a set that no
longer needs listing. A row is now a watermark plus the names above it: reads
answer at-or-below the watermark with no lookup, and compaction drops the 552
entries the watermark now covers. Bounded at one pool per repo forever, with no
eviction and nothing un-retired.
Tiers can complete out of order (a create-time collision can spend `nautilus-2`
while tier 1 is open), so compaction loops and higher-tier names simply wait.
The RPC result carries the watermark beside the names as a new field; a client
predating it reads the names only and under-retires the compacted tiers, which
degrades to the pre-retirement behavior rather than breaking.
* fix(worktree): preserve generated name retirement across failures


































ELI5
Workspaces get a random sea-creature name. When you deleted one, its name went back in the hat — so a new workspace could get the same name, land in the same folder, and open with the previous workspace's chat history behind it. Now a name Orca picked is used once and never handed out again. A name you type is still yours to reuse.
What Changed
retiredWorktreeNamesByRepo).workspaceDir,nestWorkspaces,worktreeBasePathandrepo.path, and keying storage on it would orphan every affected repo's retirements the moment a user toggles any one of those — a far more common event than removing and re-adding a repo.removeProjectand inremoveProjectForHostonce the last host's copy of the id is gone, alongside the sparse-preset deletes that already follow that convention. It is also bounded per repo, and carried through profile transfer re-keyed to the destination repo id.nameWasGeneratedflag, set by the desktop composer and the mobile create sheet exactly where they fall back to the suggestion. Both the "skip a retired candidate" and the "record this name as spent" steps are gated on it, and it defaults to false so CLI and automation callers behave exactly as before. This matters because the pool contains ordinary words —orca,runner,sole,emperor,permit,molly,oscar— that people type on purpose.-2,-3; those variants retire too, and tier numbering can no longer rewind onto a spent variant after a deletion.src/shared/worktree-name-suggestion.ts). Mobile previously hand-duplicated the algorithm; each platform now keeps a thin wrapper that builds its own used-set and delegates, so the two cannot drift apart again.worktree.listRetiredNamesRPC. Mobile and the web client both call it per selected repo while the create sheet is open, mirroring the desktop hook without exposing the broader worktree-list surface.Why
Coding-agent CLIs key prompt history and transcripts by cwd. A recycled name means a recycled path, and the new occupant silently inherits the dead workspace's conversation.
Measured on one machine: of 552 names, 187 already carried chat history and 119 of those workspaces were deleted — the name freed, the history still on disk. That is roughly a 28% chance any new workspace inherits a stranger's chat.
Two alternatives were considered and rejected:
gar-a7f3). Orca reads the path leaf in several places — display name, attachment label, smart sort, and one path that derives a branch from it — so a suffix would degrade all of them plus the user's shell prompt.Retirement fixes it with no visible change and no writes to another tool's files. The pool becomes a consumable: at the observed rate the 552 names last about a year before the first
-2appears, and expanding the list later extends that.Linked Issue
STA-4189 — https://linear.app/stably/issue/STA-4189/fix-duplicate-worktree-naming-bug-in-claude-tui-message-history
Fixes #
Visual Proof
N/A— no UI change by design. The point of this approach over a suffix is that suggested names look exactly as they do today; only which name is offered changes.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
src/main/worktree-name-retirement.test.ts— the seed scan against a fake home with buckets written using the real per-character encoding, covering plain POSIX, a dot-directory root, aC:\drive root, and a\\wsl$\UNC root. The three platform cases fail against the encoder this PR replaces, which is how the gap below was found. Plus leaf extraction, sibling-prefix rejection, cross-repo sharing within one namespace, and a test that a repo holding no retirements never costs a path probe (which for a WSL repo is a blockingwsl.execall).src/main/ai-vault/claude-project-dir-encoding.test.ts— direct tests for the shared encoder and its scope-boundary matcher.src/main/persistence-worktree-name-retirement.test.ts— per-repo scoping, case/whitespace normalization, defensive copy, merge semantics, survives reload, degrades to empty on a corrupt map, drops the registry on repo removal (and keeps it while another host row survives), and enforces the per-repo bound.src/main/orca-profiles/profile-project-transfer.test.ts— retirements follow a project into another profile under the new repo id. Verified non-vacuous: removing the re-key fails it.Create-path provenance is pinned at every hop: the RPC arg mapping (
worktree-create-args.test.ts), the local and SSH host paths (worktrees-windows.test.ts,worktrees.test.ts), the runtime path (orca-runtime.test.ts), the desktop store slice and background create flow, and the mobile create payload. Each asserts both directions — a generated name is skipped and retired, a user-typed one is neither.src/shared/worktree-name-suggestion.test.ts— the shared core: tier degradation, no rewind onto a spent variant, tier advance. Anchored on absence from the used set rather than pool position, so they cannot silently pass against a filtered pool.src/renderer/.../worktree-name-suggestions.test.tsandmobile/src/components/worktree-name-suggestion.test.ts— a retired name is never reissued on either platform, layered on top of the existing cross-repo live dedup.Verified locally:
pnpm typecheckclean on all three desktop projects and on mobile;oxlintclean on every changed file; 4,448 tests pass under the root config across the retirement, persistence, worktree, runtime, RPC, and renderer suites, and all 3,461 mobile tests pass.Note on the excluded lockfile change: mobile's toolchain was non-functional in my worktree before this work —
mobile/node_moduleswas incomplete, sotscandvitestboth failed on pre-existing files. I ranpnpm install --frozen-lockfileinsidemobile/to get a real signal. The resultingmobile/pnpm-lock.yamlchurn is not included here. It is not purely registry metadata: it also contains resolved transitive pin drift (@babel/*7.29.7 → 7.29.8,@types/node26.1.1 → 26.1.2). It is harmless — the install set is unchanged in both directions, with zero integrity, resolution, or package-entry changes — but it is unrelated to this PR.Platforms: developed and tested on macOS. Path handling is separator-agnostic (native, WSL, and SSH-host paths) rather than using a platform-bound basename, and the Windows and WSL bucket forms are covered by unit tests, but neither platform was exercised by hand. Mobile is verified by typecheck and unit tests, not on a device or simulator.
Review
C:\. Now shared, with the sibling-prefix boundary check that stops…/orcafrom absorbing…/orca-secret.createFolderWorkspacenever derives a path from the name (the path is the folder; the name only becomesdisplayName), so there is no directory to collide and nothing to retire.renameWorktreeFolderOnFirstWorkmoves a creature-named folder to a work-derived name, which frees the creature name back into the pool while the agent history for the old path stays on disk. Recording at creation covers this; deriving the used-set from live worktrees never could.Known gaps
~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonlrather than in a directory name, so there is nothing to read from directory listings, and parsing user conversation files to seed a name registry is not a trade this feature justifies. Names spent only under Codex before this change stay issuable. Every name spent after it is recorded at create time regardless of which agent runs there, so this is a one-time seeding gap, not an ongoing one.-2/-3tier accumulation.nameWasGeneratedis a new optional create param whose absence means "user-typed", which is the pre-retirement behavior, so an older client talking to a newer host simply gets no retirement. No stream opcode or existing response shape changed. The feature is unreleased, and the storage key is unchanged from the first revision of this PR, so no migration is needed.computeWorktreePath, which for a WSL repo makes a blockingwsl.execall whose failure path is uncached upstream, so the key is memoized and the peer scan is lazy — a repo's own retirements never touch a path, and a peer's namespace is derived only once that peer is known to hold retirements. The whole path is also gated onnameWasGenerated, so CLI and automation creates never reach it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)