From a7f4d756b7048e4ece779ad44737ef060716b1b1 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 18 Apr 2026 14:36:34 -0500 Subject: [PATCH] fix(tui): cap approval prompt command preview at 10 lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Large inline scripts (e.g. Python code_execution bodies) rendered as a single unbounded block, pushing the Allow/Deny options below the visible viewport. Users had to scroll the terminal to vote. Preview now shows the first 10 lines with truncate-end wrap per line and a dim "… +N more lines" indicator. Full text remains in the transcript above. --- ui-tui/src/components/prompts.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui-tui/src/components/prompts.tsx b/ui-tui/src/components/prompts.tsx index 98aba0789b..bfc603c51c 100644 --- a/ui-tui/src/components/prompts.tsx +++ b/ui-tui/src/components/prompts.tsx @@ -8,6 +8,7 @@ import { TextInput } from './textInput.js' const OPTS = ['once', 'session', 'always', 'deny'] as const const LABELS = { always: 'Always allow', deny: 'Deny', once: 'Allow once', session: 'Allow this session' } as const +const CMD_PREVIEW_LINES = 10 export function ApprovalPrompt({ onChoice, req, t }: ApprovalPromptProps) { const [sel, setSel] = useState(0) @@ -34,13 +35,28 @@ export function ApprovalPrompt({ onChoice, req, t }: ApprovalPromptProps) { } }) + const rawLines = req.command.split('\n') + const shown = rawLines.slice(0, CMD_PREVIEW_LINES) + const overflow = rawLines.length - shown.length + return ( ⚠ approval required · {req.description} - {req.command} + + {shown.map((line, i) => ( + + {line || ' '} + + ))} + + {overflow > 0 ? ( + … +{overflow} more line{overflow === 1 ? '' : 's'} (full text above) + ) : null} + + {OPTS.map((o, i) => (