Skip to content

feat(hub): expose PTY session results - #321

Merged
antfu merged 4 commits into
devframes:mainfrom
dvcolomban:codex/pty-session-result
Sep 1, 2026
Merged

feat(hub): expose PTY session results#321
antfu merged 4 commits into
devframes:mainfrom
dvcolomban:codex/pty-session-result

Conversation

@dvcolomban

@dvcolomban dvcolomban commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Why

PTY sessions provide interactive input and output, but callers cannot await a run or inspect its outcome. Consumers running finite commands need the merged terminal output, exit code, signal, and live process state without starting a separate child process.

A restarted session also needs a distinct result for each run so the previous result can settle independently while the session continues with the replacement process.

What

  • Add DevframePtyOutput and the promise-like DevframePtyResult.
  • Expose getResult() on PTY terminal sessions with merged output and live pid, exitCode, and killed getters.
  • Create a new result for each successful restart while preserving settlement and output for previous runs.
  • Report restart spawn failures through DF8203, retain the previous result, and keep the session stream available for retry.
  • Use killed as the portable termination indicator when deriving result and session state.
  • Update the terminal documentation and public API snapshots.

Verification

  • PTY tests cover natural and non-zero exits, termination, restart isolation, restart spawn failure, and retry.
  • CI passes on Ubuntu and Windows with Node 22, 24, and 26.
  • Lint, knip, typecheck, test, and build checks pass.

Copilot AI lite review requested due to automatic review settings August 31, 2026 10:02
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@dvcolomban is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a public, promise-like result handle for PTY terminal sessions in @devframes/hub, allowing consumers to await completion and retrieve merged output plus process outcome details (exit code / signal, pid, killed state), including restart isolation.

Changes:

  • Introduces DevframePtyOutput and DevframePtyResult, and exposes getResult() on DevframePtyTerminalSession.
  • Implements result capture/settlement per PTY run (including restart isolation) in the hub node host, and adds coverage for natural exits, non-zero exits, termination, and restart isolation.
  • Updates terminals documentation and API/type snapshots to reflect the new PTY result contract.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/snapshots/tsnapi/@devframes/hub/types.snapshot.d.ts Exposes the new PTY result types in the generated types snapshot export list.
tests/snapshots/tsnapi/@devframes/hub/index.snapshot.d.ts Updates the public .d.ts snapshot to include DevframePtyOutput, DevframePtyResult, and getResult().
packages/hub/src/types/terminals.ts Defines the new PTY output/result contracts and adds getResult() to the PTY session interface.
packages/hub/src/node/host-terminals.ts Captures merged PTY output per run and wires getResult() into PTY sessions (plus termination/restart interaction).
packages/hub/src/node/tests/host-terminals.test.ts Adds tests validating PTY result resolution, non-zero exits, termination semantics, and restart/run isolation.
docs/content/5.add-ons/1.devframes/6.terminals.md Documents getResult() behavior for PTY sessions alongside child-process sessions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/hub/src/node/host-terminals.ts Outdated
@dvcolomban
dvcolomban marked this pull request as draft August 31, 2026 13:11
@dvcolomban
dvcolomban marked this pull request as ready for review August 31, 2026 13:45
Copilot AI review requested due to automatic review settings August 31, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Comment thread packages/hub/src/node/host-terminals.ts
Copilot AI review requested due to automatic review settings August 31, 2026 14:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Comment thread packages/hub/src/node/host-terminals.ts
Copilot AI review requested due to automatic review settings August 31, 2026 15:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.

@antfu
antfu merged commit 3c2e74a into devframes:main Sep 1, 2026
9 of 10 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.

3 participants