Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

fix: start the bootstrap's qmd calls with windowsHide, so Windows opens no console window for each (#385)

Brenno Ferraribe9be2e9dc49
diff --git a/.claude/scripts/tests/qmd-bootstrap.test.ts b/.claude/scripts/tests/qmd-bootstrap.test.ts
index 8f46364..f28e63d 100644
--- a/.claude/scripts/tests/qmd-bootstrap.test.ts
+++ b/.claude/scripts/tests/qmd-bootstrap.test.ts
@@ -16,6 +16,7 @@ import {
isUnknownSubcommandFailure,
legacyCollectionCandidate,
} from "../lib/qmd-bootstrap.ts";
+import { spawnQmd } from "../../../.scripts/qmd-bootstrap.ts";
describe("buildCollectionAddArgs", () => {
test("emits the exact argv shape qmd's `collection add` expects", () => {
@@ -324,3 +325,15 @@ describe("isUnknownSubcommandFailure", () => {
assert.equal(isUnknownSubcommandFailure({ stdout: "", stderr: "" }), false);
});
});
+
+// Through the spawn seam, so no qmd starts here.
+describe("spawnQmd", () => {
+ test("starts qmd with windowsHide, so a console-less bootstrap opens no window (#381)", () => {
+ let hidden: boolean | undefined;
+ spawnQmd("qmd.js", ["--version"], (_cmd, _args, options) => {
+ hidden = options.windowsHide;
+ return { status: 0, signal: null, stdout: "", stderr: "" };
+ });
+ assert.equal(hidden, true);
+ });
+});
diff --git a/.scripts/qmd-bootstrap.ts b/.scripts/qmd-bootstrap.ts
index 60de92d..f357c64 100644
--- a/.scripts/qmd-bootstrap.ts
+++ b/.scripts/qmd-bootstrap.ts
@@ -28,7 +28,7 @@
* node --experimental-strip-types .scripts/qmd-bootstrap.ts
*/
-import { spawnSync } from "node:child_process";
+import { spawnSync, type SpawnSyncOptionsWithStringEncoding, type SpawnSyncReturns } from "node:child_process";
import { readFileSync } from "node:fs";
import { warn } from "../.claude/scripts/lib/hook-io.ts";
@@ -96,14 +96,23 @@ type SpawnOutcome = {
/**
* Run qmd and capture both streams so callers can classify failures.
* Captured output is echoed to the user afterward so the visible log matches
- * `stdio: "inherit"` ordering.
+ * `stdio: "inherit"` ordering. `spawn` is a seam for tests, which check the
+ * options without starting qmd.
*/
-function spawnQmd(
+export function spawnQmd(
entry: string | null,
subcommandArgs: readonly string[],
+ spawn: (
+ cmd: string,
+ args: string[],
+ options: SpawnSyncOptionsWithStringEncoding,
+ ) => Pick<SpawnSyncReturns<string>, "status" | "signal" | "stdout" | "stderr"> = spawnSync,
): SpawnOutcome {
const { cmd, args, shell } = buildQmdCommand(entry, subcommandArgs);
- const r = spawnSync(cmd, args as string[], { shell, encoding: "utf-8" });
+ // windowsHide: session-start starts this bootstrap detached, so it has no
+ // console, and on Windows a console program started from it without the
+ // flag opens a console window of its own (#381).
+ const r = spawn(cmd, args as string[], { shell, encoding: "utf-8", windowsHide: true });
return {
status: r.status,
signal: r.signal,