orca icon indicating copy to clipboard operation
orca copied to clipboard

Avoid unborn HEAD branch probe failures

Open brennanb2025 opened this issue 5 months ago β€’ 1 comments

Description

  • read the first-work auto-rename current branch with git symbolic-ref --quiet --short HEAD
  • keep the post-generation branch recheck on the same non-dereferencing branch probe
  • add a regression for an unborn/empty repo where rev-parse --abbrev-ref HEAD fails with ambiguous argument HEAD

Crash evidence

  • Original report 03-renderer-oom-taifunk recorded a renderer OOM on Windows at 2026-06-30T21:53:16.870Z.
  • The crash breadcrumbs were dominated by agent working transitions, which is the signal that triggers first-work branch auto-rename.
  • The NDJSON crash window includes repeated git rev-parse --abbrev-ref HEAD failures against C:\Users\taifu\CLAUDE with fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
  • That error is the normal behavior of rev-parse --abbrev-ref HEAD in an unborn repo. The hook only needs the symbolic branch name, and git symbolic-ref --quiet --short HEAD reads it without requiring a commit.

ELI5

Orca was asking Git β€œwhat branch am I on?” in a way that only works after the branch has at least one commit. In brand-new or unusual repos, Git answered with an error every time the auto-rename helper woke up. Now Orca asks the branch-name question directly, so it does not trip over repos whose HEAD has no commit yet.

Validation

  • Confirmed the new regression failed before the fix: the hook called rev-parse --abbrev-ref HEAD, logged the unborn-HEAD error, and did not rename.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/agent-hooks/first-work-branch-rename.test.ts src/main/git/branch-rename.test.ts src/main/git/upstream.test.ts src/main/git/status-upstream-probe-churn.test.ts src/main/git/status-upstream-negative-cache.test.ts passed: 69 tests.
  • pnpm run typecheck passed.
  • Pre-commit hooks ran oxlint, oxlint --config config/oxlint-react-doctor.json, and oxfmt --write on staged files.

Tradeoffs / gaps

  • This removes the repeated unborn-HEAD failure path from the auto-rename hook. It is not proof that the native renderer OOM in report 03 is fully fixed without the original C:\Users\taifu\... repos or a fresh current-build crash bundle.
  • Detached HEAD still returns no symbolic branch and remains a retry/skip path for the convenience auto-rename feature.
  • The fix applies to both local and SSH auto-rename branch probes because the helper uses the shared GitExec abstraction.

brennanb2025 avatar Jul 03 '26 05:07 brennanb2025

Review Change Stack

πŸ“ Walkthrough

Walkthrough

This change modifies how the current git branch is determined in the auto-rename hook, replacing git rev-parse --abbrev-ref HEAD with a new readCurrentBranch helper that uses git symbolic-ref --quiet --short HEAD. This avoids failures when HEAD is unborn. The test harness's mock git responder is updated to handle symbolic-ref and rev-parse --verify requests distinctly, replacing its previous catch-all rev-parse handling. Corresponding tests are added and updated to reflect the new branch-reading behavior, including a new test for the unborn HEAD scenario.

Changes

Area Change
first-work-branch-rename.ts Adds readCurrentBranch(exec) helper using symbolic-ref; replaces two rev-parse based branch lookups
first-work-branch-rename-test-harness.ts Refines mock git responder to handle symbolic-ref and rev-parse --verify distinctly
first-work-branch-rename.test.ts Adds unborn-HEAD test; updates existing tests' git mocks for symbolic-ref

Sequence Diagram(s)

sequenceDiagram
  participant runAutoRename
  participant readCurrentBranch
  participant git

  runAutoRename->>readCurrentBranch: readCurrentBranch(exec)
  readCurrentBranch->>git: symbolic-ref --quiet --short HEAD
  git-->>readCurrentBranch: branch name
  readCurrentBranch-->>runAutoRename: trimmed branch name

Estimated code review effort: 2 (~15 minutes)

Related PRs: None identified.

Suggested labels: none

Suggested reviewers: none

Poem

A rabbit hops past HEAD unborn, No rev-parse cries at early dawn, symbolic-ref shows the way so true, Branches renamed, tests pass anew, Hop, hop, hooray β€” the mocks align! πŸ‡

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is informative but misses several required template sections, including Summary, Screenshots, AI Review Report, Security Audit, and Notes. Reformat the description to match the template and add the missing required sections, including screenshots status, testing checklist, AI review, security audit, and notes.
βœ… Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
Title check βœ… Passed The title clearly summarizes the main change: switching the branch probe to avoid unborn HEAD failures.

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[bot] avatar Jul 03 '26 06:07 coderabbitai[bot]

Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-03T06:40:17Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes.

OrcaWin avatar Oct 27 '26 09:10 OrcaWin