Skip to content

fix(cli): add inline --yes/now skip for destructive slash commands (#30768)#31704

Merged
teknium1 merged 1 commit into
mainfrom
fix/30768-inline-skip-destructive
May 24, 2026
Merged

fix(cli): add inline --yes/now skip for destructive slash commands (#30768)#31704
teknium1 merged 1 commit into
mainfrom
fix/30768-inline-skip-destructive

Conversation

@teknium1

@teknium1 teknium1 commented May 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Append now, --yes, or -y to 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 flipping approvals.destructive_slash_confirm in config.

Changes

  • cli.py: new classmethod HermesCLI._split_destructive_skip(text) parses out skip tokens (case-insensitive exact match — now, --yes, -y). _confirm_destructive_slash gains an optional cmd_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/reset resolves to new via alias) pass cmd_original through. /new additionally strips skip tokens from the title so /new --yes My Session yields title="My Session" instead of title="--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 (now and --yes both skip; no-skip-token still consults the modal).
  • tests/cli/test_destructive_slash_inline_skip_e2e.py (new): 3 integration tests driving HermesCLI.process_command end-to-end — proves new_session runs, 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

Before After
Windows PowerShell /reset freeze works via /reset now
Linux/macOS /reset modal works unchanged

All 31 tests across the destructive-slash test surface pass on Windows:

tests/cli/test_destructive_slash_confirm.py ............... 16 passed
tests/cli/test_destructive_slash_inline_skip_e2e.py ........ 3 passed
tests/hermes_cli/test_destructive_slash_confirm_gate.py .... 5 passed
tests/cli/test_cli_new_session.py .......................... 7 passed
============================= 31 passed in 1.19s ==============================

The Linux modal path is byte-identical to before for callers that don't pass a skip token (the new cmd_original arg defaults to None, and when None or empty the function falls through to the existing gate/modal logic). The test_confirm_destructive_slash_no_skip_token_still_prompts and test_new_without_skip_token_still_consults_modal tests pin that invariant.

Notes

  • This is a deliberately surgical fix that ships independently of the underlying Windows modal investigation — root-causing the win32 prompt_toolkit key-dispatch issue is out of scope for this PR.
  • I was unable to do a live PowerShell repro of the original freeze from inside this agent's terminal (driving an interactive TUI from a non-TTY parent is precisely the situation that has caused freezes before — the bug we're trying to escape from). The unit + e2e tests cover the codepath that runs when a skip token is present; that codepath returns "once" without ever touching _prompt_text_input_modal, so it cannot hit the broken win32 dispatch regardless of platform.
  • Token set deliberately small (now, --yes, -y) and uses exact-match (not substring) so titles like Now-Title or do-this-now are unaffected.

Fixes #30768

Infographic

inline-skip-destructive-slash

…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.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/30768-inline-skip-destructive vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9101 on HEAD, 9100 on base (🆕 +1)

🆕 New issues (1):

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.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 24, 2026
@teknium1 teknium1 merged commit 8e68426 into main May 24, 2026
27 checks passed
@teknium1 teknium1 deleted the fix/30768-inline-skip-destructive branch May 24, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: /reset and /new slash commands freeze on Windows — routes to interactive CLI menu

2 participants