Skip to content

feat(tui): clear prompt input on double escape - #35036

Closed
azizbecha wants to merge 2 commits into
anomalyco:devfrom
azizbecha:double-esc-clear
Closed

feat(tui): clear prompt input on double escape#35036
azizbecha wants to merge 2 commits into
anomalyco:devfrom
azizbecha:double-esc-clear

Conversation

@azizbecha

Copy link
Copy Markdown

Issue for this PR

Closes # — no existing issue for this one. Related: #14037 asked for Claude Code double-esc parity (restore menu) before being stale-closed; this PR covers a different piece, clearing the input. Happy to open an issue first if that's preferred given the feature guardrail in CONTRIBUTING.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Pressing esc twice quickly (within 500ms) clears the prompt input. Today esc does nothing in the prompt while the session is idle, and ctrl+c is the only way to clear it.

It reuses the two patterns that already exist for this:

  • the double-press counter that session.interrupt uses for esc-esc while busy (counter in the prompt store + timeout reset), with a footer hint "esc again to clear" after the first press, styled like the existing "esc again to interrupt" hint
  • the existing clearPrompt() path, so the cleared draft is appended to prompt history and recoverable with up-arrow, exactly like ctrl+c

The binding is a new configurable keybind input_clear_double (default escape, set "none" to disable) mapped to a new prompt.clear.double command. Its enabled gate makes it mutually exclusive with every other escape claimant: only fires when the session is idle (esc while busy still interrupts and never touches the text), prompt non-empty, normal mode, no autocomplete popup, no dialog. Escape-cancels-pending-leader-sequence behavior is untouched.

How did you verify your code works?

  • New integration test packages/tui/test/cli/tui/prompt-clear.test.tsx mounts the real Prompt component with the full provider stack and drives real key events through the keymap: double-esc clears and the draft is restorable from history via up-arrow, the footer hint appears/disappears, a second esc after 600ms does not clear, input_clear_double: "none" disables the feature, and a busy session (via a session.status event) keeps the interrupt behavior with text intact.
  • Keybind plumbing test in test/keymap.test.tsx (compiles to escape, disable works).
  • bun test in packages/tui: 196 pass, 0 fail. bun run typecheck clean.
  • Tested locally in the running TUI.

Screenshots / recordings

Captured frame from the integration test after the first esc press:

┃  this is a draft message for testing
╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
   esc again to clear                agents   commands

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant