You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(git): keep branch search ref labels unique when a branch name starts with refs/ - #52657
Git lets you name a branch something that looks like a full ref path, such as refs/heads/origin/main. When you searched branches, Orca shortened that name so it looked the same as a different branch's full path, and you saw two rows with the same text that went to different commits. Now every row gets its own label, so you can tell them apart.
What Changed
Before:branchRefLabels removed the refs/heads/ or refs/remotes/ prefix and kept the short label unless two refs shortened to the same text. A local branch named refs/heads/origin/main (full ref refs/heads/refs/heads/origin/main) shortened to refs/heads/origin/main. That is the full ref the formatter already shows for the branch origin/main when it conflicts with refs/remotes/origin/main. The two rows then had the same label.
After: when the shortened label still starts with refs/, the formatter shows the full ref. The refs/ namespace is kept for full refs, so a short label can no longer match another row's full label. Ordinary labels (main, origin/feature) and the existing local-vs-remote handling are unchanged.
The formatter is in src/shared/git/refs/branch-ref-label.ts. It is shared by the workspace base-ref picker, the create-from picker, smart workspace source results, and orca repo search-refs. The fix is at that shared source, so every caller gets it.
Why
The collision comes from the formatter's own namespace rule. A short label and a full-ref fallback could overlap, so fixing it at the source is the root-cause fix. Selection values and the CLI JSON already use the original ref strings, so only the display text changes. The same rule also separates a branch named refs/tags/v1 from the tag refs/tags/v1.
The change shows up only as text labels, so here is before/after text output instead of screenshots. It comes from real git for-each-ref output run through the repo-ref formatter, main vs this branch:
Before (main): 10 refs, 8 distinct labels
refs/heads/origin/main <- branch "origin/main"
refs/heads/origin/main <- branch "refs/heads/origin/main" (collision)
refs/heads/refs/tags/v1 ... refs/tags/v1 (branch shown as "refs/tags/v1", same as the tag)
Ordinary refs are unchanged: ["main","feature/x","origin/main","refs/tags/v1"] on both.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced on macOS with a temp repo that has the branches origin/main, refs/heads/origin/main and refs/tags/v1, the tracking ref refs/remotes/origin/main, and the tag v1. Ran the ref list through the formatter on main (8 distinct labels for 10 refs) and on this branch (10 of 10).
src/shared/git/refs/branch-ref-label.test.ts: the branch and tag collision cases fail on main and pass with this fix. The no-collision case keeps short labels. vitest run src/shared/git/refs/ passes (3/3).
CI static gates on the touched files are clean: anti-slop oxlint, native code-quality oxlint, ast-grep, the changed-code quality gate, and oxfmt.
The contributor also checked it on Linux with the CLI (orca repo search-refs) and the workspace picker row builder.
Performance
None. The formatter is a pure function that runs once per branch-search result list, not on every keystroke for each row, and it adds one fixed-length startsWith check per ref. Measured old vs new over the same ref lists: N=200 was 38.0 vs 35.5 us/call, and N=10,000 (adversarial) was 2.66 vs 2.38 ms/call. That is within noise. The change adds no git subprocesses, I/O, polling, or per-item cache invalidation.
Risk
Level: Low
Only users with a literal refs/ prefix in a branch name see a longer, fully qualified label. Selection values, saved selectors, and the CLI JSON contract still use the original ref strings, so older CLIs, SSH hosts, and mobile clients are unaffected. To back it out, revert the commit.
Notes
Platform-independent string logic in src/shared, shared by desktop, mobile, and CLI. No settings, migrations, or persisted data.
Original fix by @SeungWoonSong in #52657 (authorship preserved; a maintainer squashed it onto current main and extended the test).
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)
I stated the risk: what could break, for whom, and how to back it out
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)
No actionable comments were generated in the recent review.
Walkthrough
branchRefLabels now returns a ref’s full value when its short label starts with refs/ or when multiple refs share that label. Tests check that colliding branch and tag refs receive distinct labels and that refs without collisions retain their short labels.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to 50e47
This fix keeps branch and tag labels distinct in branch search when fully qualified refs would otherwise collide. Ordinary labels are unchanged, and no merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
[#52656] requires distinct labels when different fully qualified refs would otherwise display the same. The shared mapper in src/shared/git/refs/branch-ref-label.ts (branchRefLabels) returns the full …
Out of Scope Changes check
The whole-PR change set (merge base b5aa8fd to head 50e4758) touches only src/shared/git/refs/branch-ref-label.ts (+5/-1, mapper logic and comment) and src/shared/git/refs/branch-ref-label.test.ts (+2…
Title check
The title names the main change: branch search ref labels stay unique when a branch name starts with refs/. It matches the summary, which makes branchRefLabels return the full ref when the short label…
Description check
The description follows the template closely. It has ELI5, What Changed (before/after and mechanism), Why, a Linked Issue (Fixes #52656), Visual Proof (text-based before/after, which fits a non-visual…
Full details: Linked Issues check
Explanation
[#52656] requires distinct labels when different fully qualified refs would otherwise display the same. The shared mapper in src/shared/git/refs/branch-ref-label.ts (branchRefLabels) returns the full ref when the short label starts with refs/, or when more than one ref shares the short label. For the issue reproduction (refs/heads/origin/main, refs/heads/refs/heads/origin/main, refs/remotes/origin/main), the short labels origin/main and origin/main collide, so both receive full refs. The third ref shortens to refs/heads/origin/main, which starts with refs/, so it also keeps its full ref. The three labels are distinct and match the expected text output in the issue. For the branch/tag collision (refs/heads/refs/tags/v1, refs/tags/v1), both labels are full refs and are distinct. The regression test in src/shared/git/refs/branch-ref-label.test.ts asserts label uniqueness for both cases. Ordinary short labels still shorten as before. The changes since the previous review (head 3eec7cb to 50e4758) are a comment and the regression test only; they do not alter the mapper behavior. Not independently verified: that every CLI and picker call site routes through this mapper. The source review supports this only at the mapper boundary. Non-coding items (manual testing, full-suite CI coverage) do not apply.
Full details: Out of Scope Changes check
Explanation
The whole-PR change set (merge base b5aa8fd to head 50e4758) touches only src/shared/git/refs/branch-ref-label.ts (+5/-1, mapper logic and comment) and src/shared/git/refs/branch-ref-label.test.ts (+22/-0, regression tests). Both directly implement the label-uniqueness objective of #52656. The PR states that selection values and CLI JSON refs are unchanged. The summary reports that branchRefLabel and probedDefaultBranchRef are not changed. The stated exclusions (bare main versus refs/heads/main, and the current selection's standalone label) are not modified by this PR. No unrelated change was found.
Full details: Title check
Explanation
The title names the main change: branch search ref labels stay unique when a branch name starts with refs/. It matches the summary, which makes branchRefLabels return the full ref when the short label starts with refs/ or collides. The title is specific and single-sentence, and it uses the conventional fix(git) prefix. It does not cover the tag collision case, which is an acceptable omission.
Full details: Description check
Explanation
The description follows the template closely. It has ELI5, What Changed (before/after and mechanism), Why, a Linked Issue (Fixes #52656), Visual Proof (text-based before/after, which fits a non-visual change), Testing with checkboxes, a Performance line, a Risk section with level and rollback, and a Checklist. Gaps: the AI Disclosure and Review sections are absent (AI Disclosure is optional for maintainers), the Agent skill upstream boundary checkbox is missing, and the final pnpm checklist item is unchecked while the Testing section says the gates were clean. The author should confirm whether the Agent skill boundary item applies and that the lint, typecheck, test, and build commands pass locally or in CI.
Resolution
Optional: tick or address the Agent skill upstream boundary item, and either check the pnpm lint/typecheck/test/build item or note that CI will cover it. Add an AI Disclosure entry if an AI model was used.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b97b273f-fee0-4585-ad35-1c3cbb22f8bf
Commits
Reviewing files that changed from the base of the PR and between 3eec7cb and 50e4758.
Files selected for processing: 1
src/shared/git/refs/branch-ref-label.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
A branch literally named refs/heads/origin/main shortened to the same
label as the full ref of the branch origin/main, so the branch search
picker and `orca repo search-refs` showed two identical rows that
pointed at different commits. Keep the full ref whenever the shortened
label still starts with refs/, since that namespace is reserved for
full refs.
Fixesstablyai#52656
Co-authored-by: Neil <[email protected]>
nwparker
changed the title
fix(git): keep branch search ref labels unique
fix(git): keep branch search ref labels unique when a branch name starts with refs/
Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Git lets you name a branch something that looks like a full ref path, such as
refs/heads/origin/main. When you searched branches, Orca shortened that name so it looked the same as a different branch's full path, and you saw two rows with the same text that went to different commits. Now every row gets its own label, so you can tell them apart.What Changed
branchRefLabelsremoved therefs/heads/orrefs/remotes/prefix and kept the short label unless two refs shortened to the same text. A local branch namedrefs/heads/origin/main(full refrefs/heads/refs/heads/origin/main) shortened torefs/heads/origin/main. That is the full ref the formatter already shows for the branchorigin/mainwhen it conflicts withrefs/remotes/origin/main. The two rows then had the same label.refs/, the formatter shows the full ref. Therefs/namespace is kept for full refs, so a short label can no longer match another row's full label. Ordinary labels (main,origin/feature) and the existing local-vs-remote handling are unchanged.The formatter is in
src/shared/git/refs/branch-ref-label.ts. It is shared by the workspace base-ref picker, the create-from picker, smart workspace source results, andorca repo search-refs. The fix is at that shared source, so every caller gets it.Why
The collision comes from the formatter's own namespace rule. A short label and a full-ref fallback could overlap, so fixing it at the source is the root-cause fix. Selection values and the CLI JSON already use the original ref strings, so only the display text changes. The same rule also separates a branch named
refs/tags/v1from the tagrefs/tags/v1.Linked Issue
Fixes #52656
Visual Proof
The change shows up only as text labels, so here is before/after text output instead of screenshots. It comes from real
git for-each-refoutput run through the repo-ref formatter,mainvs this branch:Before (main): 10 refs, 8 distinct labels
After (this PR): 10 refs, 10 distinct labels
Ordinary refs are unchanged:
["main","feature/x","origin/main","refs/tags/v1"]on both.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced on macOS with a temp repo that has the branches
origin/main,refs/heads/origin/mainandrefs/tags/v1, the tracking refrefs/remotes/origin/main, and the tagv1. Ran the ref list through the formatter onmain(8 distinct labels for 10 refs) and on this branch (10 of 10).src/shared/git/refs/branch-ref-label.test.ts: the branch and tag collision cases fail onmainand pass with this fix. The no-collision case keeps short labels.vitest run src/shared/git/refs/passes (3/3).CI static gates on the touched files are clean: anti-slop oxlint, native code-quality oxlint, ast-grep, the changed-code quality gate, and oxfmt.
The contributor also checked it on Linux with the CLI (
orca repo search-refs) and the workspace picker row builder.Performance
None. The formatter is a pure function that runs once per branch-search result list, not on every keystroke for each row, and it adds one fixed-length
startsWithcheck per ref. Measured old vs new over the same ref lists: N=200 was 38.0 vs 35.5 us/call, and N=10,000 (adversarial) was 2.66 vs 2.38 ms/call. That is within noise. The change adds no git subprocesses, I/O, polling, or per-item cache invalidation.Risk
Level: Low
Only users with a literal
refs/prefix in a branch name see a longer, fully qualified label. Selection values, saved selectors, and the CLI JSON contract still use the original ref strings, so older CLIs, SSH hosts, and mobile clients are unaffected. To back it out, revert the commit.Notes
Platform-independent string logic in
src/shared, shared by desktop, mobile, and CLI. No settings, migrations, or persisted data.Original fix by @SeungWoonSong in #52657 (authorship preserved; a maintainer squashed it onto current
mainand extended the test).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)