Skip to content

feat(terminals): kill process without discarding the session, and clear stopped sessions#119

Merged
antfu merged 7 commits into
mainfrom
fancy-dodos-remain
Jul 22, 2026
Merged

feat(terminals): kill process without discarding the session, and clear stopped sessions#119
antfu merged 7 commits into
mainfrom
fancy-dodos-remain

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

What

The terminals UI only ever called the remove RPC, so "killing" a terminal always discarded it along with its scrollback. There was no way to stop a process yet keep its output, nor to tidy up sessions that had already exited.

This wires up the two missing capabilities:

  • Kill process (keep the session). The toolbar now branches on status: a running session shows a Kill process action that calls the existing terminate RPC — the process stops but the session and its scrollback stay in the list, marked stopped. Restart remains available.
  • Remove stopped sessions. A stopped session shows a Remove action (remove). A new nav-level Clear exited button sweeps away every stopped owned session at once, backed by a new devframes:plugin:terminals:clear-exited RPC and TerminalManager.clearExited().

Hub-aggregated (external, read-only) sessions are excluded from all these controls, as before.

Notes

  • remove() was refactored to share a private disposeSession() teardown helper with clearExited(), which publishes once for the whole sweep.
  • Added tests: kills a running process but keeps the session as stopped and clears stopped sessions, leaving running ones untouched.
  • Verified: vitest (17 passed), tsc --noEmit, eslint, and the full plugin build (tsdown + client + SPA) all clean.

This PR was created with the help of an agent.

…ar stopped sessions

The UI only ever called the remove RPC, so killing a terminal always discarded it along with its scrollback. Wire up the existing terminate RPC (stop the process, keep the session) and distinguish it from remove in the toolbar: running sessions get a Kill action, stopped ones get Remove. Add a clear-exited RPC (TerminalManager.clearExited) plus a nav-level Clear exited sweep to drop every stopped owned session at once.
@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 1824cd4
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a60391fcec82000088665f0
😎 Deploy Preview https://deploy-preview-119--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.

antfubot and others added 6 commits July 22, 2026 01:04
Killing a process (terminate) or removing a still-running session now opens a confirmation modal, since a live process is being terminated. This applies to both interactive and readonly sessions. Already-stopped sessions are removed immediately without a prompt. The modal is dismissible via backdrop click or Escape and confirmable via Enter.
Readonly sessions aggregated from other devframes via the hub stream their raw output straight to the client, so bare LF line endings never get the server-side CRLF normalization that own pipe sessions receive — xterm then left the cursor column untouched on each newline and rendered a staircase. Enable xterm's convertEol for readonly sessions so a lone LF is treated as CRLF (a no-op when CRLF already arrived); interactive PTY sessions keep it off so full-screen TUIs retain exact cursor control.
Aggregated (read-only) sessions surfaced from other devframes via the hub were rendered without any controls. They can now be force-killed while running and removed once stopped, routed through new hub built-in RPCs (hub:terminals:terminate/restart/remove) — the same seam TerminalView already uses for write/resize. The plugin UI shows Kill/Remove for external sessions too, not just its own.

startChildProcess (and startPtySession) now accept restartable on the session descriptor. When false, the terminals UI hides the restart control and hub:terminals:restart rejects the call (DF8205) — for sessions whose lifecycle is owned elsewhere. code-server sets restartable:false so restarting the editor goes through its own start flow (fresh port + secret) rather than re-spawning the raw process.
# Conflicts:
#	plugins/terminals/src/client/App.svelte
#	plugins/terminals/src/client/design.ts
@antfu
antfu merged commit 32ef7f2 into main Jul 22, 2026
11 of 12 checks passed
@antfu
antfu deleted the fancy-dodos-remain branch July 22, 2026 03:29
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