[BUG] Desktop app: enabling the worktree checkbox resets the base branch to "main", ignoring the repo's default branch (origin/HEAD → dev)
Bug Description
In the desktop app's Code tab, the new-session bar shows: Local | <project> | <branch> | [ ] worktree. While the worktree checkbox is unchecked, the branch chip correctly shows the repo's current branch (dev). The moment the checkbox is enabled, the chip switches to main — even though this repo's default branch is dev both on the remote and in every local git pointer. The spawned session then creates its worktree from main.
For repos whose default branch is not main (common GitLab flow: dev is the integration branch), every worktree session silently starts from an older branch, and work lands on top of stale code.
Steps to reproduce
- Use a repo whose default branch is
dev(self-hosted GitLab here):
git ls-remote --symref origin HEAD→ref: refs/heads/dev- local
refs/remotes/origin/HEAD→refs/remotes/origin/dev - currently checked-out branch:
dev
- Desktop app → Code tab → select this project. The branch chip shows
dev. - Enable the
worktreecheckbox. - The chip flips to
main; a spawned session creates its worktree frommain.
Expected behavior
The worktree base should be the repo's default branch resolved from refs/remotes/origin/HEAD (→ dev), consistent with the CLI's own default-branch resolution, which reads origin/HEAD and only falls back to main/master when it is absent.
What I ruled out
- Server and local git state are correct (
origin/HEAD→dev); verified again after a full quit + relaunch of the app — the chip still flips tomain. - The
worktree.baseRefsetting has no effect on this UI path (it governs--worktree/ agent isolation). - No stale client state: localStorage only persists the checkbox itself (
persisted.cc-landing-worktree-enabled); there is no branch value in IndexedDB,~/.claude.json, or session persistence. - The desktop main-process git resolvers do read
refs/remotes/origin/HEADcorrectly and would returndev; the spawn request already arrives with an explicitsourceBranch. So the literalmainappears to originate in the landing/renderer layer, not in main-process git logic.
Workaround
A WorktreeCreate hook that creates the worktree from dev and prints its path — the hook path bypasses the UI-chosen base entirely.
Environment
- Claude desktop app 1.24012.1, macOS 26.4.1 (arm64)
- Claude Code CLI 2.1.174
- Repo: self-hosted GitLab, default branch
dev
Related: #54945 (same reset-to-default in the TUI worktree dialog, closed), #79515 (same "Branch to start from" control, different bug).
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗