Repository navigation
fix(tool-confirmation): wait for validator and preview before showing approval - #1864
puri-adityakumar wants to merge 3 commits into
Conversation
nc-review: comments — 1 important, 2 nits@puri-adityakumar — a few things worth a look, none blocking. The change gates the Yes/No tool-approval selector behind a new 🟠 important · The effect now resets let cancelled = false;
setIsChecking(true);
setIsLoadingPreview(false);That partial reset implies a full one. The auto-cancel effect below keys on exactly one of the flags that is not reset: React.useEffect(() => {
if (hasFormatterError && !hasValidationError) {
answerOnce(() => onConfirm(false));
}
}, [hasFormatterError, hasValidationError, onConfirm, answerOnce]);So if the instance is reused (the case the sibling In practice ⚪ nit · On the schema-validation and validator-failure fast paths, ⚪ nit · The new tests are genuine regression tests and correctly assert against the old behaviour, which is good. One note on 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
Description
Closes #1407 and #1814.
The tool approval box showed Yes/No right away, with "Yes" highlighted, while nanocoder was still checking the call. Pressing Enter during the validator step (#1814, no loading message at all) or during "Loading preview..." (#1407) approved the tool before you could see what it would do.
What changed in
source/components/tool-confirmation.tsx:isCheckingflag stays on until the schema check, the validator and the formatter preview have all finished. The Yes/No list only appears after that.One choice to flag: in the issue thread, "Esc and 'No' keep working" was the expected behavior. Here Escape is the way to cancel during the check, and "No" comes back as soon as the list appears. I didn't show a "No"-only list during the check because swapping in "Yes" as the default when the check finishes means an Enter pressed right at that moment could approve by mistake. Happy to change it if you'd prefer the "No" option to stay visible.
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Added three tests to the existing
source/components/tool-confirmation.spec.tsx: Enter is ignored while the validator runs, Enter is ignored while the preview loads, and Escape cancels during the checks. Three existing tests that pressed keys right after mount now wait for the prompt first. All 13 pass. The two Enter tests fail against the old component, so they catch both bugs. The Escape test passes there too, since Escape already worked.Format, lint and type checks pass.
pnpm test:allhas 95 failures locally, and the same 95 fail on a clean checkout ofmain. They come from my machine: a global git commit-msg hook rejects the test repos'initcommits, and the CLI integration tests need a builtdist/. None of them touch this component.Manual Testing
Checklist
No
badges/*.svgchanges.