fix(cli): add inline --yes/now skip for destructive slash commands (#30768)#31704
Merged
Conversation
…30768) Issue #30768 reports that on native Windows PowerShell the destructive-slash confirmation modal renders but never registers keypresses, leaving the user unable to confirm or cancel /reset, /new, /clear, or /undo. The modal works on macOS, Linux, and WSL; PR #23907 (merged May 11) replaced the daemon-thread input() pattern with a prompt_toolkit-native keybinding modal but the win32 input pipeline apparently doesn't dispatch keys to the filter-conditioned handlers. The modal investigation is ongoing. This change ships the immediate escape hatch: append `now`, `--yes`, or `-y` to any destructive slash command to bypass the modal and run the action immediately. Works on every platform without touching the broken Windows code path. /reset now -> reset, no modal /new --yes my-session -> new session titled "my-session", no modal /clear -y -> clear, no modal /undo -y -> undo, no modal The default behavior (modal prompts when approvals.destructive_slash_confirm is True) is unchanged for users who don't pass a skip token. Implementation: - New classmethod HermesCLI._split_destructive_skip(text) -> (remainder, skip) parses a destructive-slash command string, strips the leading "/cmd" word and any recognized skip tokens (case-insensitive exact match, not substring), and reports whether a skip was requested. - HermesCLI._confirm_destructive_slash gains an optional cmd_original= arg. When the arg contains a skip token, it returns "once" immediately — before the gate check and before any modal rendering. - The /clear, /new, /undo handlers in process_command pass cmd_original through. /new additionally uses _split_destructive_skip to strip skip tokens from the remaining text before deriving the session title, so "/new now My Session" yields title="My Session" (not "now My Session"). Tests: - 7 new unit tests in tests/cli/test_destructive_slash_confirm.py covering the helper (recognized tokens, command-word stripping, case-insensitive exact match, None/empty input) and the modal bypass (now and --yes both skip; no-skip-token still consults the modal). - 3 new integration tests in tests/cli/test_destructive_slash_inline_skip_e2e.py driving HermesCLI.process_command end-to-end and asserting (a) new_session is invoked, (b) the modal is never reached, (c) the skip token does not leak into the session title, and (d) the no-skip-token path still reaches the modal as a sanity check that we haven't accidentally short-circuited the normal flow. All 31 tests across the destructive-slash test surface pass. Docs: - website/docs/reference/slash-commands.md documents the new flags both in the destructive-commands table and the dedicated approval section, with a link back to issue #30768 explaining why the escape hatch exists.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-argument-type |
1 |
First entries
tests/cli/test_destructive_slash_inline_skip_e2e.py:126: [invalid-argument-type] invalid-argument-type: Argument to bound method `HermesCLI.process_command` is incorrect: Expected `HermesCLI`, found `SimpleNamespace`
✅ Fixed issues: none
Unchanged: 4848 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
1 task
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
Append
now,--yes, or-yto any destructive slash command (/reset,/new,/clear,/undo) to bypass the confirmation modal — gives users on platforms where the modal doesn't dispatch keys (native Windows PowerShell, issue #30768) an immediate self-service unblock without flippingapprovals.destructive_slash_confirmin config.Changes
cli.py: new classmethodHermesCLI._split_destructive_skip(text)parses out skip tokens (case-insensitive exact match —now,--yes,-y)._confirm_destructive_slashgains an optionalcmd_original=argument and returns"once"immediately when a skip token is present, before the gate check and before any modal rendering. The three call sites (/clear,/new,/undo—/resetresolves tonewvia alias) passcmd_originalthrough./newadditionally strips skip tokens from the title so/new --yes My Sessionyieldstitle="My Session"instead oftitle="--yes My Session".tests/cli/test_destructive_slash_confirm.py: +7 unit tests covering the helper (recognized tokens, command-word stripping, case-insensitive exact match, defensive empty/None input) and the modal bypass (nowand--yesboth skip; no-skip-token still consults the modal).tests/cli/test_destructive_slash_inline_skip_e2e.py(new): 3 integration tests drivingHermesCLI.process_commandend-to-end — provesnew_sessionruns, the modal is never invoked, the skip token doesn't leak into the title, and the no-skip path still reaches the modal as a sanity check that we haven't accidentally short-circuited normal flow.website/docs/reference/slash-commands.md: documents the new flags in both the destructive-commands table and the dedicated approval section, with a link to Bug: /reset and /new slash commands freeze on Windows — routes to interactive CLI menu #30768.Validation
All 31 tests across the destructive-slash test surface pass on Windows:
The Linux modal path is byte-identical to before for callers that don't pass a skip token (the new
cmd_originalarg defaults toNone, and whenNoneor empty the function falls through to the existing gate/modal logic). Thetest_confirm_destructive_slash_no_skip_token_still_promptsandtest_new_without_skip_token_still_consults_modaltests pin that invariant.Notes
_prompt_text_input_modal, so it cannot hit the broken win32 dispatch regardless of platform.now,--yes,-y) and uses exact-match (not substring) so titles likeNow-Titleordo-this-noware unaffected.Fixes #30768
Infographic