fix(tui): copy selection on Ctrl+C in approval overlay instead of denying#18405
Open
0xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(tui): copy selection on Ctrl+C in approval overlay instead of denying#184050xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
0xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
Conversation
…ying When the dangerous-command approval (or clarify/confirm) overlay is active, Ctrl+C was unconditionally treated as "deny", making it impossible to copy the displayed command text for review. Gate the deny on `terminal.hasSelection`: when the user has text selected, copy it via the existing `copySelection()` path; otherwise fall through to the previous deny behaviour. This matches the unblocked-path precedent (`isCopyShortcut` + `clearSelection`) and the selection-vs-interrupt distinction documented in NousResearch#16181. Fixes NousResearch#18375
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.
What does this PR do?
In the TUI dangerous-command approval overlay (and the sibling clarify/confirm overlays that share the same blocked-input path),
Ctrl+Cwas unconditionally treated as deny — so users couldn't select the displayed command and copy it for review before approving/denying. The firstCtrl+Crejected the request before the clipboard write ever ran.This PR makes the keystroke selection-aware in the blocked-overlay branch of
useInputHandlers:copySelection()(same path the unblocked branch uses viaisCopyShortcut)cancelOverlayFromCtrlC()deny behaviour, unchangedThe pattern mirrors the precedent already in this file at line ~358 where
Escclears a selection before falling through to other overlay handling, and #16181's selection-vs-interrupt distinction.Related Issue
Fixes #18375
Type of Change
Changes Made
ui-tui/src/app/useInputHandlers.ts— in theisBlockedbranch foroverlay.approval || overlay.clarify || overlay.confirm, whenCtrl+Cis received, callcopySelection()ifterminal.hasSelection, otherwise the existingcancelOverlayFromCtrlC().How to Test
hermes --tuiDANGEROUS_PATTERNS— e.g. ask the agent torm -rfsomething).Ctrl+C— selection is copied to the clipboard, overlay stays open.Ctrl+C— overlay dismisses with deny, same as before.Checklist
Code
fix(tui): …)pytest tests/ -q— pre-existing failures only, all intests/tools/(transcription, file_read_guards, terminal_tool_requirements) unrelated to this change.ui-tuivitest suite (548 tests) passes.useInputcallback inuseInputHandlers.tshas no existing unit-test infra in this repo (sibling intercept paths are also untested at unit level); a hook-test scaffold would be a separate PR. Verified viatsc --noEmitand manual TUI repro.Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/Aterminal.hasSelectionis platform-agnostic;copySelection()already handles macOS/Linux/tmux/OSC 52