Compare commits

...
Author SHA1 Message Date
t3-code[bot]andExotic 16eedd9473 test(server): preserve posix utility lookup behavior
Co-authored-by: Exotic <[email protected]>
2026-08-12 20:40:19 +00:00
t3-code[bot]andExotic 972740d55c docs(server): explain macos utility paths
Co-authored-by: Exotic <[email protected]>
2026-08-12 20:30:29 +00:00
t3-code[bot]andExotic 96b5f889cd fix(server): avoid macos path walks in terminal polling
Co-authored-by: Exotic <[email protected]>
2026-08-12 20:25:47 +00:00
2 changed files with 71 additions and 4 deletions

No files matched your search

+64
View File
@@ -24,6 +24,7 @@ import * as Ref from "effect/Ref";
import * as Schedule from "effect/Schedule";
import * as Scope from "effect/Scope";
import * as TestClock from "effect/testing/TestClock";
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
import { expect } from "vite-plus/test";
import * as ProcessRunner from "../processRunner.ts";
@@ -953,6 +954,69 @@ it.layer(
}),
);
it.effect("uses platform utility paths for POSIX subprocess polling", () =>
Effect.gen(function* () {
const calls: ProcessRunner.ProcessRunInput[] = [];
const runner = ProcessRunner.ProcessRunner.of({
run: (input) => {
calls.push(input);
const stdout =
input.args[0] === "-P"
? "10001\n"
: input.args[0] === "-eo"
? "10001 9000\n"
: input.args.includes("comm=")
? ""
: "/usr/bin/node\n";
return Effect.succeed({
stdout,
stderr: "",
code: ChildProcessSpawner.ExitCode(0),
timedOut: false,
stdoutTruncated: false,
stderrTruncated: false,
stdoutInvalidUtf8: false,
stderrInvalidUtf8: false,
});
},
});
const { manager } = yield* createManager(5, { subprocessPollIntervalMs: 20 }).pipe(
Effect.provideService(ProcessRunner.ProcessRunner, runner),
Effect.provide(withHostPlatform("darwin")),
);
yield* manager.open(openInput());
yield* waitFor(
Effect.sync(() => calls.length >= 4),
"1200 millis",
);
expect(calls.slice(0, 4).map(({ command }) => command)).toEqual([
"/usr/bin/pgrep",
"/bin/ps",
"/bin/ps",
"/bin/ps",
]);
yield* manager.close({ threadId: "thread-1" });
calls.length = 0;
const { manager: linuxManager } = yield* createManager(5, {
subprocessPollIntervalMs: 20,
}).pipe(
Effect.provideService(ProcessRunner.ProcessRunner, runner),
Effect.provide(withHostPlatform("linux")),
);
yield* linuxManager.open(openInput());
yield* waitFor(
Effect.sync(() => calls.length >= 4),
"1200 millis",
);
expect(calls.slice(0, 4).map(({ command }) => command)).toEqual(["pgrep", "ps", "ps", "ps"]);
}),
);
it.effect("caps persisted history to configured line limit", () =>
Effect.gen(function* () {
const { manager, ptyAdapter } = yield* createManager(3);
+7 -4
View File
@@ -703,9 +703,12 @@ const posixInspectSubprocess = Effect.fn("terminal.posixInspectSubprocess")(func
ProcessRunner.ProcessRunner
> {
const processRunner = yield* ProcessRunner.ProcessRunner;
// Absolute paths avoid libuv's per-PATH-entry posix_spawn search on macOS.
const pgrepCommand = platform === "darwin" ? "/usr/bin/pgrep" : "pgrep";
const psCommand = platform === "darwin" ? "/bin/ps" : "ps";
const runPgrep = processRunner
.run({
command: "pgrep",
command: pgrepCommand,
args: ["-P", String(terminalPid)],
timeout: "1 second",
maxOutputBytes: 32_768,
@@ -725,7 +728,7 @@ const posixInspectSubprocess = Effect.fn("terminal.posixInspectSubprocess")(func
const runPs = processRunner
.run({
command: "ps",
command: psCommand,
args: ["-eo", "pid=,ppid="],
timeout: "1 second",
maxOutputBytes: 262_144,
@@ -776,7 +779,7 @@ const posixInspectSubprocess = Effect.fn("terminal.posixInspectSubprocess")(func
}
const runComm = processRunner.run({
command: "ps",
command: psCommand,
args: ["-p", String(childPid), "-o", "comm="],
timeout: "1 second",
maxOutputBytes: 8_192,
@@ -792,7 +795,7 @@ const posixInspectSubprocess = Effect.fn("terminal.posixInspectSubprocess")(func
if (!rawComm || rawComm.length === 0) {
const runArgs = processRunner.run({
command: "ps",
command: psCommand,
args: ["-p", String(childPid), "-o", "args="],
timeout: "1 second",
maxOutputBytes: 16_384,