fix(cli): prevent /reset and /new freeze on Windows by falling back to stdin prompt (#30768)#32013
Merged
Merged
Conversation
…o stdin prompt On Windows (PowerShell/Windows Terminal), the queue-based modal used for destructive slash command confirmations deadlocks because prompt_toolkit's input channel becomes unresponsive when entered from the process_loop daemon thread. Keystrokes never reach the key bindings, so response_queue.get() blocks until the 120-second timeout expires. Fix: fall back to _prompt_text_input (stdin-based) when: 1. sys.platform == 'win32' — Windows console doesn't support the modal reliably 2. Called from non-main thread — key bindings can't fire from daemon threads 3. self._app is not set — existing behavior for tests/non-interactive This mirrors the thread-aware guard from _prompt_text_input (PR #23454). 9 new regression tests covering Windows detection, non-main thread fallback, macOS/Linux modal preservation, and integration with _confirm_destructive_slash. Fixes #30768 Surgical reapply of PR #30773. Original branch was many months stale (911 files / 146k LOC of unrelated reverts); the substantive ~30 LOC change in cli.py plus the new test file were reapplied onto current main with the contributor's authorship preserved via --author.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/cli/test_slash_confirm_windows.py:23: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 4909 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
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.
Summary
/reset,/new,/curator wipe, and/exit --deleteno longer freeze on Windows. The destructive-slash confirmation modal previously deadlocked because prompt_toolkit's input channel becomes unresponsive when the modal is entered from theprocess_loopdaemon thread — keystrokes never reached the key bindings, soresponse_queue.get()blocked for the full 120-second timeout. Fixes #30768.Fix
_prompt_text_input_modalfalls back to the stdin-based_prompt_text_inputprompt when:sys.platform == "win32"— Windows ConPTY doesn't support the modal reliably._prompt_text_input, PR fix(cli): drive _prompt_text_input directly when off main thread (#23185) #23454).self._app is None— unchanged, existing behavior for tests/non-interactive contexts.macOS and Linux main-thread paths still use the rich modal — no regression.
Changes
cli.py— two new guard clauses at the top of_prompt_text_input_modalplus an updated docstring explaining the Windows deadlock.tests/cli/test_slash_confirm_windows.py— 9 new regression tests covering: Windows detection, non-main-thread fallback, macOS/Linux modal preservation, no-app fallback (existing), empty-choices behavior, integration via_confirm_destructive_slash.scripts/release.py—AUTHOR_MAPentry mappingsimo.kiihamaki@gmail.comto@SimoKiihamakifor the attribution check.Validation
/reseton WindowsChoice [1/2/3]:prompt, responsive/newon Windows/curator wipeon Windows/reseton macOS/LinuxTargeted tests:
tests/cli/test_slash_confirm_windows.py(9 new) +tests/cli/test_destructive_slash_confirm.py+tests/cli/test_destructive_slash_inline_skip_e2e.py— 28/28 passing.Salvage notes
Surgical reapply of PR #30773 by @SimoKiihamaki (commit
ed136c98e,simo.kiihamaki@gmail.com). The original branch was many months stale against currentmainand a direct cherry-pick would have reverted 911 unrelated files (−146,163 LOC), including the entire kanban-tutorial docs tree, ntfy plugin, docker s6 infrastructure, dozens of skill files, and the multi-language locale infrastructure. The substantive ~30 LOC change incli.pyplus the new 259-line regression test file were reapplied by hand onto currentmainwith the contributor's authorship preserved viagit commit --author=.Original PR #30773 will be closed pointing to this one. Issue #30768 will auto-close from the merge commit footer.
Infographic
https://v3b.fal.media/files/b/0a9b9dbf/VlmYQitISHT0_YK_49yp9_yqhGQNPn.png