Skip to content

[Bug] Tool approval Yes/No selector is interactive before the formatter preview has loaded, allowing blind approval #1407

Open
awhite0030/nanocoder
#60

Description

@addyCooks

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

  1. 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).
  2. 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

  • I have searched existing issues to ensure this is not a duplicate
  • 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)
  • This issue occurs on the latest main

Activity

  1. addyCooks commented on Sep 20, 2026

    @addyCooks
    CollaboratorAuthor

    Hi @akramcodez,
    I’ve been looking into this,
    could you assign it to me?

  2. awhite0030 commented on Sep 21, 2026

    @awhite0030
  3. added
    area:toolsTool implementations and tool-calling
    securityA security weakness or hardening
    high-prioritySevere user impact: fix before other work
    on Oct 7, 2026
  4. AniketR10 commented on Oct 16, 2026

    @AniketR10
    Contributor

    @akramcodez would like to work on this pelase assign

  5. puri-adityakumar commented on Oct 19, 2026

    @puri-adityakumar
    Contributor

    @addyCooks Please assign this to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:toolsTool implementations and tool-callingarea:tuiTerminal UIbugSomething isn't workinghigh-prioritySevere user impact: fix before other worksecurityA security weakness or hardening

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions