`nuxt dev`: takeover prompt loses raw mode when terminal doesn't answer OSC 11

Open Beginner friendly
#1,685 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start with withUserAttention and host.withTerminal, then compare their stdin handling with attachKeys and whenStdinReleased() in src/boot.ts and the takeover prompt path. Reproduce in a terminal that does not answer OSC 11 and confirm the prompt retains raw mode after the timeout. Done means arrow keys move the selection and Enter submits it in that scenario.

Written by the indexing model from the issue text.

Description

Version: @nuxt/cli 4.0.3, Nuxt 4.6.4, Node 24.16, macOS

Repro
  1. Start nuxt dev in a project and leave it running.
  2. In a terminal that does not reply to OSC 11 (ESC ] 11 ; ? BEL), run nuxt dev again in the same project.
  3. The "A Nuxt dev server is already running here" select prompt appears. Press ↑/↓.

Expected: the selection moves.

Actual: ~250ms after the prompt renders, stdin drops out of raw mode. Arrow keys echo as ^[[A, and Enter arrives as \n (readline names it enter, not return), so the prompt can't be answered. Only Ctrl-C gets out.

Cause

bootDevUI (src/boot.ts) paints the panel and calls queryBackground before the dev command reaches takeOverServer. listen() in src/dev/tui/background.ts captures wasRaw = false, sets raw mode, then in finish() (on reply or on the 250ms timeout) runs if (!wasRaw) stdin.setRawMode(false). By then clack's select has taken raw mode, so the restore turns it off underneath the prompt. attachKeys already waits for whenStdinReleased(); the takeover prompt (via withUserAttention) does not.

Verified by sampling the pty's termios flags: ICANON and ECHO switch back on 0.27s after the prompt appears. With NUXT_TERM_THEME=dark (no query sent), raw mode holds.

Suggested fix

Have withUserAttention / host.withTerminal await whenStdinReleased() before running the prompt, the same way attachKeys does. Alternatively, finish() could skip the raw-mode restore if stdin's raw state changed while the query was pending.

Workaround

export NUXT_TERM_THEME=dark (or light).

Dominant language
TypeScript
Stars
402
Forks
125
Avg merge
2d 9h
Merged PRs (30d)
37

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nuxt/cli

All issues in nuxt/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.