Skip to content

Commit 0429060

Browse files
fix(coding-agents): hide Windows child processes (#3736)
1 parent 1cbd77d commit 0429060

12 files changed

Lines changed: 28 additions & 8 deletions

File tree

hindsight-integrations/coding-agents/src/core/bank.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ export function getProjectRootFromGit(directory: string): string | null {
5151
const commonDir = execFileSync(
5252
"git",
5353
["rev-parse", "--path-format=absolute", "--git-common-dir"],
54-
{ cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1000 }
54+
{
55+
cwd: directory,
56+
encoding: "utf-8",
57+
stdio: ["ignore", "pipe", "ignore"],
58+
timeout: 1000,
59+
windowsHide: true,
60+
}
5561
).trim();
5662
if (!commonDir) return null;
5763
// clones + `git worktree add`: common-dir is `<main root>/.git`; bare repos: the dir itself.

hindsight-integrations/coding-agents/src/core/daemon.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ describe("startDaemonDetached", () => {
180180
const [cmd, args, opts] = spawn.mock.calls[0] as unknown as [
181181
string,
182182
string[],
183-
{ detached: boolean; stdio: string },
183+
{ detached: boolean; stdio: string; windowsHide: boolean },
184184
];
185185
expect(cmd).toBe("node");
186186
expect(args[0]).toMatch(/daemon-start\.js$/);
187187
expect(opts.detached).toBe(true);
188188
expect(opts.stdio).toBe("ignore");
189+
expect(opts.windowsHide).toBe(true);
189190
// An async spawn 'error' event would otherwise crash the hook process.
190191
expect(child.on).toHaveBeenCalledWith("error", expect.any(Function));
191192
expect(child.unref).toHaveBeenCalled();

hindsight-integrations/coding-agents/src/core/daemon.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export function startDaemonDetached(
195195
const child = spawnFn("node", [starter, "--harness", harness], {
196196
detached: true,
197197
stdio: "ignore",
198+
windowsHide: true,
198199
});
199200
// spawn() failures often surface ASYNCHRONOUSLY as an 'error' event; unhandled, that would
200201
// crash the hook.

hindsight-integrations/coding-agents/src/core/git.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const US = "\x1f";
1616
const RS = "\x1e"; // record separator between commits in gitLogText
1717

1818
function git(repo: string, ...args: string[]): string {
19-
return execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 1 << 28 });
19+
return execFileSync("git", ["-C", repo, ...args], {
20+
encoding: "utf8",
21+
maxBuffer: 1 << 28,
22+
windowsHide: true,
23+
});
2024
}
2125

2226
/** The bank-facing name for a repo — WORKTREE-AWARE (all worktrees produce the main checkout's

hindsight-integrations/coding-agents/src/core/seed.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("startBackgroundSeed", () => {
1313
expect(spawn).toHaveBeenCalledWith(
1414
"node",
1515
["/dist/deepen.js", "--repo", "/some/repo", "--gitlog-limit", String(DEFAULT_SEED_LIMIT)],
16-
{ detached: true, stdio: expect.anything() }
16+
{ detached: true, stdio: expect.anything(), windowsHide: true }
1717
);
1818
expect(spawn.mock.results[0].value.unref).toHaveBeenCalled();
1919
});
@@ -38,7 +38,7 @@ describe("startBackgroundSeed", () => {
3838
expect(spawn).toHaveBeenCalledWith(
3939
"node",
4040
["/dist/deepen.js", "--repo", "/some/repo", "--gitlog-limit", "50"],
41-
{ detached: true, stdio: expect.anything() }
41+
{ detached: true, stdio: expect.anything(), windowsHide: true }
4242
);
4343
});
4444

@@ -60,7 +60,7 @@ describe("startBackgroundSeed", () => {
6060
"--harness",
6161
"antigravity-cli",
6262
],
63-
{ detached: true, stdio: expect.anything() }
63+
{ detached: true, stdio: expect.anything(), windowsHide: true }
6464
);
6565
});
6666

hindsight-integrations/coding-agents/src/core/seed.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function startBackgroundSeed(
4242
{
4343
detached: true,
4444
stdio: "ignore",
45+
windowsHide: true,
4546
}
4647
);
4748
// spawn() failures (ENOENT/EACCES/fd exhaustion/sandboxed environments) often arrive

hindsight-integrations/coding-agents/src/core/session-start.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ async function gitSyncNote(args: {
9898
try {
9999
const { execFileSync } = await import("node:child_process");
100100
const n = Number(
101-
execFileSync("git", ["-C", cwd, "rev-list", "--count", "HEAD"], { encoding: "utf8" }).trim()
101+
execFileSync("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
102+
encoding: "utf8",
103+
windowsHide: true,
104+
}).trim()
102105
);
103106
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
104107
} catch {

hindsight-integrations/coding-agents/src/core/status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function commitCount(repoDir: string): number | null {
4848
try {
4949
const out = execFileSync("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
5050
encoding: "utf8",
51+
windowsHide: true,
5152
});
5253
return Number(out.trim()) || 0;
5354
} catch {

hindsight-integrations/coding-agents/src/core/survey.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe("startCodebaseSurvey", () => {
8383
expect(options.cwd).toBe("/repo");
8484
expect(options.detached).toBe(true);
8585
expect(options.stdio).toBe("ignore");
86+
expect(options.windowsHide).toBe(true);
8687
expect(options.env.HINDSIGHT_DISABLE_HOOKS).toBe("1");
8788

8889
const child = spawn.mock.results[0].value;

hindsight-integrations/coding-agents/src/core/survey.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export function startCodebaseSurvey(
338338
cwd: repoDir,
339339
detached: true,
340340
stdio: "ignore",
341+
windowsHide: true,
341342
env: plan.env,
342343
});
343344
// spawn() failures (binary not found, EACCES, sandboxed environments) often arrive

0 commit comments

Comments
 (0)