feat(hub): expose getResult() on startChildProcess() terminal sessions#90
Merged
Conversation
Add a getResult() accessor to DevframeChildProcessTerminalSession that
mirrors tinyexec's Result contract — a promise-like handle with live
pid/exitCode/killed getters that resolves to { stdout, stderr, exitCode }
once the process exits. stdout and stderr are now captured separately
(alongside the existing merged display stream) by listening on the raw
child process directly, rather than through tinyexec's own async
iterator/promise, which would otherwise starve each other reading the
same underlying streams.
This gives tinyexec/execa-based subprocess-runner APIs (e.g. Nuxt
DevTools' startSubprocess().getResult()) a compatible seam to adopt
ctx.terminals.startChildProcess() directly.
Co-authored-by: opencode <noreply@opencode.ai>
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Nuxt DevTools is planning to retire its own
@xterm-based terminal system in favor of the hub'sctx.terminals(see itsplans/vite-devtools-integration/02-terminals-reuse.md/00-compat-foundation.md). Its currentstartSubprocess()returns{ getProcess (deprecated), getResult, terminate, restart, clear }, wheregetResult()is atinyexecResult— awaitable to{ stdout, stderr, exitCode }, with livepid/exitCode/killedin the meantime.ctx.terminals.startChildProcess()had no equivalent, so there was no drop-in seam for that migration.What changed
DevframeChildProcessTerminalSessiongains agetResult()accessor returning a newDevframeChildProcessResult— a promise-like handle (livepid/exitCode/killedgetters +kill()) that resolves to{ stdout, stderr, exitCode }once the process exits. Mirrorstinyexec'sResultshape closely enough that atinyexec/execa-based subprocess-runner API can adoptstartChildProcess()with little translation.startChildProcess()'s internals now capture stdout/stderr separately, by listening on the raw child process directly instead of consumingtinyexec's own async-iterator/promise. Those both read from the same underlying streams as the merged terminal-display stream, and would otherwise starve each other — this was a real correctness gap, not just a missing feature.getResult()tracks the current run and points at a fresh handle afterrestart(); it still settles with the real exit code if the session isterminate()d mid-flight.Testing
packages/hub/src/node/__tests__/host-terminals.test.tscovering: separate stdout/stderr + exit code capture, live accessors before/after exit, a fresh handle afterrestart(), and settlement afterterminate().pnpm lint && pnpm typecheck && pnpm test && pnpm buildall pass repo-wide (652 tests).@devframes/hubtsnapi export snapshots for the two new public types, and added a short note todocs/guide/hub.md/docs/plugins/terminals.md.Created with the help of an agent.