Skip to content

feat: allow custom worktree branch names - #6454

Merged
nwparker merged 3 commits into
stablyai:mainfrom
wolfiesch:wolfiesch/6414
Jul 4, 2026
Merged

nwparker merged 3 commits into
stablyai:mainfrom
wolfiesch:wolfiesch/6414

Conversation

@wolfiesch

@wolfiesch wolfiesch commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an Advanced Branch name field to Git worktree creation so users can create an Orca worktree with an explicit Git branch name instead of accepting the generated branch slug.

The field reuses the existing branchNameOverride create path, so local and SSH/runtime worktree creation keep the same Git validation and conflict handling. Manual branch edits also clear stale PR/MR push-target and branch-reuse state when the chosen branch no longer matches the selected review branch.

Fixes #6414

Screenshots

Create worktree dialog showing the Branch name field

Testing

  • pnpm lint - passed with an existing useGitStatusPolling.ts exhaustive-deps warning.
  • pnpm run typecheck
  • pnpm test - attempted; failed on existing environment-sensitive tests unrelated to this change (localStorage helpers unavailable in several renderer tests, git prompt env expectation, repo remote URL expectation, and gitleaks output in a relay commit test).
  • pnpm test src/renderer/src/hooks/composer-branch-selection.test.ts src/renderer/src/components/NewWorkspaceComposerCard.test.tsx src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts src/main/ipc/worktrees.test.ts src/main/ipc/workspace-create-error-classifier.test.ts
  • pnpm run build:desktop - passed with existing chunk-size warnings and a non-fatal /usr/local/bin/orca-dev symlink permission notice.
  • Added focused tests for manual branch override preservation, stale push-target clearing, Git-only UI visibility, accessible label wiring, and explicit-branch conflict copy.

AI Review Report

Reviewed the branch-name create flow across renderer state, existing branchNameOverride plumbing, local/SSH backend creation, and conflict copy.

Findings addressed during review:

  • Cleared stale PR/MR pushTarget and fork warnings when manual branch input no longer matches the selected review branch.
  • Cleared branch-reuse state and the auto-name ref on manual branch edits so the reuse checkbox cannot later restore a stale selected branch.
  • Added id/htmlFor wiring for the new field.
  • Synced localization keys across locales.

Cross-platform: no keyboard shortcuts, shell interpolation, or path separators added. Branch validation remains in Git via argv-style check-ref-format, and the existing local/SSH worktree create paths are reused.

Security Audit

Manual branch input is passed through existing branchNameOverride validation instead of being shell-interpolated. Git rejects invalid branch names through check-ref-format; conflicts still stop exact branch overrides instead of silently suffixing them. No auth, secrets, dependency, network, or IPC surface changes beyond the existing create payload field.

Notes

  • X handle: @wolfie_
  • The change is intentionally UI-only for manual worktree creation; CLI support can be added separately if maintainers want the command surface expanded.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds branch-name override handling to the composer flow. The renderer now shows an advanced branch-name field, shared selection logic reconciles manual branch edits with push-target state, and the main-process worktree conflict messages and tests now use branch-name wording for branch collisions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: adding custom branch names for worktree creation.
Description check ✅ Passed The description covers summary, screenshots, testing, AI review, security, and notes, with only minor detail gaps in the cross-platform checklist.
Linked Issues check ✅ Passed The PR adds a manual branch-name field and routes creation through existing validation and conflict handling, satisfying #6414.
Out of Scope Changes check ✅ Passed The changes stay focused on branch-name UI, state, validation, localization, and tests, with no unrelated feature work apparent.

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.

🧹 Nitpick comments (1)
src/renderer/src/components/NewWorkspaceComposerCard.tsx (1)

888-911: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: the extra advancedOpen guard makes this field behave differently from its siblings.

The Name/Note/Setup fields render unconditionally inside the collapsing drawer (which already sets aria-hidden={!advancedOpen}), so they stay mounted and animate. Gating the branch-name field on advancedOpen unmounts it on collapse and reveals it instantly (no grid-rows animation) on expand. Dropping advancedOpen from the condition keeps it consistent with the surrounding fields.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4dcc2024-90b2-4afa-a253-4967cd46dd98

📥 Commits

Reviewing files that changed from the base of the PR and between 85d626b and 15bbb07122dea6d4e072dd93de3bbb69f43e9656.

📒 Files selected for processing (15)
  • src/main/ipc/workspace-create-error-classifier.test.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees.test.ts
  • src/renderer/src/components/NewWorkspaceComposerCard.test.tsx
  • src/renderer/src/components/NewWorkspaceComposerCard.tsx
  • src/renderer/src/hooks/composer-branch-selection.test.ts
  • src/renderer/src/hooks/composer-branch-selection.ts
  • src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/composer-branch-selection.ts

@wolfiesch

Copy link
Copy Markdown
Contributor Author

Resolved: removed the advancedOpen check from the branch name field's rendering condition in NewWorkspaceComposerCard.tsx so it transitions/animates consistently with the note and setup fields. Verified with unit tests.

@wolfiesch
wolfiesch force-pushed the wolfiesch/6414 branch 3 times, most recently from d6b7504 to 00e0547 Compare June 30, 2026 05:08
@nwparker

nwparker commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

will try to merge today! Sorry for delay

wolfiesch and others added 3 commits July 3, 2026 14:05
…s the branch

A tracked PR/issue/MR/Linear source derives the branch itself, and a linked
GitHub PR re-resolves the branch name at submit — so an override typed in the
Advanced branch field was silently ignored. Only render the field for the
typed-name and base-branch flows, where the manual override is honored.

Co-authored-by: Orca <[email protected]>
Copilot AI review requested due to automatic review settings July 3, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@nwparker

nwparker commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Maintainer takeover — rebased, reviewed, verified end-to-end

A maintainer has taken ownership of this PR: rebased onto latest main (resolved conflicts), screened it for security, verified it in a real dev build, fixed one review finding, and pushed back to the branch. Not merged — a human will make the final call.

Description (what this ships)

An Advanced → "Branch name" field in the worktree-creation composer that lets you set the exact Git branch name instead of accepting the auto-derived slug. It reuses the existing branchNameOverride create path, so:

  • Empty field → falls back to the auto-derived branch (e.g. nwparker/my-workspace).
  • A typed name is used verbatim (slashes, underscores, casing preserved) after git validates it.
  • Manual edits clear stale PR/fork push-target state so a renamed branch doesn't push to someone else's fork.

Is this already on main? No. main has a "Branch" mode (the branch composer) whose "create new branch: X" row sets the workspace name and then sanitizes/hyphenates it into a branch (sanitizeBranchSlug → computeBranchName); it cannot produce an exact custom ref. PR #6748 (unmerged, targets #6721) only adds slash-preservation to that name field. So #6414 was genuinely unmet — this PR fills the gap with a dedicated field that flows through the exact-override path. No duplicated UI or sanitization logic.

Security — branch name → git command (safe)

The typed name becomes a real Git ref, so I traced it end-to-end. It is safe:

  • Never touches a shell. Every hop is argv: resolveCreateBranchName / resolveCreateBranchNameSsh → git check-ref-format --branch <name> → addWorktree (git worktree add --no-track -b <name> …) via gitExecFileAsync (execFile). Over SSH it's a structured JSON-RPC array; the relay's addWorktreeOp re-validates.
  • Option-injection guarded: rejects names starting with - on both local and SSH paths, so --upload-pack=-style injection can't slip in.
  • Path traversal blocked: check-ref-format rejects .., control chars, spaces, etc.; the worktree filesystem path derives from the sanitized name, not the branch, and passes ensurePathWithinWorkspace.
  • No new surface: the diff adds no git command, network call, dependency, or filesystem write, and disables no validation — it only surfaces the pre-existing branchNameOverride path through a new input.

Evidence (verified in a real Orca dev build)

Scenario Input Result
Custom branch name custom-branch-e2e, branch feature/JIRA-1234_e2e-Custom git branch = feature/JIRA-1234_e2e-Custom exactly (slash/underscore/uppercase preserved); folder = custom-branch-e2e (decoupled) ✅
Empty → fallback name only, branch blank git branch auto-derived → nwparker/fallback-test-e2e ✅
Invalid name branch foo..bar blocked with git check-ref-format --branch foo..bar: 'foo..bar' is not a valid branch name; no branch/worktree created ✅

git rev-parse --abbrev-ref HEAD in the created worktree confirmed the exact branch. Tests: the 4 touched suites pass (70 tests). oxlint, oxfmt, and both localization checks (verify:localization-catalog, verify:localization-coverage) are clean.

Review fix I applied (1 finding)

An independent review found the always-visible field was an editable-but-silently-ignored control when a GitHub PR was the source: a linked PR re-resolves its own branch at submit (and the base is resolved lazily from that selection), so a typed override was dropped. I gated the field to the typed-name and base-branch flows — where the override is actually honored — and hid it when a tracked work item (PR/issue/MR/Linear) drives the branch. Added 2 tests for the gating. (Clearing the PR start-point ref instead would have silently dropped the PR base, so hiding is the safe minimal fix.)

I also finished the rebase conflicts: kept main's new composer i18n keys and added the two new branch keys across all 5 locales (with real translations for branchName; the feature/my-branch placeholder stays as a literal git example).

Trade-offs

  • The field is intentionally not offered when starting from a PR/issue/MR/Linear source (that source defines the branch). Allowing an override there too is possible but needs a fork-push-target UX decision — a good follow-up, out of scope here.
  • New branch keys are English in en + translated in es/ja/ko/zh; the localization pipeline can refine later.

ELI5

Orca used to name your Git branch for you by squishing your workspace name into hyphens. Now there's a "Branch name" box: type the exact branch you want (e.g. feature/JIRA-1234) and that's the branch you get — your folder can still be named whatever. Leave it blank and Orca names it for you like before. Type something git hates and it politely refuses instead of making a mess. The name is handed to git as a plain argument (never run through a shell), so a sneaky name can't run commands.

@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Description

Implements #6414 — you can now customize the Git branch name when creating a worktree, independent of the workspace/directory name.

A new optional "Branch name" field appears under Advanced in the Create-worktree composer. Whatever you type there becomes the actual Git branch (git worktree add -b <name>), while the workspace name still drives the folder name. Leave it blank and Orca keeps its existing behavior: the branch is auto-derived from the workspace name.

This integrates cleanly with the existing composer rather than duplicating it:

  • The field is only shown when the branch is something you control — i.e. a typed Name or a base Branch.
  • It is hidden when a tracked work item (GitHub PR/issue, GitLab MR, Linear) is the source, because the branch is derived from that item (a linked GitHub PR even re-resolves it at submit), so a manual override would be silently ignored. This is documented with a // Why: comment at the render site.

The branch string flows through the pre-existing branchNameOverride plumbing — no new IPC surface, no new subprocess path.

The branch was rebased onto main (3 commits: feat → refactor → fix), sits cleanly on top of it (git log main..HEAD = only these 3 commits), and the PR reports MERGEABLE.

Evidence

End-to-end in a real Electron dev build (fork PRs have no CI, so this dev build also served as the compile check — it built and ran clean):

  1. Custom branch name → matching Git branch. Composer for a git repo, Name tab (typed name orca custom branch demo), Advanced → Branch name = feature/orca-custom-branch-demo, then Create.

    • Rendered terminal prompt showed (feature/orca-custom-branch-demo); status bar showed workspace orca-custom-branch-demo / branch feature/orca-custom-branch-demo — i.e. the branch is decoupled from the auto-derived folder name.
    • Proven against real git in the created worktree:
      $ git branch --show-current
      feature/orca-custom-branch-demo
      $ git worktree list
      .../orca-branch-name-demo                                   [main]
      .../orca-branch-name-demo/orca-custom-branch-demo           [feature/orca-custom-branch-demo]
      
    • Screenshots: 05-branch-name-filled.png (composer with the field filled), 06-worktree-created.png (terminal showing the branch).
  2. Empty field → auto-derived fallback. Same flow, workspace name orca fallback demo, Branch name left blank → created branch orca-fallback-demo (slug of the workspace name). Real git: git branch --show-current → orca-fallback-demo. Screenshots: 07-empty-branch.png, 08-fallback-created.png.

  3. Work-item source → field hidden. Composer on a GitHub repo, selected PR Terminal performance initiative: pipeline fixes + term-speed-2 revival + PTY flow control (integration branch) #7214 as the source, expanded Advanced. The Branch name field is not rendered — Advanced shows only Name / Note / Setup script / Sparse checkout. DOM probe confirmed 0 branch-name inputs and 0 "Branch name" labels. Screenshot: 10-workitem-hidden.png.

Unit tests — 70/70 pass (re-run on the rebased branch):

npx vitest run --config config/vitest.config.ts \
  src/renderer/src/hooks/composer-branch-selection.test.ts \
  src/renderer/src/components/NewWorkspaceComposerCard.test.tsx \
  src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts \
  src/main/ipc/workspace-create-error-classifier.test.ts
→ Test Files 4 passed (4) · Tests 70 passed (70)

Lint clean (pnpm lint, exit 0): oxlint + switch-exhaustiveness, verify:localization-catalog ("Verified 9555 localization key references against en.json"), and verify:localization-coverage ("check passed with 0 allowlisted candidates"). branchName has real, localized strings in all 5 locales (en/es/ja/ko/zh), e.g. Branch name / Nombre de rama / ブランチ名 / 브랜치 이름 / 分支名称.

Security: the typed name reaches git only as an argv token to git worktree add -b <name> <path> via execFile (no shell → no injection). Git's own check-ref-format/refname rules reject invalid names, and an empty/whitespace name trims to undefined and falls back to auto-derivation. The only worktree-remote.ts change is conflict-error copy ("Pick a different branch name" vs "worktree name").

ELI5

When you make a new workspace, Orca creates a Git branch for it. Before, the branch was always named after the workspace folder. Now there's an optional box where you can type exactly what you want the branch to be called — like feature/login-fix — even if the folder is named something else. Leave the box empty and nothing changes; Orca names the branch for you like it always did. And if you're starting from a GitHub PR or issue, the box doesn't show up, because the branch name already comes from that PR/issue.

Trade-offs

  • No behavior change by default. The field is optional; blank = the existing auto-derived branch name. Existing flows are untouched.
  • Deliberately scoped. Hidden for work-item sources (PR/issue/MR/Linear) so the override can't be silently ignored — the branch there is owned by the linked item.
  • Fork PR: this branch lives on a contributor fork, so required CI must be triggered by a maintainer (mergeStateStatus is currently UNSTABLE = checks pending, not conflicting). Content is MERGEABLE.

(Screenshots are attached to this PR conversation, not committed to the branch.)

@nwparker
nwparker merged commit 8796261 into stablyai:main Jul 4, 2026
@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Merged! 🎉 Thank you, @wolfiesch — this is live on main now.

Being able to type your own branch name when spinning up a worktree is one of those small things people ask for all the time, and it's genuinely nicer to use. Two things I really appreciated: how cleanly it dropped into the existing composer, and the thoughtful touch of hiding the manual field when a linked PR/issue is already driving the branch name — that's exactly the kind of detail that keeps the flow from getting confusing. Thanks too for sticking with it through the review round-trips (including that advancedOpen rendering fix).

For transparency: I rebased onto latest main and gave it a full pass before merging — custom name → matching git branch, empty → auto-derived fallback, and the work-item hide behavior all verified end-to-end, with tests / lint / typecheck green (details in the comment above). Nothing needed from you.

Thanks again for making Orca a little better. 🙌

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* feat: allow custom worktree branch names

* refactor(ui): render custom branch name field unconditionally under advanced container

* fix(composer): hide manual branch field when a work-item source drives the branch

A tracked PR/issue/MR/Linear source derives the branch itself, and a linked
GitHub PR re-resolves the branch name at submit — so an override typed in the
Advanced branch field was silently ignored. Only render the field for the
typed-name and base-branch flows, where the manual override is honored.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Wolfgang Schoenberger <[email protected]>
Co-authored-by: Neil <[email protected]>
Co-authored-by: Orca <[email protected]>
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.

[Feature]: I'd like to be able to customize the Git branch name when creating a worktree.

4 participants