Skip to content

One JSON-lines process helper for the provider adapters (#1447 pass D) - #1451

Merged
currentbits merged 9 commits into
mainfrom
coder/refactor-d-shared-provider-process-helpe-ad9eb4
Oct 4, 2026
Merged

currentbits merged 9 commits into
mainfrom
coder/refactor-d-shared-provider-process-helpe-ad9eb4

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Pass D of #1447. Six provider adapters each carried their own copy of the same child-process plumbing: spawn the CLI, split stdout into lines, parse each line as JSON defensively, keep a stderr tail, run a one-shot finish that flushes the last partial line and clears the SIGKILL timer, then call onExit. That now lives in runJsonLines in electron/agent.js.

Changes

  • runJsonLines added to electron/agent.js. cursor, muse, opencode, codex, claude and kimi run on it. Each adapter maps the shared { code, stderr, fullStdout, gotJson } to its own onExit payload.
  • New electron/overlayHomes.js: the four near-identical reclaim*Homes functions (cursor, grok, kimi, muse) share one implementation. Grok's session copy-back is kept as a hook.
  • ask.js and commitmsg.js share the muse stdout text extractor.
  • Removed codex.js's unused isAgentMessageEvent export.
  • New electron/test/json-lines-child.test.js covers the helper: partial last line, non-JSON lines, finish only once, kill escalation. which-platform.test.js points its cross-spawn/detach guards at the helper.

Behaviour checked against main: each adapter still keeps the 64 KB stderr tail. fullStdout is only collected where it was before (keepStdout: true for cursor, muse, opencode and kimi). Kill escalation via killTree/SIGKILL_AFTER_MS is unchanged. Interactive Claude still gets a piped stdin, and codex exec still ignores stdin.

Diff: 14 files, +545 / −1,194.

Verification: full electron suite in a CI-like env 4109/4109; npm run typecheck clean.

🤖 Generated with Claude Code

Willem and others added 9 commits October 4, 2026 19:34
…o it

One spawn + NDJSON line buffer + finish guard + SIGKILL escalation for the
stream-json adapters, instead of a copy per provider. Cursor keeps its exact
onExit payload ({ code, stderr, fullStdout, gotJson }). Also moves the
runCursor JSDoc back above runCursor (it had drifted onto linkOrSkip).

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same onExit payload ({ code, stderr, fullStdout, gotJson }), kill timing and
stderr tail as the removed copy.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same onExit payload ({ code, stderr, fullStdout, gotJson }), kill timing and
stderr tail as the removed copy.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ageEvent

Codex keeps its narrower onExit payload ({ code, stderr }) and does not
buffer fullStdout. isAgentMessageEvent had no callers in src/, electron/ or
test/.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The result-event stdin close moves into an onEvent wrapper; writeLine still
refuses once the process has finished (isFinished). onExit keeps
{ code, stderr, gotResult } and no fullStdout is buffered, which matters for
keepAlive processes that outlive many turns.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kimi's extras stay in kimi.js: the effort-flip restore is prepended to the
stdout/stderr data listeners (so it still runs before parsing) and runs again
on exit; the stderr thinking parser is a second stderr listener and its last
partial line is flushed before onExit, as before.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mi/muse

isLive*Thread, rmWithoutFollowing and reclaim*Homes were four identical
copies (plus isLiveOverlayThread in remote-overlay.js). They now live in
electron/overlayHomes.js; grok's session copy-back runs as a beforeRemove
hook inside the same try, so a failing copy still skips that overlay.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ask.extractMuseText and commitmsg.extractMuseMessage were byte-identical;
both now call muse.extractStdoutText. The codex extractors stay separate
(commitmsg filters by item/msg type, ask takes any item text). The argv
builders stay separate too: they differ only in claude --max-turns 1 today,
and sharing them would let ask-mode flag changes leak into commit-message
generation.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ines

The JSON-lines adapters no longer spawn themselves; agent.js does, and it
stays under the cross-spawn and agentSpawnOptions checks. The adapters are
now asserted to go through runJsonLines with no child_process spawn or
detached: true of their own. Drops kimi's orphaned cross-spawn comment.

Refs #1447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 6763da6 into main Oct 4, 2026
6 checks passed
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