Skip to content

fix(git): preserve Unicode refs in base search - #19540

Closed
nishino-tsukasa wants to merge 2 commits into
stablyai:mainfrom
nishino-tsukasa:fix/unicode-ref-search
Closed

nishino-tsukasa wants to merge 2 commits into
stablyai:mainfrom
nishino-tsukasa:fix/unicode-ref-search

Conversation

@nishino-tsukasa

@nishino-tsukasa nishino-tsukasa commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On affected macOS Git builds, searching for a Chinese-named branch could give Orca a cut-off name ending in �. Orca now detects that broken short name and uses the intact, uniquely resolvable full Git ref while keeping the intended local branch name for worktree creation.

What Changed

  • Compare %(refname:short) with the intact full ref and preserve complete natural, namespace-qualified, and full DWIM forms, including legitimate names containing U+FFFD.
  • Promote corrupt or namespace-ambiguous short refs to refs/heads/... or refs/remotes/..., then derive localBranchName independently from the full ref.
  • Treat a fully qualified local ref as the existing local branch in composer reuse and checked-out-branch handling.
  • Gate qualified ref results behind repo.search-qualified-refs.v1; new native, Web, CLI, and mobile clients advertise it, while older remote clients fail closed by omitting rows they cannot interpret safely.
  • Add real Apple Git and synthetic regression coverage for Unicode truncation, literal U+FFFD, local/remote/tag collisions, multi-segment refs, attached worktrees, and mixed-version RPC projection.

Why

Apple Git 2.39.5 can split a multibyte ref while producing %(refname:short), even though %(refname) remains intact. Trusting the damaged short value makes the selected base ref impossible to resolve. Recovering from the full ref fixes the failure, while exact DWIM-form checks and namespace qualification avoid selecting a same-name tag or the wrong local/remote ref.

Linked Issue

Fixes #19515

Visual Proof

N/A — this changes Git ref parsing and compatibility projection; it does not change UI layout or styling.

Testing

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

Validated on macOS with git version 2.39.5 (Apple Git-154):

  • Focused feature suites: 5 files, 128 tests passed.
  • Transport/capability suites: 6 files, 79 tests passed.
  • pnpm typecheck: passed.
  • pnpm lint: passed (only pre-existing collator warnings).
  • Changed-code quality gates: 0 new findings across 13 changed files.
  • pnpm build: passed for desktop, relay, CLI, renderer, Web, and native. The optional /usr/local/bin/orca-dev symlink could not be installed without elevated permission; the build still exited 0.
  • Full pnpm test: 8206 files / 76216 tests passed; 62 files / 386 tests skipped. Five unrelated environment-sensitive files remained red (5 failed tests plus 1 suite setup failure):
    • config/scripts/workflow-ref-reachability.test.mjs: Apple Git lacks git init --ref-format=reftable.
    • config/scripts/skill-recipe-shell.test.mjs: the host Bash reports vercel_args[@]: unbound variable before the expected cleanup assertion.
    • src/main/agent-hooks/wsl-hook-relay-manager.test.ts and wsl-hook-relay-live.integration.test.ts: the macOS host rejects synthetic WSL homes under /tmp as outside the guest home.
    • src/main/ssh/ssh-relay-node-headers.test.ts: the ephemeral npm Node package does not expose the expected local header prefix.
  • The standalone mobile Vitest target was not available because this checkout does not have the Expo dependency tree installed; the shared mobile capability helper and all production capability paths were reviewed, while CI can cover the mobile workspace.

AI Disclosure

OpenAI Codex (GPT-5) was used for diagnosis, implementation, tests, and review. The final candidate was independently reviewed along specification and engineering-standards axes, both with no findings.

Review

  • Cross-platform: normal Git short refs remain unchanged; the fallback is exercised only for exact namespace disambiguation or proven corruption. No platform-specific command was added.
  • Local / SSH / remote: the same parser covers local and SSH-backed searches; runtime capability projection preserves mixed-version safety.
  • Agents / integrations: no agent or integration behavior changed.
  • Performance: no extra Git process or unbounded scan was added; parsing remains linear in the already bounded result set.
  • Security: no new command interpolation or filesystem authority was introduced; existing ref validation and bounded search limits remain in place.
  • UI: no visual layout change.

Author

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

No issues found in security, cross-platform support, remote SSH, mobile compatibility, general backwards compatibility, or performance during final dual-axis review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

The final checklist item remains unchecked because the full local test suite has the environment-sensitive failures itemized above; lint, typecheck, build, and all change-related tests pass.

@pullfrog

pullfrog Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The change preserves complete Unicode and namespace-qualified Git refs during base-ref search. It adds the REPO_SEARCH_QUALIFIED_REFS_RUNTIME_CAPABILITY capability to runtime registries, remote transports, and authentication frames. Repository search responses filter qualified refs for legacy clients while retaining them for capable and in-process clients. Composer branch reuse recognizes both short local names and refs/heads/ selectors. Regression tests cover parsing, capability advertisement, response projection, and branch reuse.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 1e712

Older clients can miss available base refs when creating workspaces, changing settings, or creating pull requests. Fix the search limit before merging unless this mixed-version behavior is explicitly accepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 13 files. 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 clearly identifies the primary change: preserving Unicode refs during Git base-ref search. It is concise and relevant to the broader ref-resolution fixes.
Description check ✅ Passed The description includes all required sections, explains the user impact and implementation, links issue #19515, documents testing and known environment failures, and addresses compatibility, security…
Linked Issues check ✅ Passed For #19515, parseAndFilterSearchRefDetails compares the Git short ref with complete forms and returns refs/heads/... or refs/remotes/... when U+FFFD indicates corrupted multibyte output. It pres…
Out of Scope Changes check ✅ Passed The capability declaration, RPC projection, client advertisement, composer reuse handling, and related tests support the qualified-ref behavior required by #19515. The changes provide fallback filteri…
  • Fix all pre-merge checks with AI

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d41b78ed-dd05-40d9-a1a2-e64cc6b38f60

📥 Commits

Reviewing files that changed from the base of the PR and between 285e09f and 1e71290.

📒 Files selected for processing (7)
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/runtime/rpc/methods/repo.test.ts
  • src/main/runtime/rpc/methods/repo.ts
  • src/renderer/src/web/web-runtime-client.test.ts
  • src/renderer/src/web/web-runtime-connection-frame-router.ts
  • src/shared/protocol-version.ts
  • src/shared/remote-runtime-client-capabilities.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +189 to +190
await runtime.searchRepoRefs(params.repo, params.query, params.limit),
clientCapabilities

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Filter legacy results before applying the result limit.

When qualified refs fill the first limit search results, the projection removes them after the bounded search. A legacy client can receive no refs even though an unqualified match exists beyond that limit. The base-ref search limits its results before this projection. For legacy clients, collect eligible refs before applying the final result limit. (raw.githubusercontent.com)

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — first Pullfrog review of this PR; no prior review existed, and the only delta since the previous event was a merge of main into the branch (base-branch noise, no net fix changes).

  • Recovered Apple-Git-truncated Unicode ref names by comparing the emitted %(refname:short) against the intact full ref, keeping the natural short form only when it is genuinely intact (including a literal U+FFFD) and preserving namespace-qualified selectors otherwise.
  • Derived localBranchName independently from the full ref, so a disambiguated refs/heads/… selector maps back to its real branch name.
  • Gated namespace-qualified selectors behind repo.search-qualified-refs.v1 and filtered them out for legacy refs-only clients in projectRepoSearchRefsForClient, which follows the existing clientCapabilities === undefined = trusted-caller convention.
  • Advertised the capability from the host, native/Electron remote clients, the shared remote client defaults (CLI/Web/mobile), and the Web frame router.
  • Treated fully qualified local selectors as the local branch in the shared composer reuse/override logic used by both desktop and mobile.
  • Added synthetic and real-Git regression coverage for truncation, literal U+FFFD, local/remote/tag collisions, multi-segment refs, and mixed-version RPC projection.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

nwparker added a commit that referenced this pull request Oct 6, 2026
Preserve complete branch selectors when Git truncates or disambiguates short names, and keep slash-named local branches separate from remote-tracking refs through worktree creation and reuse.

Keep native/SSH namespace boundaries and mixed-version client capability gates intact. Accept Git-valid dotted components and cover collisions with configured and orphan tracking refs.

Adapted from @nishino-tsukasa's #19540. Independently reviewed in seven adversarial rounds; 235 focused tests and 77 affected-Apple-Git tests pass, along with typecheck, quality checks, and the desktop build.

Correct the inherited file-explorer cache-scan expectation while retaining its exact constant-work bound.

Correct the inherited release-parser compatibility assertion to match the pinned test dependency; all 121 cross-version tests pass locally.

Fixes #19515

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

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Superseded by merged #25777, adapted from this contribution with co-author credit. Thank you @nishino-tsukasa for the original fix and regression coverage.

@nwparker nwparker closed this Oct 6, 2026
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

2 participants