Skip to content

fix(coding-agents): capture background git stderr - #4334

Merged
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
kyletser:fix/coding-agents-git-stderr
Sep 15, 2026
Merged

nicoloboschi merged 1 commit into
vectorize-io:mainfrom
kyletser:fix/coding-agents-git-stderr

Conversation

@kyletser

Copy link
Copy Markdown
Contributor

Summary

Fixes #4328.

Capture stderr explicitly for background Git subprocesses in the coding-agents integration. With execFileSync, catching an error does not stop Node from forwarding the failed child's stderr to the host process when stdio is omitted. In Pi, that output can corrupt the TUI.

The change covers the shared Git helper, sync-status commit count, incremental-sync helper, and the late commit count used for the session-start full-sync banner. Stdout, error status, and captured error diagnostics remain available; existing fallback values and ingestion errors are preserved.

This is intentionally limited to stderr isolation. It does not change autoSeed, gitIngest, survey defaults, or introduce a cached repository probe.

Regression coverage

Five tests run the actual core code with real Git subprocesses inside a child Node process and assert that the host's stderr is empty. They cover non-repository fallbacks, retained diagnostics on a propagated ingestion failure, sync status, best-effort fetch/ref fallback, and a repository disappearing before the session-start banner's late commit count.

The tests inspect process stderr rather than mocking console.error, which would miss this failure.

Validation

From hindsight-integrations/coding-agents, on Linux with Node 24.15.0:

  • npm test: 1,022 passed across 73 files (the package's standard command excludes live E2E tests).
  • npx tsc --noEmit: passed.
  • npm run build: passed.

Also checked all changed files with Prettier and git diff --check. The five new tests failed before the fix and passed after it. Temporarily removing the shared helper's stdio setting made two regression tests fail again; restoring it returned all five to green.

Windows targeted tests passed (54 tests), as did type checking and build. The Windows full suite has existing path/permission failures, reproduced on an unchanged LF checkout of the same upstream commit; the CRLF checkout also has docs-fixture failures. The monorepo lint script could not run from that CRLF checkout, so this does not claim a full-monorepo lint pass. No tests were weakened or skipped to obtain the Linux package result.

This verifies the subprocess boundary and the shared Pi session-start path, not a manual interactive Pi session.

Review guide

The production diff only adds explicit stdio settings and comments at four Git call sites. src/core/git-stderr.test.ts contains the real-process regressions. There are no dependency, API, configuration, or generated-file changes.

Keep failed Git probes from writing directly into the host TUI while preserving fallback results and error diagnostics. Cover all four synchronous Git call sites with real-process regression tests.

Fixes vectorize-io#4328
Copilot AI lite review requested due to automatic review settings September 12, 2026 10:02

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nicoloboschi
nicoloboschi merged commit 3ea5489 into vectorize-io:main Sep 15, 2026
95 checks passed
nicoloboschi added a commit that referenced this pull request Sep 29, 2026
…erminal (#4918)

* fix(coding-agents): keep foreign survey-baseline git errors off the terminal (#4525)

The session-start fatal lines came from execFileSync forwarding git stderr;
#4334 already captures it in git(), status and session-start (shipped in 0.7.0,
the reporter runs 0.6.1). This pins the shared-bank case with a regression test
and closes the last uncaptured call, deepen's rev-list, which install runs with
inherited stdio.

* test(coding-agents): guard every git call against leaking stderr

Review fix: the deepen.ts stdio change had no test. Add a structural test that
scans the shipped sources and fails on any execFileSync("git") call that does
not capture stderr, so the next new call can't reintroduce #4328/#4525.

* test(coding-agents): explain the guard's minimum call count
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.

pi plugin: git probe stderr not captured — 'fatal: not a git repository' leaks into the host TUI and breaks input

3 participants