Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/run/ralph-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function spawnRalphLoop(
const child = spawn(cachedBashCommand ?? "bash", [BASH_RALPH_LOOP_PATH], {
cwd: projectDir,
env,
stdio: options.inheritStdio ? "inherit" : ["ignore", "pipe", "pipe"],
stdio: options.inheritStdio ? "inherit" : ["ignore", "ignore", "ignore"],
detached: process.platform !== "win32",
windowsHide: true,
});
Expand Down
17 changes: 15 additions & 2 deletions tests/run/ralph-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe("spawnRalphLoop", () => {
);
});

it("uses piped stdio when inheritStdio is false", async () => {
it("uses ignored stdio when inheritStdio is false", async () => {
const mockChild = createMockChild();
mockSpawn.mockReturnValue(mockChild);

Expand All @@ -404,11 +404,24 @@ describe("spawnRalphLoop", () => {
"bash",
expect.any(Array),
expect.objectContaining({
stdio: ["ignore", "pipe", "pipe"],
stdio: ["ignore", "ignore", "ignore"],
})
);
});

it("detach does not throw when stdout/stderr are null (ignore stdio mode)", async () => {
const mockChild = createMockChild();
mockSpawn.mockReturnValue(mockChild);

const { spawnRalphLoop } = await import("../../src/run/ralph-process.js");
const rp = spawnRalphLoop("/project", "claude-code", { inheritStdio: false });

// child.stdout and child.stderr are null when stdio is "ignore" — detach() must not throw
expect(() => rp.detach()).not.toThrow();
expect(mockChild.unref).toHaveBeenCalled();
expect(rp.state).toBe("detached");
});

it("tracks exit code and updates state on child exit", async () => {
const mockChild = createMockChild();
mockSpawn.mockReturnValue(mockChild);
Expand Down