gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

^C throws away the buffer

Open appsforartists opened this issue 1 week ago • 1 comments

What happened?

Frustratingly often, i've typed ^C (perhaps as a reflex after a typo) and lost the whole message I was drafting. I would like if the draft was stored somewhere, perhaps at the [-1] position, so I can hit the up key to undo it.

What did you expect to happen?

I can undo an accidental ^C, perhaps with the up key.

Client information

  • CLI Version: 0.21.0
  • Git Commit: 1f1bbc462
  • Session ID: 27fa8af1-eb75-48f7-b867-4e88f8d1d9cf
  • Operating System: darwin v25.0.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3-pro-preview
  • Memory Usage: 340.5 MB

Login information

No response

Anything else we need to know?

No response

appsforartists avatar Dec 16 '25 22:12 appsforartists

Found the input handling in packages/cli/src/ui/components/InputPrompt.tsx. Ctrl+C maps to Command.CLEAR_INPUT which clears the buffer.

The history mechanism uses useCommandHistory hook but only saves submitted prompts, not cancelled drafts. Adding the current buffer to a temporary 'draft' slot before clearing would enable recovery via up-arrow.

afarber avatar Dec 17 '25 09:12 afarber

Just now, I asked it to write some notes in TODO. I got the suggested amendment with the 4 options. I hit escape (I think option 4) to give more context. While I was typing, I noticed the model was still working:

✦ The write operation to TODO.md was cancelled. I will ensure I append the new section to the existing content instead of
  overwriting it. First, I'll read the current TODO.md…

I hit escape again to stop it, and also lost what I was typing.

appsforartists avatar Dec 18 '25 21:12 appsforartists