The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { it } from "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Fiber from "effect/Fiber"; |
| 4 | import * as HostProcess from "@t3tools/shared/HostProcess"; |
| 5 | |
| 6 | import { awaitLauncherLoss } from "./launcherWatch.ts"; |
| 7 | |
| 8 | const launcherPid = 4100; |
| 9 | // Orphans are adopted by init or a subreaper, so the new parent is not always 1. |
| 10 | const subreaperPid = 1800; |
| 11 | |
| 12 | const watch = (getParentPid: () => number, platform: NodeJS.Platform, startPid = launcherPid) => |
| 13 | awaitLauncherLoss({ launcherPid: startPid, getParentPid }).pipe( |
| 14 | Effect.provideService(HostProcess.Platform, platform), |
| 15 | ); |
| 16 | |
| 17 | it.effect("notices a launcher that was already gone when the watch began", () => |
| 18 | Effect.gen(function* () { |
| 19 | const fiber = yield* Effect.forkChild(watch(() => subreaperPid, "linux")); |
| 20 | yield* Effect.yieldNow; |
| 21 | yield* Fiber.join(fiber); |
| 22 | }), |
| 23 | ); |