Skip to content

feat: double ESC to clear the input#91

Merged
balajz merged 2 commits into
balajz:mainfrom
LeeFred3042U:feat/73-double-ESC-to-clear-the-input
Jun 8, 2026
Merged

feat: double ESC to clear the input#91
balajz merged 2 commits into
balajz:mainfrom
LeeFred3042U:feat/73-double-ESC-to-clear-the-input

Conversation

@LeeFred3042U

@LeeFred3042U LeeFred3042U commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Closes #73

Changes

internal/app/ui/keys.go

  • Added Clear key.Binding to KeyMap struct
  • Added esc keybinding in DefaultKeyMap() with help text esc esc, clear input

internal/app/ui/model.go

  • Added StatePending to the const
  • Added seqTimeoutMsg struct to carry the sequence number when the 500ms timer is triggered
  • Added escSeq int field to Model to track the current esc seq generation
  • Added time to imports
  • In Update(): added Clear key handler inside tea.KeyMsg block:
    • first esc sets StatePending and fires a tea.Tick
    • second esc within 500ms calls m.input.Reset() and returns to StateInput
  • In Update(): added escTimeoutMsg case,
    • cancels pending state if the sequence number matches

Note: the 3 other files changes is maybe due to fmt, because it just removed 3 empty lines and 1 space, should i revert it or keep it?

@balajz

balajz commented Jun 6, 2026

Copy link
Copy Markdown
Owner

There is one edge case that needs to be resolved.

If I execute a long-running query, the UI state changes to StateExecuting, and the spinner starts spinning. During that time, if I press Esc, the UI switches to StatePending and eventually returns to StateInput. However, the backend continues executing the query, which creates an inconsistency between the UI and the backend. however the user still receives the query result.

screen_2026-06-06_08-42-40.mp4

@balajz

balajz commented Jun 6, 2026

Copy link
Copy Markdown
Owner

should i revert it or keep it?

keep it

@LeeFred3042U

Copy link
Copy Markdown
Contributor Author

There is one edge case that needs to be resolved.
ok

@LeeFred3042U LeeFred3042U force-pushed the feat/73-double-ESC-to-clear-the-input branch from 09c419b to b283e07 Compare June 6, 2026 07:24
@LeeFred3042U

Copy link
Copy Markdown
Contributor Author

@balajz
i updated the code for the edge case

Signed-off-by: Balaji J <j.balaji2468@gmail.com>
@balajz

balajz commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Merging, Thank you for your contribution!.

@balajz balajz merged commit adb3084 into balajz:main Jun 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: double ESC to clear the input

2 participants