Skip to content

Fix git status startup spawn failures#15

Merged
khaliqgant merged 1 commit into
mainfrom
codex/fix-git-status-ebadf
May 21, 2026
Merged

Fix git status startup spawn failures#15
khaliqgant merged 1 commit into
mainfrom
codex/fix-git-status-ebadf

Conversation

@khaliqgant

@khaliqgant khaliqgant commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

  • replace execFile-based git reads with a shared spawn runner that controls stdio explicitly
  • catch git:status failures in the IPC handler and return an empty status after a single warning instead of repeatedly rejecting during startup polling
  • stop full-diff startup from spawning one git diff --no-index process per untracked file
  • compute untracked summary additions in-process with bounded file reads, and skip overlapping renderer git polling requests

Verification

  • npm run build on the clean PR branch
  • local dirty checkout: npm run build
  • local dirty checkout: npm run typecheck
  • local dirty checkout startup smoke test with active Pear project: Electron main CPU stayed around 3-4%, no git diff --no-index child flood, and no repeated git:status spawn EBADF handler errors observed

Notes

  • npm run typecheck is not defined on current clean main
  • npx tsc -b --noEmit on clean main still fails on pre-existing type drift in cloud/proactive/store/index/DiffPane/GraphView/syntax-highlighter files`

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 4aafa95f-b062-42a0-8161-926176f66aab

📥 Commits

Reviewing files that changed from the base of the PR and between edf88e9 and 5011dfe.

📒 Files selected for processing (3)
  • src/main/git.ts
  • src/main/ipc-handlers.ts
  • src/renderer/src/stores/git-store.ts

📝 Walkthrough

Walkthrough

The pull request refactors Git command execution from execFile to spawn-based runGit, adds custom GitCommandError with stderr/stdout capture, changes untracked addition counting to read file contents directly instead of using git diff, introduces warning deduplication for IPC status failures, and adds concurrent request deduplication in the renderer store.

Changes

Git Operations Reliability and Performance

Layer / File(s) Summary
Git command execution refactoring
src/main/git.ts
GitCommandError class captures exit code, stdout, stderr. runGit helper built on spawn validates working directory, supports optional stdin and custom env, buffers output, enforces 10MB size limit, and provides consistent error semantics. git, gitWithEnv, and gitWithInput refactored to call runGit.
Direct untracked file line counting
src/main/git.ts
New countLines and getUntrackedAdditions helpers read up to 500 untracked files (1MB max each), count lines, and sum results with best-effort error handling, replacing previous per-file git diff --no-index approach.
getDiff and getSummary updates
src/main/git.ts
getDiff now returns only git diff output without appending generated no-index diffs. getSummary computes untracked additions via direct file reading and adds them to tracked totals.
IPC handler error deduplication
src/main/ipc-handlers.ts
Module-level gitStatusWarnings cache with error-to-message conversion and single-warning-per-path:message logging. git:status handler wrapped in try/catch, emits deduplicated warning on failure, returns empty array instead of error propagation.
Renderer store concurrent request deduplication
src/renderer/src/stores/git-store.ts
Module-level tracking sets for in-flight status, summary, project status, and diff requests. fetchStatus, fetchSummary, fetchProjectStatus, and fetchDiff early-return if request already in-flight, remove marker in finally, preserve existing state comparison and error fallbacks. selectFile resets diff and loading when file is cleared instead of triggering fetchDiff.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through git commands new,
With spawn instead of exec, a faster view,
Untracked files counted, errors deduped with care,
Concurrent requests blocked, no duplicate air!
Reliability blooms where duplication was—
The warren runs swiftly, no network pause! 🌱


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@khaliqgant khaliqgant force-pushed the codex/fix-git-status-ebadf branch from f0ea038 to 5011dfe Compare May 21, 2026 20:58
@khaliqgant khaliqgant merged commit 66a0242 into main May 21, 2026
1 check passed
miyaontherelay added a commit that referenced this pull request Jun 8, 2026
Fix #9: track last-sent rows/cols and skip duplicate resizePty IPC. The
ResizeObserver fires on every dragged pixel; the cell grid only changes
at discrete steps.

Fix #12: refuse a second concurrent mount of the same runtime into a
different container. Currently chunkAgents doesn't trigger this, but
silently reparenting would tear xterm out from under the original owner.

Fix #15: post-font-settle metrics may differ from the pre-settle ones
the predictor was built with. Call predictiveEcho.onResize after the
refit so column wraps line up with the real grid.

Also adds refreshOnShow() and setInputSrttGetter() to the runtime
interface in preparation for use-terminal wiring.
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