[Feature] Clear the prompt with Ctrl+C when idle, and make double-Escape consistently open the tree #1459
ruttybob
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Area: TUI / Coding agent and CLI
Problem
The clear/interrupt/navigation gestures overlap in a state-dependent way that is easy to trip over:
When the editor has content and nothing is running, Ctrl+C does nothing useful — it falls through to
handleInterruptKey(), shows an exit hint, and a second press exits. There is no single-key way to discard a long draft.Double-Escape is overloaded with invisible state-dependence (
armEscapeRepeat(...)ininteractive-mode.ts):/treeselector)clearInputBar()and silently deletes the draftThe destructive branch fires exactly when the user has the most to lose. Concrete case from daily use: I am mid-draft on a prompt, then realize I actually want to send it two messages earlier in the conversation — branch from an earlier point. The natural gesture for that is double-Escape to open the tree and navigate. But because my editor has content, the same gesture wipes the draft instead. The only difference between the two outcomes is invisible editor state, and the hotkey guide ("Interrupt response or clear prompt") covers both without distinguishing them.
To be fair to the counter-arguments raised by @alexanderkjeldaas in #1098: traditional Unix TUIs don't use Ctrl+C for text editing,
Ctrl+A Ctrl+Kalready clears the editor, and in a sluggish TUI a repeated Ctrl+C meant as "clear again" can exit the program and lose state. Both concerns are legitimate — opening this discussion to settle the design rather than assume.Proposed direction
Give "clear" one unambiguous key and free double-Escape for navigation:
!hasInterruptibleWork()— no streaming, bash, compaction, retry). When an operation IS running, Ctrl+C still interrupts and preserves the draft (unlike the earlier fix(coding-agent): clear draft input on Ctrl+C #845 approach, which unconditionally cleared and could lose a draft mid-interrupt).Alternatives considered
Ctrl+A Ctrl+K(existing chord): works today, but is a two-chord sequence and undiscoverableAdditional context
This division comes from pi (earendil-works/pi), the upstream project Prime Agent's TUI is built on: there
ctrl+cis bound toapp.clear("Clear editor") andescapetoapp.interrupt("Cancel or abort"), so clearing and interrupting are never the same gesture. As a daily pi user, I find this split works well in practice and consider it a good reference point for Prime Agent.I prototyped the Ctrl+C part in #1098 (closing it now per the new contribution process). Implementation is small: in
handleCtrlC(), checkeditor.getText().length > 0 && !hasInterruptibleWork()before falling through to the exit-hint path, plus hotkey-guide and test updates. The double-Escape change is a tweak of thearmEscapeRepeat(...)predicate that currently selects"tree" : "clear". Can rebase onto current main if invited.All reactions