Skip to content

fix(workspace): a typed workspace name names its own branch - #251

Merged
nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/typed-label-names-its-branch
Oct 30, 2026
Merged

nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/typed-label-names-its-branch

Conversation

@nplez1

@nplez1 nplez1 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

What

A typed workspace name now names its own branch. Branch/Workspace Naming creates the folder
Branch-Workspace-Naming and the branch Branch-Workspace-Naming; no marine-creature name
appears anywhere.

input in the New Workspace name field workspace branch renamed on first work?
Branch/Workspace Naming (typed) Branch/Workspace Naming Branch-Workspace-Naming <- was mahimahi no
nautilus (typed) nautilus nautilus no — your name wins
left blank creature name creature name yes, still (unchanged)

A blank name is untouched: it still gets a generated creature name for both, that branch is still
eligible for Auto-rename branch & worktree, and the setting's own copy — "Only branches Orca named
itself are renamed" — is now what the code checks.

Root cause

Upstream 9608420517b ("Keep workspace labels independent of automatic branch names", stablyai#32919) added
src/main/worktree-create-branch-seed.ts, whose whole job was to discard a typed label and seed the
branch with a random creature name:

// Typed labels stay independent of the placeholder consumed by first-work naming.
return label.kind === 'user' && label.value ? selectSuggestedCreatureName([]) : undefined

The design assumes the first-work rename will replace that placeholder. On the reporting machine it
never runs: after the agent's working hook the main-process trace records no rev-parse --abbrev-ref HEAD for the worktree and no branch rename, so the creature name is permanent. docs/site/content/docs/first-session.mdx
documents the behaviour users expect instead — a typed task name is the name, and only a blank one
becomes a creature — so this restores it.

Changes

  • delete src/main/worktree-create-branch-seed.ts — it had no other job (rg finds no remaining
    reference anywhere in src/, mobile/, tests/)
  • src/main/ipc/worktree-remote.ts (desktop / remote-host creates) and
    src/main/runtime/runtime-local-worktree-create-candidate.ts (runtime-host creates): drop the seed
    and fall back to effectiveSanitizedName, which is what every pre-Keep workspace labels independent of automatic branch names stablyai/orca#32919 create did
  • collision suffixes now move branch and folder together (label-2 / label-2) instead of a fresh
    creature name per attempt against a suffixed folder
  • branchNameWasGenerated on the worktree meta, stamped by all three create paths
    (worktree-remote.ts, runtime-local-worktree-materialization.ts, provisioned-root-checkout.ts)
    as nameWasGenerated === true && !branchNameOverride. canRenameOrcaCreatedBranch requires it not
    to be false, so a typed creature word is not renamed out from under the user while a generated one
    still is. Legacy workspaces carry no flag and keep today's behaviour
  • a .lock branching name is rewritten to -lock in computeBranchName /
    computeValidatedBranchName, not in sanitizeWorktreeName: git refuses a ref, and
    sanitizeWorktreeName also names project containers and clone-placement folders, where rewriting
    would have moved a project already called x.lock into a new sibling folder. The folder keeps its
    name, as it already does for an explicit branch override. toRefLeaf matches any case, because
    refs/heads/foo.LOCK shares a loose-ref filename with foo's lock on the case-insensitive
    filesystems macOS and Windows use by default
  • tests: the shared harness no longer asserts that a rename landed; it returns { worktree, renamed }
    and one labelOnlyCreateCases table carries each row's expected branch and expected rename, so all
    three suites assert the same five cases
  • local/sync/convergence-ledger.md: entry under "Worktree create and removal" so the next sync
    resolver knows the seed must not come back

Verification

  • pnpm test on the nine suites covering these paths — 252 passed:
    runtime-local-worktree-create, worktrees-create-label-only-first-work,
    worktrees-create-first-work-rename, worktree-logic, first-work-branch-rename,
    runtime-local-worktree-create-pr-conflicts, worktrees-create-metadata-persistence,
    provisioned-root-checkout, worktrees-local-create-flow. The table pins the reported input, an
    ASCII label, a CJK label, a typed creature word, and a generated creature name.
  • Every new assertion was checked for teeth rather than assumed:
    • neutering canRenameOrcaCreatedBranch fails exactly the typed-nautilus row;
    • tightening the gate to === true fails exactly the legacy no-flag row;
    • removing toRefLeaf from computeValidatedBranchName fails exactly the create-path .lock test.
  • .lock behaviour is asserted against real git: git check-ref-format refs/heads/foo.lock exits 1,
    refs/heads/foo-lock and refs/heads/foo.LOCK exit 0 — hence the any-case rewrite plus the folder
    keeping the name.
  • pnpm tc:node clean (probed: an injected type error makes it exit 1, so the pass is not a no-op).
  • pnpm run check:code-quality:changed — 0 findings across 12 changed files.
  • pnpm check:changed is red for two reasons that are not this diff and reproduce at the base
    commit 24ebadb5a8d: max-lines-ratchet flags its own fixture strings in
    tests/tools/upstream-file-comments.test.mjs and holds a stale baseline row for
    register-core-handlers.ts; and its unfiltered vitest step exceeds its 300 s step deadline.
  • Not run: the full unit suite (release gate; this diff touches no global input) and in-app validation
    (the running Orca NP build predates these commits).

Review

Reviewed by claude/opus (Opus 5.5), high: R1 clean; R2 clean; R3 clean; R4 clean — no BLOCKER or SHOULD-FIX findings in any round.

Four rounds, each on a committed revision, each a delta from the previous one:

  • R1 (f85f31e) — seed removal is complete and both call sites match their pre-Keep workspace labels independent of automatic branch names stablyai/orca#32919 shape;
    branchNameOverride, exactBranchName, cliProvenance: created-by-cli and nameWasGenerated still
    win; collision suffixes keep folder and branch in step; Unicode labels stay valid through
    sanitizeWorktreeName + computeValidatedBranchName + git check-ref-format.
  • R2 (631b948) — the new meta flag survives the setWorktreeMeta write path the same way
    orcaCreationSource does, with no field allowlist to extend; !== false blocks no rename that
    should happen and is the right default for legacy rows made under upstream's seed.
  • R3 (6ded5dd) — moving the .lock rule to the ref builders leaves every create path's branch
    passing check-ref-format (collision suffixes, prefixes, existing-branch checkout, the first-work
    rename, provisioned roots, CLI/mobile); the project-container hazard is gone.
  • R4 (d5868c8) — the create-path test covers all three return paths of
    computeValidatedBranchName with literal expectations, and the any-case rewrite introduces no new
    collision class (conflict checks run on the rewritten name).

Findings below were MINOR/NIT and are recorded rather than fixed:

  • MINOR (R1) — scope of the report. This PR fixes the random branch; it cannot explain a random
    workspace name. The seed only ever set the branch, and the display name has always come from the
    label. That symptom was not reproduced here; its likely cause is a blank or generated name
    (displayNameKind: 'generated'). Out of scope, tracked separately.
  • NIT (R1) — the two IPC suites edited here are near-duplicates left by an upstream file split, so
    every future edit must be made twice. Folding them means deleting an upstream-owned file and buying a
    sync conflict; deliberately left.
  • NIT (R3) — buildProvisionedRootMeta stamps the flag but has no test of its own; it needs a
    repo/settings fixture that does not exist in provisioned-root-checkout.test.ts, and the stamp
    mirrors the two covered paths.
  • NIT (R3/R4) — after a collision, a .lock label's branch and folder diverge
    (foo.LOCK-2 vs foo.LOCK). Cosmetic, and already true of the lowercase case before this PR.
  • NIT (R4) — on a case-sensitive filesystem foo.LOCK was a legal ref and is now rewritten to
    foo-lock. The branch changes on every platform so the result is the same everywhere; folders and
    display names are untouched.

Sync note

This reverts a deliberate upstream decision (stablyai#32919). The next sync will conflict on the deleted
src/main/worktree-create-branch-seed.ts and on the two call-site lines; re-apply the revert there.
The ledger entry above is the durable record.

Upstream 9608420 (stablyai#32919, "Keep workspace labels independent of
automatic branch names") made `selectWorktreeCreateBranchSeed` throw the
typed label away and seed the branch with a random marine-creature name, so
the first-work AI rename could name the branch from the agent's work later.
The label was only ever a display name.

That leaves a workspace created as "Branch/Workspace Naming" sitting on
branch `mahimahi` — the folder is right, the branch is a fish — and it stays
there rather than being renamed: on this machine the first-work rename never
runs (the trace log records no branch-rename git call after the agent's
`working` hook), so the creature name is permanent rather than transient.
`docs/site/content/docs/first-session.mdx` documents the behaviour users
expect: a typed task name is the name, and only a blank one falls back to a
creature.

So a typed label now seeds its own branch: the create path falls through to
`effectiveSanitizedName`, which is what every pre-stablyai#32919 create did, and
which keeps `-2` collision suffixes in the directory and branch together.
`selectWorktreeCreateBranchSeed` had no other job, so it and its two call
sites go.

Unchanged: a blank name still gets a generated creature name for both the
workspace and the branch, and that branch is still creature-shaped, so the
first-work rename can still improve it. Only typed labels lose the rename,
which is the point — the branch is already the name the user chose.

Verification: `pnpm test` on the three first-work harness suites,
`runtime-local-worktree-create.test.ts` (40 passed),
`runtime-local-worktree-create-pr-conflicts.test.ts`,
`first-work-branch-rename.test.ts`, `worktrees-create-base-status.test.ts`;
`pnpm tc:node`; `pnpm run check:code-quality:changed`.

Sync note: this reverts a deliberate upstream decision, so the deleted
`src/main/worktree-create-branch-seed.ts` is a modify/delete conflict on the
next sync. It is not registered in local/sync/expected-deletions.json
because that register holds settled fork decisions, not PR-branch state.
Two review findings from the first round, both about a typed name losing
out to machinery that assumes Orca named the branch.

A typed label that happens to be a creature word (`nautilus`) was still
renamed on first work: eligibility tested the branch shape only, so the
user's own name came back as an AI slug. The create paths now stamp
`branchNameWasGenerated` on the worktree meta — `nameWasGenerated === true`
and no branch override — and `canRenameOrcaCreatedBranch` requires it not to
be `false`. That is the signal the setting's own copy promises ("Only
branches Orca named itself are renamed"); a blank name still gets a creature
name for both label and branch and stays rename-eligible. Legacy workspaces
carry no flag, so they keep today's behaviour rather than losing a rename
they always had.

A label ending in `.lock` produced a ref `git check-ref-format` rejects, so
the create failed at the last step. `sanitizeWorktreeName` now rewrites the
suffix to `-lock`, next to the `..` rule it already had for the same reason.
Only the lowercase suffix is rewritten: git accepts `.LOCK`.

Also records the revert in local/sync/convergence-ledger.md under "Worktree
create and removal", so the next sync resolver knows the creature seed must
not come back.

Verification: 225 tests across the seven suites covering these paths,
`pnpm tc:node`, `pnpm run check:code-quality:changed`. The new typed
`nautilus` row fails if the gate ignores the flag (checked by neutering it),
and the `.lock` rewrite is asserted against what `git check-ref-format`
actually accepts.
Round 2 left three findings worth acting on, plus two coverage gaps.

The `.lock` rewrite moves from `sanitizeWorktreeName` to the branch-name
builders. A ref is what git refuses, not a directory: `sanitizeWorktreeName`
also names project containers and clone placement folders, so rewriting
there would have moved a project already called `x.lock` into a new sibling
folder. `computeBranchName` and `computeValidatedBranchName` now rewrite the
leaf, which also covers the first-work rename's generated slugs; the folder
keeps the name, the way it already does for an explicit branch override.

`buildProvisionedRootMeta` stamps `branchNameWasGenerated` too, so a typed
creature word on the provisioned-root path is not renamed out from under the
user either.

Coverage for the two edges round 2 named: a workspace whose meta predates
the flag still gets its generated creature branch renamed (asserted by
deleting the flag from a real create's meta and running the real gate), and
a generated name with an explicit branch override stamps `false` and is
never renamed. Both were checked for teeth by tightening the gate to
`=== true`, which fails exactly the legacy case.

Verification: 251 tests across the nine suites covering these paths,
`pnpm tc:node`, `pnpm run check:code-quality:changed`.
Round 3's one MINOR: the new `.lock` test covered only `computeBranchName`,
which the first-work rename uses, so deleting `toRefLeaf` from
`computeValidatedBranchName` — the builder every local and remote create
actually goes through — would have left the suite green. It now has its own
cases for the bare, custom-prefix and git-username shapes, checked for teeth
by removing the rewrite and watching exactly that test fail.

Also widens `toRefLeaf` to `.lock` in any case. git's check-ref-format only
rejects the lowercase suffix, but `refs/heads/foo.LOCK` occupies the same
loose-ref filename as `foo`'s lock file on the case-insensitive filesystems
macOS and Windows use by default, so a later update of branch `foo` would
fail with "Unable to create ... lock: File exists". Rewriting both cases
avoids creating such a ref; the folder still keeps the name.
@nplez1
nplez1 merged commit ef46e09 into nplez1/main Oct 30, 2026
2 checks passed
@nplez1
nplez1 deleted the nplez1/typed-label-names-its-branch branch October 30, 2026 04:34
nplez1 added a commit that referenced this pull request Oct 30, 2026
Merge base f173998, fork tip before this sync 16f49e0 (rollback tag
archive/pre-sync-16f49e00cf), upstream tip a903985.

184 conflicted paths / 340 hunks: both-rewrote 98, union 57, rename-replay 10,
duplicate-tail 8, modify/delete 8, duplicate-members 2, add/add 1.
`conflicts.mjs --apply-proven` proved 38 paths outright (55 import-only unions,
6 upstream- or fork-unchanged whole hunks, 1 identity-only); the remaining 138
were resolved in five disjoint area batches against
`local/sync/convergence-ledger.md`, then the sidebar goldens were regenerated
from the resolved row model rather than merged.

Deletions, all 8 modify/delete entries:

- Four renderer dashboard-popout paths, per ledger "Dashboard delivery: a
  content-area view, not a drawer or a pop-out" (owner decision 2026-10-26).
  The manifest entries had reverted to `pending-decision` only because
  upstream's blobs moved.
- `ipc/jira/project-metadata-registration.test.ts` and
  `runtime-client-settings-wsl-host-hooks.test.ts`: upstream test retire­ments.
- `ipc/worktrees-create-first-work-rename.test.ts`: upstream's f5a4a72
  implements the fork's #251 and deleted its suite, moving coverage to
  `worktrees-create-label-only-first-work.test.ts` and
  `runtime-local-worktree-create.test.ts`.
- `task-page-jira-item-source-context.test.ts`: deleted with the move under
  `task-page/jira/`; the matcher keeps its own suite in
  `shared/workspace-linked-item-source-context.test.ts`.

Breaks the merge left with no conflict marker, all repaired here:

- `pr-conversation-response.ts` (upstream's extraction of the PR conversation
  parser) carried no review-verdict mapping, so the fork's
  `includeReviewVerdicts` accepted a flag and ignored it. The `state` field,
  `mapGraphQLReview`, and the shared `isReportableReviewSubmission` keep-rule
  are re-homed there for both the GraphQL and the REST path.
- `local-agent-inventory-refresh.ts` (upstream's extraction) derived isolation
  only from the floating terminal, dropping the fork's `options.isolated`; the
  per-workspace enable re-read would have blanked the shared detected list.
- `worktree-status.ts` kept two of ten `STATUS_LABELS` entries, so every
  activity label but `inactive`/`setup` read `undefined`.
- `terminal-transient-facts.ts` gained two `getTrackedPtyTitle` declarations —
  both sides added one for the same synthetic-title producer. Upstream's raw
  variant stays; the fork's display variant remains as the protected
  `getTrackedDisplayTitleForPty`.
- `agent-state-rules-catalog.ts`: upstream's lazy-parse refactor dropped the
  fork's `copilot` rule file from the bundled list while upstream never had it.
- `use-ai-vault-session-copy-actions.ts` copies the Windows-normalized path
  again (`formatClipboardFilePath`), now that the panel delegates to the hook.
- `jira-issue-mutations.ts`: the non-Error fallback carries
  `taskProviderFailure('jira.updateFailed', …)` like upstream's.
- `git-stream-options.ts` regains upstream's `hostGit?: true` (the fork
  extracted the type upstream then extended).
- Fork files re-pointed at upstream's moves/deletions: `task-page-jira-status-
  tone` (3 importers), `shared/jira/jira-issue-url` (one depth),
  `ephemeral-vm-recipe-checkout-mode` (`…Error` -> `…Failure`, now spread as a
  structured failure), `PRIORITY_LABELS` (retired upstream; the fork's
  `linear-issue-edit-rows` resolves the copy from the catalog).
- `main-window-actions.ts` referenced `getDashboardPopoutWindow` after the
  fork's own popout deletion; the companion-renderer guard is the workspace
  space window alone.
- `pr-number-lookup.ts`: the fork's `getPRByNumber`/`lookupPRByNumberData`
  split lost the `options` thread, so `includeStackSummary` was read from an
  undefined binding.
- `host-sync-settings-disposition.ts`: 13 settings upstream added were
  unclassified; all 13 are `replicated` (preferences and per-host selections),
  matching `autoRenameBranchFromWorkDefaultedOn` and `browserProfileScope`.
- Test fixtures repaired for upstream's new required fields
  (`indexConsumers`, `pathOwner`, `initialBranchNameOverride`,
  `worktreeLayoutMode`) and for a doubled `toast` import and a duplicated
  `getTrackedPtyTitle`.
- `i18n`: `setRendererUiLanguage` is restored over upstream's bootstrap, and
  the fork overlay now derives its directory from `readLocalizationSurface`, so
  upstream's desktop/mobile split carries it and a surface without an overlay
  merges to upstream's file unchanged.

Localization: 24 orphan keys removed from each of the ten locales (the fork's
deleted dashboard popout and four reworded strings), 26 stale tombstones
removed from each fork overlay, and the two #169 ack toasts the fork rewords
retired from every locale so they fall back to the fork's English overlay
instead of rendering upstream's five-placeholder sentence.

Rollback: `backup/nplez1-main-pre-sync` and tag `archive/pre-sync-16f49e00cf`.
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