Skip to content

Reduce Git refresh subprocess fanout - #6324

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/diagnose-bricked-machine
Jun 25, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/diagnose-bricked-machine

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This reduces Git subprocess pressure during PR/worktree refresh paths that were showing up in crash diagnostics with thousands of git.exec spans.

  • Replace per-branch upstream probes with a coalesced git for-each-ref snapshot per repo/runtime, including SSH/WSL/local cache separation.
  • Cache local GitHub remote identity misses against a .git/config signature so repeated missing/non-GitHub remote probes do not keep spawning Git.
  • Cache unsupported local git merge-tree --merge-base capability per runtime and reuse the legacy merge-tree path after the first failure.
  • Cache local detected-worktree scans per repo/runtime and avoid updating local roots or pruning lineage from stale cache hits.

This is root-cause pressure reduction for repeated background Git/GitHub refresh work. It is not intended to prove every crash family is fixed; renderer active-status polling/backoff and lazy chunk load/syntax crashes remain separate work.

Tests

  • pnpm run typecheck
  • pnpm run lint
  • git diff --check
  • pnpm exec vitest run --config config/vitest.config.ts src/main/github/gh-utils.test.ts src/main/github/client.test.ts --reporter=dot --testTimeout=15000 (119 tests)
  • pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/worktrees.test.ts --reporter=dot --testTimeout=15000 (154 tests)
  • pnpm build:relay
  • Electron validation from this exact worktree: window.api.app.getIdentity() reported cutlassfish @ brennanb2025/diagnose-bricked-machine.
  • Local disposable repo validation: repeated non-GitHub slug/worktree lookups produced stable null/one-worktree results and bounded Git work (remote: 1 failure, worktree: 1 success); ten GitHub-style PR branch lookups produced one upstream snapshot rather than per-lookup branch probes (for-each-ref: 1).
  • SSH live validation with a throwaway Linux Docker target and real remote repo at /work/demo-project: registered through Orca SSH, verified remote git status --short --branch and git worktree list --porcelain, then repeated the PR branch lookup path through the app.
  • SSH regression evidence: before the final fix, ten SSH PR lookups produced 11 for-each-ref calls; after the fix, ten lookups for a newly-created remote branch produced for-each-ref: 1 and remote get-url: 2.
  • SSH cleanup complete: stopped only the Electron process started for the test, removed the Docker container, removed the temp SSH key/profile directory.

Made with Orca 🐋

Screenshots

No visual change.

AI Review Report

CodeRabbit code review threads were addressed and resolved. A separate review-code subagent pass reported no issues.

Security Audit

No auth, credential storage, or permission model changes. The change reduces repeated Git/GitHub subprocess work and keeps SSH, WSL, and host caches separated by runtime.

Notes

Validated normal sidebar/PR checks refresh behavior on demo-project. Active git status polling and lazy chunk load/syntax crashes remain separate work.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds local Git config signature reading, uses it to invalidate owner/repo cache entries, changes tracked-upstream discovery to bulk for-each-ref snapshots with runtime-scoped caching, caches unsupported merge-tree --merge-base capability per environment, and keys detected worktree scans by repo plus local Git options.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 matches the core change: reducing Git refresh subprocess fanout.
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.
Description check ✅ Passed The description covers the required sections and is largely complete, with only a minor heading mismatch and some review detail left high-level.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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: 3

🧹 Nitpick comments (1)
src/main/github/local-git-config-signature.ts (1)

16-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a short Why comment for the host-only early return.

This branch encodes the PR's local-only invalidation rule, but the SSH/WSL exclusion is otherwise easy to misread as an accidental omission. As per coding guidelines "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5ce814d9-4cbc-42de-b24f-b7e26508bf02

📥 Commits

Reviewing files that changed from the base of the PR and between c328ac8 and f434ef4.

📒 Files selected for processing (8)
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/conflict-summary.ts
  • src/main/github/gh-utils.test.ts
  • src/main/github/github-repository-identity.ts
  • src/main/github/local-git-config-signature.ts
  • src/main/ipc/worktrees.test.ts
  • src/main/ipc/worktrees.ts

Comment thread src/main/github/client.ts Resolved
brennanb2025 and others added 3 commits June 24, 2026 21:39
Only cache stable missing-remote negatives for five minutes; transient
git remote get-url failures retry on the next lookup. Tracked-upstream
snapshot waiters re-probe missing branches, coalesce superseded probes,
and avoid caching failed for-each-ref scans that would fan out per branch.
@brennanb2025
brennanb2025 merged commit c10b77d into main Jun 25, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/diagnose-bricked-machine branch June 25, 2026 20:00
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

1 participant