Skip to content

fix(cli): use prompt_toolkit.prompt() for TUI confirmation prompts (Fixes #22958)#22989

Closed
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix-22958-prompt-toolkit
Closed

fix(cli): use prompt_toolkit.prompt() for TUI confirmation prompts (Fixes #22958)#22989
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix-22958-prompt-toolkit

Conversation

@KhanCold

Copy link
Copy Markdown

Problem

When using destructive slash commands (/clear, /new, /reset, /undo) in TUI mode, the confirmation prompt renders correctly but cannot be answered. Typing 1, 2, or 3 sends that character to the agent as a chat message instead of resolving the prompt.

Root Cause

_prompt_text_input() in cli.py uses Python's built-in input() inside prompt_toolkit.application.run_in_terminal(). When the TUI Application is active, input() cannot receive keystrokes because prompt_toolkit's input reader intercepts them before they reach the stdin buffer that input() reads from.

Fix

Replace input() with prompt_toolkit.shortcuts.prompt() (aliased as pt_prompt) inside run_in_terminal(). pt_prompt properly negotiates terminal state with the running event loop, ensuring keystrokes are handled correctly.

Changes

  • Import: Add from prompt_toolkit.shortcuts import prompt as pt_prompt
  • _prompt_text_input(): Use pt_prompt() when self._app is active (TUI mode), keep input() fallback for non-TUI mode
  • Options passed to pt_prompt(): multiline=False, enable_history_search=False, enable_suspend=False, mouse_support=False
  • Error handling: Both paths catch KeyboardInterrupt and EOFError, returning None

Testing

  • TUI path uses pt_prompt() when self._app is active
  • Non-TUI path falls back to input() when self._app is None
  • Both paths handle KeyboardInterrupt and EOFError
  • Status bar visibility is restored in finally block

Fixes #22958

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround labels May 10, 2026
@KhanCold

Copy link
Copy Markdown
Author

Closing this PR as the fix has already been merged into main via commit 054f5685 by @zhengyn0001 ("fix: use TUI modal for slash confirmations"), which implements the same TUI modal approach for destructive slash command confirmations. The issue #22958 is resolved in current main.

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 P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /clear, /new, /reset, /undo confirmation prompt cannot be answered — keystrokes leak into chat composer

2 participants