Skip to content

refactor(pty-effect): delegate spawnDaemon to @myobie/pty#643

Merged
schickling-assistant merged 1 commit intomainfrom
schickling-assistant/2026-05-06-pty-effect-delegate-spawn
May 8, 2026
Merged

refactor(pty-effect): delegate spawnDaemon to @myobie/pty#643
schickling-assistant merged 1 commit intomainfrom
schickling-assistant/2026-05-06-pty-effect-delegate-spawn

Conversation

@schickling-assistant
Copy link
Copy Markdown
Collaborator

Problem

@overeng/pty-effect/client's spawnDaemon reimplements the entire daemon spawn pipeline (server module resolution via require.resolve('@myobie/pty/server'), detached child launch with node:child_process, socket wait, early-exit detection, cleanup-on-timeout) to work around the lack of a Bun-on-Node escape hatch in upstream @myobie/pty.spawnDaemon.

The in-house copy then drifts from upstream and locks consumers out of upstream improvements — most importantly, the bundle-safe spawn work in myobie/pty#38 (embedded server source fallback for bundled callers) only kicks in when consumers actually call upstream spawnDaemon.

Change

Replace the in-house spawnDaemonViaNode / spawnDaemonCompat pair with a thin wrapper that calls upstream @myobie/pty.spawnDaemon directly. The Bun-on-Node case is now handled by upstream's launcher option (added in 0.9.0), set to NODE_BIN ?? "node" when running under Bun.

  • Public API unchanged: PtyClient service shape, PtyDaemonSpec schema, and PtyError reasons are identical.
  • Env injection (PtyDaemonSpec.env) still goes through withEnvOverrides — that one predates upstream's extraEnv and operates without requiring isolateEnv, so it stays as the wrapper-side mechanism.
  • Drops node:child_process, node:module / createRequire, and upstreamWaitForSocket imports.
  • Unit test that asserted spawn(...) arguments rewritten to assert the args passed to upstream spawnDaemon (including launcher).

Field mapping (PtyDaemonSpecSpawnDaemonOptions)

All upstream-supported fields map 1:1 in buildSpawnOpts. No PtyDaemonSpec field is dropped:

  • name, command, args, displayCommand, cwd, ephemeral, tags → upstream equivalents
  • size.rows / size.colsrows / cols
  • env → wrapper-side withEnvOverrides (mutates process.env around the call, restores after)
  • New: launcher: { command: NODE_BIN ?? "node" } is set when process.versions.bun !== undefined

Upstream SpawnDaemonOptions exposes displayName, isolateEnv, extraEnv, and launcher. None are surfaced through PtyDaemonSpec today; this PR doesn't add them. The wrapper-side env mechanism is preserved so behavior for the existing env field is byte-identical.

Test results

  • pnpm exec vitest run (pty-effect package): all 28 tests pass, including the 4 unit tests for the spawn wrapper.
  • pnpm exec tsc --noEmit -p tsconfig.json: clean.
  • oxlint: clean.

Related

Posted on behalf of @schickling
field value
agent_name 🌸 cl2-glade
agent_session_id 246b956a-0258-4209-8265-143eb77329b1
agent_tool Claude Code
agent_tool_version 2.1.121
agent_runtime Claude Code 2.1.121
agent_model unknown
worktree effect-utils/main
machine dev3
tooling_profile dotfiles@unknown-dirty

`@overeng/pty-effect/client`'s `spawnDaemon` previously reimplemented
the daemon spawn pipeline (server module resolution, child process
launch, socket wait, early-exit detection) to work around the lack of
a Bun-on-Node escape hatch in upstream `@myobie/pty.spawnDaemon`.

Upstream now ships a `launcher` option that covers exactly that case,
so the in-house path is obsolete. Replace it with a thin wrapper that
calls upstream `spawnDaemon` and sets `launcher` to `NODE_BIN ?? "node"`
when running under Bun. Public API and `PtyDaemonSpec` schema unchanged.

Consumers automatically inherit upstream improvements such as
bundle-safe spawn (myobie/pty#38) without any local workaround.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Storybook Previews

Package Latest URL Last Deploy (Europe/Berlin)
react-inspector https://react-inspector-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
effect-react https://effect-react-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
effect-schema-form-aria https://effect-schema-form-aria-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
genie https://genie-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
notion-react https://notion-react-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
tui-react https://tui-react-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
tui-stories https://tui-stories-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
megarepo https://megarepo-pr-643--overeng-utils.netlify.app 2026-05-06 14:56 CEST
notion-cli https://notion-cli-pr-643--overeng-utils.netlify.app 2026-05-06 14:57 CEST
Per-Commit Deploy History

Commit b5edbcd · 2026-05-06 14:58 CEST

Package URL
react-inspector https://69fb3a655b65f01d4ed6db49--overeng-utils.netlify.app
Alias: https://react-inspector-pr-643--overeng-utils.netlify.app
effect-react https://69fb3a66370b134b8de2afd5--overeng-utils.netlify.app
Alias: https://effect-react-pr-643--overeng-utils.netlify.app
effect-schema-form-aria https://69fb3a660972031ed238ba78--overeng-utils.netlify.app
Alias: https://effect-schema-form-aria-pr-643--overeng-utils.netlify.app
genie https://69fb3a6c1032845a667b012d--overeng-utils.netlify.app
Alias: https://genie-pr-643--overeng-utils.netlify.app
notion-react https://69fb3a6d2a349a586eb9d520--overeng-utils.netlify.app
Alias: https://notion-react-pr-643--overeng-utils.netlify.app
tui-react https://69fb3a755964d5590d5c2890--overeng-utils.netlify.app
Alias: https://tui-react-pr-643--overeng-utils.netlify.app
tui-stories https://69fb3a75097203225738bb41--overeng-utils.netlify.app
Alias: https://tui-stories-pr-643--overeng-utils.netlify.app
megarepo https://69fb3a7eb6bb2c59a697e06b--overeng-utils.netlify.app
Alias: https://megarepo-pr-643--overeng-utils.netlify.app
notion-cli https://69fb3a85d9c5405a0ac8e8b1--overeng-utils.netlify.app
Alias: https://notion-cli-pr-643--overeng-utils.netlify.app

@schickling-assistant schickling-assistant marked this pull request as ready for review May 8, 2026 01:27
@schickling-assistant schickling-assistant merged commit 2397155 into main May 8, 2026
14 of 15 checks passed
@schickling-assistant schickling-assistant deleted the schickling-assistant/2026-05-06-pty-effect-delegate-spawn branch May 8, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant