[Bug] Tool approval Yes/No selector is interactive before the formatter preview has loaded, allowing blind approval
Description
The tool-approval confirmation screen shows a "Loading preview..." message while the tool's formatter builds its preview asynchronously, but the Yes/No StyledSelectInput underneath is gated only on !hasFormatterError, not on !isLoadingPreview. Both error flags default to false and only flip after the formatter settles, so the approval list is mounted, focused, and accepting input with "Yes, execute this tool" pre-highlighted as the default for the entire time "Loading preview..." is on screen.
Parent: #907
Steps to Reproduce
- Trigger a tool call whose formatter preview takes a moment to build (e.g. one that reads/diffs a large file, or is momentarily slow under load).
- While "Loading preview..." is still visible, press Enter.
Expected Behavior
The Yes/No selector should not accept input (or should not be visible/focused) until the actual preview has rendered, so the user can't approve a tool call blind to what it will do.
Actual Behavior
Enter is accepted immediately and executes the tool via the default-highlighted "Yes, execute this tool" option, even though nothing about the tool call has been shown yet.
Root Cause
source/components/tool-confirmation.tsx:174-210:
{isLoadingPreview && (
<Box marginBottom={1}>
<Text color={colors.secondary}>Loading preview...</Text>
</Box>
)}
{formatterPreview && !isLoadingPreview && ( ... )}
{/* Show the approval prompt unless a formatter crash already
auto-cancelled the call. */}
{!hasFormatterError && (
<>
<Box marginBottom={1}>
<Text color={colors.tool}>Do you want to execute ...?</Text>
</Box>
<StyledSelectInput items={options} onSelect={handleSelect} />
...
isLoadingPreview (line 40) has no bearing on the !hasFormatterError condition gating the select input the two states are independent, so the approval list renders regardless of whether the preview has actually loaded.
Suggested Fix
Gate the approval block on !hasFormatterError && !isLoadingPreview so the Yes/No selector only becomes interactive once the preview has actually rendered.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently (verified by direct code trace against current
main: the JSX conditions are unambiguous a live clip needs an artificially slow formatter to demonstrate cleanly) - [x] This issue occurs on the latest
main
Hi @akramcodez,
I’ve been looking into this,
could you assign it to me?
Picking this up - a fix will follow shortly.
@akramcodez would like to work on this pelase assign
@addyCooks Please assign this to me