Skip to content

fix(terminal): restore native coding CLI starts on Bun - #140876

Merged
steipete merged 3 commits into
mainfrom
codex/native-cli-start-repair
Sep 7, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/native-cli-start-repair

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users starting Codex or Claude Code from New session could receive “Could not attach terminal session” before seeing the CLI's startup output. On Linux and macOS Bun Gateways, the native PTY stream could also close prematurely. The launch form exposed additional Codex history stores as duplicate machine choices and required manual refresh.

Why This Change Was Made

The terminal now initializes and subscribes before requesting a native start, preserving early output, exit details, and cancelled drafts. Bun Gateways use a Node PTY helper with ordered commands, backpressured output, and owned-process cleanup. New Codex starts use one primary native profile per machine; existing-session discovery and resume keep their original homes.

Maintainer compatibility decision: the documented Node prerequisite and primary-only fresh-start policy are intentional parts of this repair. The existing Linux Bun host used for proof already has Node available. Existing local-home discovery and resume retain their original implementation and boundary coverage; no stored-data schema or migration changes are introduced.

User Impact

Native CLI starts open a working terminal or show an actionable failure while retaining the draft. A single destination needs no selector, availability refreshes automatically, and a disconnected selected machine remains visibly unavailable. The working folder controls trusted project settings without switching native accounts. Bun terminals require Node on the Gateway's PATH.

Evidence

  • Original-source regression tests fail on lost startup output for both providers; the repaired UI lifecycle suites pass 125 tests, including cancellation during terminal initialization and reconnect/resume behavior.
  • Codex catalog boundary: 13 tests passed. Browser checks cover all 31 catalog/workspace cases plus two terminal-open siblings, including vanished destinations, node-only initialization, and native starts through button and Enter.
  • PTY owner checks: 20 passed with five Windows-only skips. Matching Linux Bun 1.4.2 proof covers Unicode input, resize ordering, terminal environment, lossless 2 MiB pause/resume, descendant cleanup, and native Codex execution.
  • Live Chrome against isolated Node and Bun Gateways: native Codex 0.153.4 and Claude Code 2.1.263 each returned exact success markers using operator-authorized provider keys. Both terminal tabs reattached after a Bun Gateway page reload, and both sessions appeared in their native catalogs.
  • Codex honored a trusted workspace's .codex/config.toml reasoning setting while retaining the selected native home.

Runtime build, selected changed-code checks (formatting, typechecks, lint, and repository guards), and independent Codex review passed. The final structural cleanup also passed 58 affected unit tests and the focused browser cases.

Before and after screenshots use only a synthetic agent, operator, and workspace.
Both published captures were inspected locally; the review bot's screenshot-fetch failure does not leave the visual changes uninspected.

Before After
Native CLI start with duplicate profile destinations and Refresh Native CLI start with one destination and automatic availability updates

Prepare the terminal and subscribe before starting native Codex or Claude Code,
retaining early output and exits while preserving rejected or cancelled drafts.
Keep tab setup separate from session lifecycle and RPC ownership.

Use a Node-owned PTY helper on Bun to preserve ordered input and resize commands,
backpressure, and descendant cleanup. Show one primary native launch destination
per machine, update availability automatically, and retain original source homes
for existing-session resumes.

Verified native model replies on isolated Node and Bun Gateways, terminal
reconnect, project configuration layering, focused UI/catalog tests, and Linux
Bun PTY input, output, backpressure, and cleanup behavior.
Keep native-start regressions in a focused suite with shared attachment fixtures.
Centralize the repeated current-repository refresh guard in its existing owner.
Preserve startup, destination, and repository-state behavior within file limits.
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui extensions: codex size: XL maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 05:36
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 2:05 AM ET / 06:05 UTC.

ClawSweeper review

What this changes

The PR prepares terminals before native CLI launch, delegates Unix Bun PTY handling to Node, preserves startup output and cancellation, and simplifies launch destinations.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful repair absent from inspected main and release source. No blocking introduced defect was found. The updated body explicitly resolves the previous review’s compatibility-policy question.

Priority: P1
Reviewed head: 768565b6692b9e80ea1b7b84e80c285f78a5045f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful runtime observations, regression coverage, and explicitly accepted compatibility tradeoffs.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured maintainer observations connect the changed terminal lifecycle and Node PTY owner to real Node/Bun Gateway launches, native model replies, reload recovery, and PTY cleanup. Screenshot fetch failure limits independent visual inspection but does not invalidate the reported runtime evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured maintainer observations connect the changed terminal lifecycle and Node PTY owner to real Node/Bun Gateway launches, native model replies, reload recovery, and PTY cleanup. Screenshot fetch failure limits independent visual inspection but does not invalidate the reported runtime evidence.
Evidence reviewed 9 items Pinned introduction and review continuity: Inspected merge-base 55fc54c through the pinned head. Compared with the previously reviewed head, the only new change removes an obsolete assertion-baseline entry; no previous code findings were recorded. The stale test merge was not used to infer removals from main.
Terminal startup lifecycle: The session controller initializes the emulator before requesting a catalog start, rechecks cancellation, and closes a returned session when ownership expires. TerminalConnection subscribes before issuing the RPC and replays early data and exit events. Focused tests exercise both providers, rejected starts, and cancellation during initialization; tests were inspected, not executed.
Bun PTY boundary: Unix Bun delegates to a Node helper using ordered IPC controls and backpressured stdout. Completion joins helper exit, IPC disconnection, and output EOF. The worker is included through the existing runtime-process build-entry registry.
Findings None None.
Security None None.

How this fits together

The Control UI starts native coding CLIs through Gateway session catalogs and displays their process output in terminal tabs. The shared PTY layer also serves node-host terminals.

flowchart TD
  A[Native CLI launch form] --> B[Initialize terminal and subscribe]
  B --> C[Gateway catalog launch]
  C --> D[Selected local or paired machine]
  D --> E{Unix Bun runtime}
  E -->|Yes| F[Node PTY helper]
  E -->|No| G[Direct PTY]
  F --> H[Terminal output and exit status]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The accepted compatibility tradeoff means Unix Bun installations without Node on PATH cannot start terminals, and secondary Codex homes no longer support fresh starts. Missing-Node recovery was not demonstrated; the reported existing Bun proof host already had Node.
Agent review details

Security

None.

PR surface

Source +579, Tests +493, Docs +22, Other -1. Total +1093 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 21 782 203 +579
Tests 10 766 273 +493
Docs 3 26 4 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 35 1574 481 +1093

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Retain the accepted launch contract (recommended)
    Proceed with the explicitly accepted Node prerequisite and primary-only fresh starts while preserving secondary-home resume behavior.

Technical review

Best possible solution:

Keep the unified terminal lifecycle and documented Node prerequisite, with original-profile discovery and resume preserved under the maintainer’s accepted launch policy.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main requests native launch before terminal subscription, allowing early output and exit to precede attachment. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Moving launch into the existing terminal lifecycle addresses the ordering defect at its owner, and Node isolation addresses Bun PTY handling without changing provider execution contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 64887802d73b.

Labels

Label justifications:

  • P1: The repair restores a broken native coding CLI workflow and prevents startup output from disappearing.
  • merge-risk: 🚨 compatibility: Unix Bun terminals gain a Node prerequisite and fresh Codex starts reject secondary homes, both explicitly accepted in the PR body.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured maintainer observations connect the changed terminal lifecycle and Node PTY owner to real Node/Bun Gateway launches, native model replies, reload recovery, and PTY cleanup. Screenshot fetch failure limits independent visual inspection but does not invalidate the reported runtime evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured maintainer observations connect the changed terminal lifecycle and Node PTY owner to real Node/Bun Gateway launches, native model replies, reload recovery, and PTY cleanup. Screenshot fetch failure limits independent visual inspection but does not invalidate the reported runtime evidence.

Evidence

What I checked:

  • Pinned introduction and review continuity: Inspected merge-base 55fc54c through the pinned head. Compared with the previously reviewed head, the only new change removes an obsolete assertion-baseline entry; no previous code findings were recorded. The stale test merge was not used to infer removals from main. (config/assertion-safety-baseline.txt:3824, 768565b6692b)
  • Terminal startup lifecycle: The session controller initializes the emulator before requesting a catalog start, rechecks cancellation, and closes a returned session when ownership expires. TerminalConnection subscribes before issuing the RPC and replays early data and exit events. Focused tests exercise both providers, rejected starts, and cancellation during initialization; tests were inspected, not executed. (ui/src/components/terminal/terminal-panel-session-controller.ts:441, 768565b6692b)
  • Bun PTY boundary: Unix Bun delegates to a Node helper using ordered IPC controls and backpressured stdout. Completion joins helper exit, IPC disconnection, and output EOF. The worker is included through the existing runtime-process build-entry registry. (src/process/terminal-pty-node.ts:15, 768565b6692b)
  • Compatibility disposition and resume preservation: The captured PR body explicitly accepts the Node prerequisite and primary-only fresh-start policy. Source restricts startTerminalSession while openTerminal still resolves the original source home; session-catalog-terminal.ts has no introduced changes. This supports accepting the previous secondary-home upgrade suggestion as non-blocking rather than requiring another review cycle. (extensions/codex/src/session-catalog.ts:335, 768565b6692b)
  • Captured behavior evidence: The supplied body, captured under sourceRevision fd78d35e7ba368f6ef9557e42046518afe85ca16228947615500e2fb89a81567, reports real Chrome launches of Codex and Claude Code against isolated Node and Bun Gateways, successful model replies, reload reattachment, catalog discovery, and Linux Bun PTY input, resize, backpressure, and descendant cleanup. It also records inspection of synthetic before/after screenshots. Attachment fetches failed in this reviewer environment; those images were not independently inspected here. (768565b6692b)
  • Still necessary on main and latest release: Inspected main retains direct node-pty spawning under Bun and issues native-start requests before opening the terminal panel. The supplied latest release, v2026.9.2 at 3928bad, also retains the direct PTY path. No verified merged replacement was supplied or established. (src/process/terminal-pty.ts:83, 64887802d73b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-07T05:42:48.284Z sha 701d000 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 7, 2026
@steipete
steipete merged commit b420450 into main Sep 7, 2026
190 checks passed
@steipete
steipete deleted the codex/native-cli-start-repair branch September 7, 2026 06:18
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
* fix(terminal): restore native coding CLI starts on Bun

Prepare the terminal and subscribe before starting native Codex or Claude Code,
retaining early output and exits while preserving rejected or cancelled drafts.
Keep tab setup separate from session lifecycle and RPC ownership.

Use a Node-owned PTY helper on Bun to preserve ordered input and resize commands,
backpressure, and descendant cleanup. Show one primary native launch destination
per machine, update availability automatically, and retain original source homes
for existing-session resumes.

Verified native model replies on isolated Node and Bun Gateways, terminal
reconnect, project configuration layering, focused UI/catalog tests, and Linux
Bun PTY input, output, backpressure, and cleanup behavior.

* refactor(ui): isolate native terminal draft tests

Keep native-start regressions in a focused suite with shared attachment fixtures.
Centralize the repeated current-repository refresh guard in its existing owner.
Preserve startup, destination, and repository-state behavior within file limits.

* chore: shrink terminal assertion baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant