Skip to content

fix(progress): block keyboard input while a Rust spinner is visible - #3373

Draft
jong-kyung wants to merge 2 commits into
voidzero-dev:mainfrom
jong-kyung:fix/spinner-input-block
Draft

jong-kyung wants to merge 2 commits into
voidzero-dev:mainfrom
jong-kyung:fix/spinner-input-block

Conversation

@jong-kyung

Copy link
Copy Markdown
Collaborator

Summary

Pressing Enter during a Rust spinner, such as Installing global packages in vp install -g, pushed a copy of the spinner row down with each key press. The local CLI already avoids this because clack's block() suppresses input while its spinner runs, so this PR gives the Rust spinners the same behavior.

Closes #3359

Root cause

The terminal stays in its normal line-editing mode while the spinner is visible, so it echoes typed keys. Each echoed newline moves the cursor down, and indicatif then redraws the spinner on the new line.

Changes

While a new progress row is visible, vp_shared::progress now switches stdin to raw input and restores it when the row is cleared. This follows clack's block() with two differences:

  • ISIG stays on, so Ctrl+C and Ctrl+Z still signal the whole process group. Ctrl+C now ends the process with the usual signal status instead of exit code 0, and no thread needs to read stdin.
  • Pending input is discarded on release, so typed keys never reach the shell.

The terminal is restored on every exit path:

  • On Unix, SIGINT, SIGQUIT, and SIGTERM handlers restore the terminal and then re-raise the signal. The handlers are only installed when the signal still has its default disposition, so dispositions chosen by someone else are kept, such as Node's own handlers when this code runs inside the NAPI binding.
  • On Windows, a console control handler restores the console mode.
  • A panic hook restores the terminal before the abort in release builds.
  • A job running in the background leaves the terminal alone, because changing the terminal from the background would stop the process with SIGTTOU.

The global package spinners for vp install -g and vp outdated -g previously built their own indicatif bars, which bypassed the shared progress module. They now use a new Progress::counter, so the input block applies to them as well. The counter keeps the existing (n/total) display and now also shows the elapsed time, like the other Rust spinners. This is why two snapshots gained <duration>.

Add Progress::counter to vp_shared so global install and update share the
same progress row as other Rust spinners.
Typing during a Rust spinner echoed into the progress row, and each Enter
pushed a copy of the row down. Switch stdin to Node's raw mode while a new
row is visible, as clack's block() does, but keep ISIG so Ctrl+C, Ctrl+\,
and Ctrl+Z still signal the whole process group. Pending input is discarded
on release so it never reaches the shell.

SIGINT, SIGQUIT, SIGTERM, Ctrl+C on Windows, and panics restore the saved
terminal state before the process ends. A background job leaves the
terminal alone, because changing or flushing its controlling terminal
would stop it with SIGTTOU.

Closes voidzero-dev#3359
@jong-kyung jong-kyung self-assigned this Nov 6, 2026
@jong-kyung jong-kyung added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests labels Nov 6, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T16:53:32.899364Z a895ded Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a895deda3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +79 to +83
if !block(libc::STDIN_FILENO) {
return None;
}
BLOCKED.store(true, Ordering::SeqCst);
Some(Self { previous: install_handlers() })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Arm signal restoration before switching stdin to raw mode

On Unix, a SIGTERM arriving after block() changes termios but before install_handlers() registers its handler still takes the default termination path. Neither Drop nor the panic hook runs on that path, so the terminal is left with echo, canonical input, and carriage-return translation disabled. This is reproducible by signaling a PTY-backed process during guard acquisition. The signal test only raises signals after acquisition completes, so it misses this window. Arm restoration safely before modifying the terminal, or otherwise synchronize this transition with signal delivery.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressing enter during "Installing global packages" should be a no-op

1 participant