Skip to content

fix: prevent escape from offering to clear an empty input box - #1437

Closed
awhite0030 wants to merge 10 commits into
Nano-Collective:mainfrom
awhite0030:fix/escape-empty-input-4098719853249926375
Closed

awhite0030 wants to merge 10 commits into
Nano-Collective:mainfrom
awhite0030:fix/escape-empty-input-4098719853249926375

Conversation

@awhite0030

Copy link
Copy Markdown

Description

Brief description of what this PR does

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Docs-only or internal chores need no changeset (or run pnpm changeset --empty to note that intentionally).

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover both success and error scenarios

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging (see CONTRIBUTING.md)

Root cause: Pressing Escape always showed a "Press escape again to clear" hint even when the input was completely empty and there were no attachments, as there was no check for input.length or attachments.length in handleEscape.

Fix: Updated handleEscape in source/components/user-input.tsx to conditionally check input.length > 0 || attachments.length > 0 before calling setShowClearMessage(true). Added a test case in source/components/user-input.spec.tsx to verify this behavior.

Validation: Ran pnpm run build, pnpm test:format, pnpm test:lint, pnpm test:types, and pnpm test:knip, which all passed. Ran pnpm test:ava in the background and verified all user-input tests passed successfully.

Fixes #1430

Fixes #1430

@github-actions github-actions Bot added the area:tui Terminal UI label Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review: comments — 1 important, 2 nits

@awhite0030 — a few things worth a look, none blocking.

The change correctly guards handleEscape against showing the clear hint when both input and attachments are empty, and adds a regression test that actually exercises that branch. The fix resolves issue #1430. The badge SVGs in the changeset are unrelated noise from a local badge-updater run (and the stars badge now points at the contributor's fork) — they are drive-by churn that should not have been committed alongside this targeted bug fix.

🟠 important · scope · badges/stars.svg:1

Five badge SVGs are modified in this PR for no reason related to the bug fix:

  • badges/coverage.svg, badges/forks.svg, badges/npm-downloads-monthly.svg, badges/repo-size.svg — fresh stats from a local update-badges run.
  • badges/stars.svg — the link has changed from Nano-Collective/nanocoder to awhite0030/nanocoder (the contributor's fork). Once this lands on main the README's star badge will point at the contributor's repo instead of the collective's repo until the badge workflow next runs upstream.

These are unrelated, regenerable assets produced by update-badges.yml and the only behavioural effect of including them is to risk a wrong-owner stars badge shipping to main. Drop them from this PR — the badge workflow will regenerate them on its own cadence.

⚪ nit · tests · source/components/user-input.spec.tsx:82

The new test only asserts the negative case (t.notRegex(.../Press escape again to clear/) on an empty input). There is no positive case asserting that the clear hint still appears when input.length > 0 after one Escape press. The existing two-step clear tests indirectly cover the positive path, but a one-line stdin.write('a') followed by stdin.write('\u001B') and a regex against the hint would make this test symmetric and protect against an over-eager fix (e.g. a future change that gates the hint on attachments.length only and breaks the input.length > 0 branch).

⚪ nit · design · source/components/user-input.tsx:538

The new dep is attachments.length while input (the full string) stays in the same array. Functionally equivalent here since input and attachments are local state, but for consistency with the attachments.length choice the dep could be input.length as well — both are scalars derived from the state values the callback actually reads, which is the same intent.


🔴 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 /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:comments nc-review left non-blocking findings area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Escape offers to "clear" an already-empty input box

3 participants