Skip to content

Fix truncated Unicode branch names in base ref search - #25777

Merged
nwparker merged 5 commits into
mainfrom
nwparker/bug-base-ref-search-truncates-chinese-branch-nam
Oct 6, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/bug-base-ref-search-truncates-chinese-branch-nam

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Some older Apple Git builds cut off Chinese branch names in search. Selecting that result fails because the displayed name is not a real branch. Orca now keeps the complete branch identity and can create a worktree from it.

What Changed

Compare Git's short name with the complete ref and use the complete ref when the short spelling is incomplete or needs namespace disambiguation. Local branch names containing / also keep their full selector, because worktree creation otherwise gives a matching remote-tracking ref priority even when no remote is configured. Derive the proposed local branch name independently, so local branch reuse still works. Literal � characters stay valid. Simple local names and ordinary remote names retain their short spelling.

Local and SSH searches use the same parser. Remote clients advertise support for complete selectors; older clients omit those rows before the result limit so ordinary results still fill the page. This deliberately hides slash-named local branches from older clients until they upgrade; current clients retain them with exact selectors.

Why

Reproduced with Apple Git-154 (2.39.5) built from Apple's source on macOS: feature/加 becomes feature/� under a UTF-8 locale, while the complete ref resolves correctly. Current Apple Git 2.50.1 and Homebrew Git 2.55.0 are unaffected. The issue comment records the source-build caveat and exact steps.

Comparing spellings also catches partial names without a replacement character. Using the complete ref preserves local/remote/tag distinctions; blindly removing the namespace could select the wrong commit. Git commands and bounded search counts are unchanged.

Linked Issue

Fixes #19515

Adapted from #19540 by @nishino-tsukasa, with co-author credit. Thank you for the original fix, compatibility handling, and regression coverage. This version also checks incomplete spellings generally and filters unsupported selectors before pagination.

Visual Proof

Hidden Electron renderer running the affected Apple Git build. Before: the long Chinese branch ends in �. After: complete selectors preserve the names (the long row is visually elided; the short feature/加 example fits). Creating a worktree from the long branch and reusing feature/加 both succeed.

Before:

orca-19515-before.png

After:

orca-19515-after-short.png

Created worktree from the recovered long branch:

orca-19515-created.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

macOS: 235 focused tests pass across Git search, SSH query handling, RPC capability negotiation, branch reuse, and web/CLI clients. The 77 Git tests also pass with Apple Git-154 under en_US.UTF-8, including real local and remote worktree creation. pnpm tc, the changed-code quality gate, and the complete pnpm run build:desktop pass after installing this worktree's missing mobile dependencies.

Hidden Electron UI: reproduced the corrupted result before the fix, then searched, selected, created a new worktree, and reused the existing local Unicode branch after the fix. SSH behavior is covered with provider fixtures; Linux and Windows were not run locally.

AI Disclosure

Review

Three independent adversarial reviewers completed seven review rounds. The final pass is clean after fixing valid dotted-component validation, desktop capability drift, native/SSH namespace confusion, and loose-shortening collisions with configured or orphan remote refs. Tests also execute the real relay argument validator. Reviewed branch/tag collisions, literal replacement characters, slash-containing remote names, nested /HEAD branches, legacy-client pagination, and folder workspaces.

After updating to the CI base, corrected an inherited release-checkout assertion that expected a missing package although the harness pins that package for old release tests. All 121 cross-version tests now pass locally. The file-explorer scan-count correction was also adopted on main while CI ran; the final merge uses main's identical two-scan assertion. All 14 tests pass. Three reviewers rechecked the updated base and found no remaining issues.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Uses existing Git commands and ref validation, without additional subprocesses or a larger scan. Capabilities protect independently updated clients and hosts. No platform-specific UI, paths, or shortcuts were added.

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)
  • 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)

Full CI passed on d80254a8d9e86bef60afb45fa15071b4af67e95f, including all five unit shards, Git/wire compatibility, packaging, and platform smoke checks. After resolving concurrent upstream test wording, all three reviewers rechecked the merge; 235 focused tests, 121 cross-version tests, typecheck, and the quality gate passed again.

The focused tests, typecheck, changed-code gate, and desktop build were run locally.

Recover incomplete or disambiguated short refs from the full selector and
keep local branch names independent for reuse. Gate qualified selectors
for remote clients and filter unsupported rows before pagination.

Adapted from nishino-tsukasa's PR #19540 with additional truncation and
legacy pagination coverage.

Co-authored-by: kino <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

Git ref search now resolves selectors from complete ref names and can include qualified refs in search results. Runtime search passes the inclusion option through local and SSH paths. RPC responses filter qualified refs for clients that do not advertise the new capability. Composer branch selection recognizes qualified local refs for reuse, and remote-tracking resolution rejects qualified refs outside refs/remotes/. Ref-name validation and test expectations also changed.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to d8025

A large batch of directory renames could become slower if linked-directory checks repeat for each event. The current code checks once per payload, but this test would not catch that performance regression.

Architecture Summary

Architecture risk: 🔵 Low · up to 9f8c3

The change affects 2 systems.

Changed systems: src, tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 25 changed files map to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/cli/runtime/websocket-transport.test.ts: Added the qualified repository-search references runtime capability to the protocol capability imports.
  • observed — Modified behavior in src/cli/runtime/websocket-transport.test.ts: The authentication capability expectation now includes REPO_SEARCH_QUALIFIED_REFS_RUNTIME_CAPABILITY after AUTOMATION_OWNER_FENCING_RUNTIME_CAPABILITY.
  • observed — Modified behavior in src/main/git/repo-base-ref-search.ts: Adds imports for qualified-selector detection and selector resolution.
  • observed — Modified behavior in src/main/git/repo-base-ref-search.ts: searchBaseRefDetails adds an optional includeQualifiedRefs parameter, defaulting to true.
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning For [#19515], the search uses full selectors to preserve recovered ref identity and derives local branch names separately. However, resolveBaseRefSearchSelector returns fullRef for every short nam… Restrict corruption recovery to unexpected short names containing U+FFFD. Keep full selectors where namespace disambiguation requires them. Update tests that require recovery of other unexpected short names.
Out of Scope Changes check ⚠️ Warning The PR also changes tests/e2e/cross-version-wire/release-checkout.unit.test.ts to change a released parser dependency assertion, and changes `src/renderer/src/components/right-sidebar/file-explorer-… Remove the release-checkout and file-explorer test changes from this PR, or submit them as separate changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 27 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing truncated Unicode branch names in base-ref search.
Description check ✅ Passed The description covers the required sections, explains the problem and solution, links issue #19515, includes visual proof, and reports testing and compatibility considerations. The AI Disclosure sect…
Full details: Linked Issues check

Explanation

For [#19515], the search uses full selectors to preserve recovered ref identity and derives local branch names separately. However, resolveBaseRefSearchSelector returns fullRef for every short name outside the expected DWIM forms, even when it has no U+FFFD. The tests require this broader fallback for feature/ and origin/fea. Issue #19515 limits corruption recovery to short names containing U+FFFD that match none of the complete forms.

Full details: Out of Scope Changes check

Explanation

The PR also changes tests/e2e/cross-version-wire/release-checkout.unit.test.ts to change a released parser dependency assertion, and changes src/renderer/src/components/right-sidebar/file-explorer-watch-reconcile.test.ts to update a file-explorer scan-count assertion. Neither change has a connection to base-ref search or worktree creation for [#19515].

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Qualify slash-named local branches before worktree creation can interpret
them as remote refs. Preserve nested HEAD and reserved-prefix identities,
accept valid dotted ref components, and advertise support on local RPC.

Keep qualified local selectors out of native/SSH remote-fetch planning,
and exercise the existing relay argument validator in search tests.

Add real Git collision tests with configured and orphan tracking refs.
@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial review loop completed with three independent reviewers over four rounds. Final source review is clean.

Fixed the concrete findings: valid dotted ref components were being excluded, local desktop RPC lacked the capability, qualified local refs could be mistaken for a remote named refs, and local/remote collisions could select the wrong commit with loose Git shortening. Slash-named locals now keep exact selectors even when tracking refs are orphaned or outside the search page. Native and SSH creation keep local and remote namespaces separate.

Verified: 220 focused tests pass; all 77 Git tests pass against both current Git and affected Apple Git-154 under en_US.UTF-8. Typecheck, changed-code quality, and the complete desktop build pass. The SSH test exercises the actual relay argument validator; Git commands and the relay wire contract remain unchanged.

Compatibility tradeoff: older clients safely omit qualified slash-named local branches until upgraded. Current clients retain them and use the separate local branch name for naming/reuse.

@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Updated reviewed head: 9f8c3c94b2d7fcab1c8d85795ceca35548da7821. All three adversarial reviewers rechecked the CI base update and found it clean. Fresh local validation: 221 focused tests, 119 cross-version tests, typecheck, and the changed-code quality gate pass.

The preceding CI failure was inherited from main: its release-checkout test expected a missing @streamparser/json dependency although the harness already pins it for old releases. Corrected the assertion to verify actual released parsing. Fresh CI is running before merge.

@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Final reviewed head: d80254a8d9e86bef60afb45fa15071b4af67e95f. All three reviewers independently approved the test-only correction of an inherited file-explorer assertion: the existing code performs one linked-directory index scan and one subtree purge, rather than one total scan. The exact two-scan bound still detects per-event fan-out. All 14 tests pass. Branch-selector production code is unchanged.

Git, cross-version wire, Linux/Windows packaging, relay, mobile, typecheck and native smoke checks passed on the preceding head. Fresh CI is pending on this final commit.

@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/right-sidebar/file-explorer-watch-reconcile.test.ts (1)

434-435: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Count the linked-directory traversal in this performance test.

This test sends 1,000 directory-rename events, but keyVisits counts only property-descriptor reads caused by Object.keys(cache). hasCachedDirectoryLink separately traverses pathIndex.values(). The current hasLinkedCache ??= limits that check to once per payload, but a regression that repeats it per event would still pass this assertion while adding a full directory-index traversal for every event. Count or otherwise bound the entries visited by that traversal.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4fbf901a-1ec2-451b-a64b-0e3311592720
📥 Commits

Reviewing files that changed from the base of the PR and between 9f8c3c9 and d80254a.

📒 Files selected for processing (1)
  • src/renderer/src/components/right-sidebar/file-explorer-watch-reconcile.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Final reviewed head: 524ccaee00833690609da58530eddacf0e0ee59a. All three reviewers found the concurrent-main merge clean; ref-search and worktree-creation production code is unchanged from the fully green CI head d80254a8d9e86bef60afb45fa15071b4af67e95f. The only conflict was test wording where main independently adopted the same two-scan expectation; main's version is retained. Fresh merged-checkout validation passes: 235 focused tests, 121 cross-version tests, typecheck, and changed-code quality.

@nwparker
nwparker merged commit 1de3aa4 into main Oct 6, 2026
9 of 14 checks passed
@nwparker
nwparker deleted the nwparker/bug-base-ref-search-truncates-chinese-branch-nam branch October 6, 2026 06:47
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.

[Bug]: Base-ref search truncates Chinese branch names on Apple Git

1 participant