Repository navigation
fix(core): exit 3 on Ctrl-C at any prompt after the cli-utilities 2 upgrade - #294
Open
Harshi-Shah-CS wants to merge 15 commits into
Open
Harshi-Shah-CS wants to merge 15 commits into
Harshi-Shah-CS wants to merge 15 commits into
Conversation
In raw mode Ctrl-C reaches inquirer 12 as a keypress, not a process SIGINT, and the prompt rejects with ExitPromptError. The prompt wrapper now turns that rejection into CancelledError (exit 3), as it does for a SIGINT. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
inquirer 12 runs search-list as a legacy prompt: on Ctrl-C it rejects with AbortPromptError and then raises a real SIGINT. The wrapper used to stop listening on that rejection, so the SIGINT found no listener. It now keeps listening, and the SIGINT cancels the prompt with CancelledError. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
cliux.inquire catches inquirer's ExitPromptError and calls process.exit(130) before a caller can see it. terminalUx asks the same inquirer instance (the one search-list is registered with) and lets the rejection through, so the Ctrl-C wrapper can map it to exit 3. It prints through cliux as before. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
LaunchCommand's ux is now cancelOnInterrupt(terminalUx) instead of cancelOnInterrupt(cliux), so inquirer's ExitPromptError reaches the wrapper and becomes CancelledError rather than cli-utilities' process.exit(130). Tests stub prompts at terminalUx.inquire (stubPrompts in test/support/terminal.ts) instead of cliux.inquire, and answerPrompts' CTRL_C now rejects with ExitPromptError, which is what a real Ctrl-C does, instead of emitting a SIGINT that no longer reaches an open prompt. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
… wraps terminalUx The prompt-funnel guard now expects LaunchCommand's ux to be built as cancelOnInterrupt(terminalUx), and flags two new ways around the wrapper: any use of promptLibrary outside search-list.ts and terminal-ux.ts, and any use of terminalUx other than that one funnel line. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The prompt guards simulated Ctrl-C by emitting SIGINT, which is how the cli-utilities 2 regression (CL-8790) stayed green: in raw mode Ctrl-C reaches inquirer as typed input, never as a signal. This test opens a real prompt (input, list, checkbox, confirm, search-list) through LaunchCommand's ux on a pty, types Ctrl-C, and expects exit 3. Against the old cancelOnInterrupt(cliux) funnel it fails with 130, and with 1 at search-list. The driver is a Python stdlib pty script, so it needs no native module. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
AGENTS.md's prompt-funnel guard row now says LaunchCommand's ux is cancelOnInterrupt(terminalUx), why it skips cliux.inquire, how Ctrl-C reaches an inquirer 12 prompt and a legacy search-list prompt, and which test types a real Ctrl-C on a pty. "Driving a prompt" now names the terminalUx.inquire spy, stubPrompts, and CTRL_C rejecting with ExitPromptError. Test names and comments that said "the inquirer cliux prompts with" now say terminalUx. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
On AbortPromptError the wrapper used to wait for the SIGINT inquirer raises next, so a legacy-prompt abort with no signal after it would hang with the event loop held. It now rejects with CancelledError and releases the loop straight away, and stays attached to SIGINT only to absorb that signal, then detaches. Found in review. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
press-ctrl-c.py now waits for the command to exit only until its deadline, then kills it and reports 125, and the test gives execFileSync a timeout, so a regression that leaves the CLI running after Ctrl-C fails the test instead of hanging the whole jest run. The matrix covers the password prompt again: askSecret uses it at six call sites and @inquirer/password carries its own @inquirer/core. The test file gets a per-file checksum in .talismanrc because the prompt type's name trips Talisman. Found in review. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…rs it answerPrompts' CTRL_C now rejects a search-list prompt with AbortPromptError and raises a SIGINT on the next tick, as inquirer 12 does for that legacy prompt, and keeps ExitPromptError for every other prompt. A new projects:get case presses Ctrl-C at the project picker and expects exit 3 with no SIGINT listener left once the signal is absorbed. The stubPrompts and ctrlC comments are dropped, per AGENTS.md. Found in review. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The prompt-funnel guard matched only the literal names, so
`import { terminalUx as tty }` or `import { promptLibrary as lib }` reached
the prompt library around the Ctrl-C wrapper unnoticed. It now resolves
aliases the way it already did for cliux. Found in review.
#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
AGENTS.md asks for no code comments on changes; the reason terminalUx skips cliux.inquire is in AGENTS.md's prompt-funnel guard row. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
#claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…e touched The pre-push scan reads each changed file whole, so the existing per-file checksums for launch-command, search-list and the integration tests that now stub prompts at terminalUx.inquire are refreshed in place. No new secrets: the flagged lines are the existing password/key test fixtures. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…l docs #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
Claude review
Fixed
Not changed
#claude_code# |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CL-8790: since the cli-utilities 2 upgrade (CL-8328), Ctrl-C at an interactive prompt exited 130 instead of 3 (cancelled).
What
cliux.inquirein cli-utilities 2 catches inquirer 12'sExitPromptErrorand callsprocess.exit(130)itself. In raw mode Ctrl-C reaches inquirer as typed input, not as a processSIGINT, so theSIGINTlistener incancelOnInterruptnever fired.LaunchCommand'suxis nowcancelOnInterrupt(terminalUx).terminalUx(src/core/terminal-ux.ts) prompts through the same inquirer instance cli-utilities uses (promptLibrary(), wheresearch-listis registered), so the rejection reaches the wrapper, which mapsExitPromptErrortoCancelledError.search-listprompt (organization and project pickers) exits 3 too. This case was not in the ticket. inquirer 12 runssearch-listas a legacy prompt: on Ctrl-C it rejects withAbortPromptErrorand then raises a realSIGINT. The wrapper used to stop listening on the rejection, so the command failed as a runtime error (exit 1), or theSIGINTkilled it. The wrapper now cancels on the rejection at once and stays attached only to absorb theSIGINTthat follows.cancelOnInterrupt(terminalUx)and flags any use ofpromptLibraryoutsidesearch-list.ts/terminal-ux.ts, and any use ofterminalUxother than the funnel line, following import aliases.terminalUx.inquire(newstubPromptsintest/support/terminal.ts) instead ofcliux.inquire.answerPrompts'CTRL_Cnow rejects withExitPromptError, as a real Ctrl-C does, instead of emitting aSIGINTthat no longer reaches an open prompt; at asearch-listprompt it rejects withAbortPromptErrorand raises theSIGINT, as inquirer does.Tests
test/integration/prompt-ctrl-c-on-a-terminal.test.ts(new) opens a real input, password, list, checkbox, confirm and search-list prompt throughLaunchCommand'suxon a pseudo-terminal, types Ctrl-C and expects exit 3. The driver istest/support/pty/press-ctrl-c.py(Python stdlibpty, no native module;python3is on the ubuntu runners). The driver kills the CLI and fails the test if it is still running 30 s after Ctrl-C. Against the oldcancelOnInterrupt(cliux)funnel every case fails: 130, and 1 at search-list. This is the class test the ticket asked for; the existing guards simulatedSIGINT, which is how this regression stayed green.Unit tests for both rejections in
src/core/interruptible-ux.test.ts, and forlibraryUx/terminalUxinsrc/core/terminal-ux.test.ts.projects-command-flows.test.tspresses Ctrl-C at the project picker and expects exit 3.Manual acceptance harness (
scripts/launch-cli-manual-tests,LAUNCH_INTERACTIVE=1, dev11) against this branch: every Ctrl-C case passes. That covers the organization picker, the project picker, the firstprojects:createprompt, theenv:getenvironment picker and thedeployments:listenvironment picker, each exiting 3. 68 passed, 1 failed. The failure is the harness'sdeployments:getcheck of the ENVIRONMENT VARIABLES wording, which has been stale since 50a8622 and is unrelated to this PR. The test environment has one domain, so 88's multi-domain Ctrl-C case did not run.Coverage:
npm run test:coveragereports branch coverage at 99.75%, under the 100% threshold.v2-dev(43e0d95) reports exactly the same gaps, run locally: one branch each incache.presenter.ts,logs/get.ts,failure.ts,commit.prompt.ts,deployment.create.ts,deployment.rollback.tsanddeployment.watcher.ts. None of them comes from this PR. Every file this PR adds or changes is at 100%.Left as is, low:
terminalUxno longer runs prompt messages through cli-utilities' message-key lookup (messageHandler.parse), whichcliux.inquiredid. Every Launch prompt message is a literal English sentence, not a key.search-listis still the one legacy inquirer prompt, hence the abort-then-SIGINTcase in the wrapper. Porting the pickers to@inquirer/searchwould leave one Ctrl-C path. That is a follow-up, not part of this fix.python3(3.9+, POSIXpty), which the ubuntu runners and macOS have.Talisman:
.talismanrcgets a checksum for the new pty test (itspasswordprompt type trips the scanner) and refreshed checksums for the touched files that already had one.#claude_code#
🤖 Generated with Claude Code