fix(cli): use prompt_toolkit.prompt() for TUI confirmation prompts (Fixes #22958)#22989
Closed
KhanCold wants to merge 1 commit into
Closed
fix(cli): use prompt_toolkit.prompt() for TUI confirmation prompts (Fixes #22958)#22989KhanCold wants to merge 1 commit into
KhanCold wants to merge 1 commit into
Conversation
This was referenced May 10, 2026
…ixes NousResearch#22958) Rebased onto upstream main.
1b80d0a to
5a4cdc1
Compare
1 task
Author
|
Closing this PR as the fix has already been merged into main via commit |
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.
Problem
When using destructive slash commands (
/clear,/new,/reset,/undo) in TUI mode, the confirmation prompt renders correctly but cannot be answered. Typing1,2, or3sends that character to the agent as a chat message instead of resolving the prompt.Root Cause
_prompt_text_input()incli.pyuses Python's built-ininput()insideprompt_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 thatinput()reads from.Fix
Replace
input()withprompt_toolkit.shortcuts.prompt()(aliased aspt_prompt) insiderun_in_terminal().pt_promptproperly negotiates terminal state with the running event loop, ensuring keystrokes are handled correctly.Changes
from prompt_toolkit.shortcuts import prompt as pt_prompt_prompt_text_input(): Usept_prompt()whenself._appis active (TUI mode), keepinput()fallback for non-TUI modept_prompt():multiline=False,enable_history_search=False,enable_suspend=False,mouse_support=FalseKeyboardInterruptandEOFError, returningNoneTesting
pt_prompt()whenself._appis activeinput()whenself._appis NoneKeyboardInterruptandEOFErrorfinallyblockFixes #22958