fix(hub): bound terminal scrollback buffer and reject restart after terminate#79
Merged
Conversation
…erminate Caps the per-session terminal scrollback buffer at 1000 chunks (mirroring the streaming replay window) instead of growing unbounded for the lifetime of a long-running PTY/child-process session. Also makes both restart() closures no-op once the session's stream has been terminated, so restarting a terminated session no longer spawns an orphaned, unmanaged process.
✅ 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.
Summary
Implements plan 008: two lifecycle fixes in
DevframeTerminalsHost.session.buffergrew without limit for thelifetime of a terminal session (a long-running
pnpm dev,tail -f, etc.),linear in total output produced. It's now capped at
TERMINAL_BUFFER_LIMIT(1000 chunks, matching the streaming channel's existing replay window),
trimmed oldest-first on every push.
restart()on both the child-process andPTY terminal sessions used to re-spawn a process even after
terminate()had closed the session's stream — the new process's output was silently
dropped (the read loop short-circuits on
streamClosed) and the processitself was left running unmanaged. Both
restart()closures now bail whenthe stream is already closed.
Changes
packages/hub/src/node/host-terminals.ts— addTERMINAL_BUFFER_LIMIT,trim
session.bufferafter each push, guard bothrestart()closures onstreamClosed.packages/hub/src/node/__tests__/host-terminals.test.ts— cover the boundedbuffer (newest retained, oldest dropped) and the terminated-session restart
no-op.
plans/008-cap-terminal-buffer.mdremoved (implemented);plans/README.mdstatus row updated to DONE.
Verification
pnpm exec vitest run packages/hub/src/node/__tests__/host-terminals.test.ts— 8/8 passpnpm --filter @devframes/hub typecheck— cleanpnpm lint— cleanThis PR was created with the help of an agent.