Skip to content

fix(hub): bound terminal scrollback buffer and reject restart after terminate#79

Merged
antfu merged 1 commit into
mainfrom
yummy-books-find
Jul 9, 2026
Merged

fix(hub): bound terminal scrollback buffer and reject restart after terminate#79
antfu merged 1 commit into
mainfrom
yummy-books-find

Conversation

@antfubot

@antfubot antfubot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements plan 008: two lifecycle fixes in DevframeTerminalsHost.

  • Bounded scrollback buffer: session.buffer grew without limit for the
    lifetime 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.
  • No-op restart after terminate: restart() on both the child-process and
    PTY 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 process
    itself was left running unmanaged. Both restart() closures now bail when
    the stream is already closed.

Changes

  • packages/hub/src/node/host-terminals.ts — add TERMINAL_BUFFER_LIMIT,
    trim session.buffer after each push, guard both restart() closures on
    streamClosed.
  • packages/hub/src/node/__tests__/host-terminals.test.ts — cover the bounded
    buffer (newest retained, oldest dropped) and the terminated-session restart
    no-op.
  • plans/008-cap-terminal-buffer.md removed (implemented); plans/README.md
    status row updated to DONE.

Verification

  • pnpm exec vitest run packages/hub/src/node/__tests__/host-terminals.test.ts — 8/8 pass
  • pnpm --filter @devframes/hub typecheck — clean
  • pnpm lint — clean

This PR was created with the help of an agent.

…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.
@netlify

netlify Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 5a50817
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a4f250720f8f00007a1f278
😎 Deploy Preview https://deploy-preview-79--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu antfu merged commit d090001 into main Jul 9, 2026
6 of 12 checks passed
@antfu antfu deleted the yummy-books-find branch July 9, 2026 08:22
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.

2 participants