Skip to content

feat(devtools)!: reuse the built-in Terminals dock via ctx.terminals#1026

Open
antfubot wants to merge 1 commit into
nuxt:mainfrom
antfubot:feat/terminals-reuse-devframe
Open

feat(devtools)!: reuse the built-in Terminals dock via ctx.terminals#1026
antfubot wants to merge 1 commit into
nuxt:mainfrom
antfubot:feat/terminals-reuse-devframe

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Summary

Implements plan 02-terminals-reuse from the Vite DevTools integration series. Nuxt DevTools stops shipping its own @xterm terminal UI + RPC and instead surfaces terminal sessions through the devframe terminals host (ctx.terminals), so they render in Vite DevTools' built-in Terminals dock (which auto-hides when empty). The Nuxt "Terminals" tab is removed.

Existing modules keep working via a compat shim, and a new opt-in interactive PTY path is added.

What changed

Server bridge (server-rpc/terminals.ts, rewritten)

  • Bridges the devtools:terminal:* hooks onto ctx.terminals instead of maintaining its own Map + RPC:
    • register → a read-only DevframeTerminalSession carrying a ReadableStream (registered via ctx.terminals.register). Re-registration resets/clears in place, so startSubprocess().clear()/restart() still work.
    • writecontroller.enqueue(data); exit → close stream + update(status); remove → dispose + remove the session.
    • New devtools:terminal:spawn hook → ctx.terminals.startChildProcess (output-only) or ctx.terminals.startPtySession (interactive PTY, zigpty with graceful pipe fallback).
  • Terminals registered before the kit connects are buffered and replayed inside the devtools:ready callback.

Kit surface (@nuxt/devtools-kit)

  • Added SpawnTerminalOptions, the devtools:terminal:spawn hook, and a startDevToolsTerminal() helper (opt-in PTY).
  • Dropped getTerminals/getTerminalDetail/runTerminalAction + onTerminalData from the RPC types (kept onTerminalExit). TerminalState/TerminalInfo/TerminalAction and the devtools:terminal:* module-facing hooks are preserved.

Internal producers — module-install / analyze-build / npm-update already spawn via startChildProcess; they now broadcast onTerminalExit on process exit so their transient UI state (installing-modules, "Building…", update spinner) still clears. Exit-driven cleanup is not lost.

Client — deleted the terminals.vue tab, TerminalPage.vue, TerminalView.vue; removed useTerminals, useCurrentTerminalId, the onTerminalData handler, and all /modules/terminals navigation (replaced with a "follow the output in the Terminals dock" hint). Removed the @xterm/* deps from package.json, pnpm-workspace.yaml, and the client nuxt.config.ts bundling/optimizeDeps; refreshed the lockfile.

Docs — documented startDevToolsTerminal() and refreshed the "Terminals tab" references.

Notes / breaking changes

  • New major: the bespoke Nuxt terminals RPC (getTerminals/getTerminalDetail/runTerminalAction) and the @xterm UI are removed. Module-facing hooks (devtools:terminal:register/write/remove/exit) and startSubprocess() continue to work via the shim.
  • The startSubprocess/getProcess() deprecation codes (NDT_DEP_0004/0001) already shipped; this PR swaps the underlying implementation rather than adding new codes.

Verification

pnpm lint, pnpm typecheck, pnpm build, and pnpm test:unit all pass.

This PR was created with the help of an agent.

Retire Nuxt DevTools' bespoke @xterm terminal UI + RPC and surface terminal
sessions through the Vite DevTools terminals host (ctx.terminals), so they
render in the built-in Terminals dock.

Existing modules keep working: the devtools:terminal:* hooks are bridged onto
ctx.terminals as read-only registered sessions (module still owns the process
and streams output). A new opt-in interactive PTY path is added via a
devtools:terminal:spawn hook and the startDevToolsTerminal() helper.

Exit-driven cleanup for the internal module-install / analyze-build / npm-update
flows is preserved by broadcasting terminal exits from their startChildProcess
producers.

Created with the help of an agent.
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.

1 participant