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

Feature Request: Quick-history editing via arrow-key navigation (switch chat history)

Open chachako opened this issue 5 months ago • 9 comments

What would you like to be added?

Please add an in-place history editing mode in Gemini CLI so I can:

  • Press ↑/↓ to scroll through previous messages and see a live preview.
  • Hit Enter on a selected message to rewind the session to that point and open the message for editing.

No more manual /chat save before every prompt—just intuitive arrow-key navigation and instant message rewrite.

Why is this needed?

  • Natural CLI UX: Arrow keys are the de facto navigation method in terminals.
  • On-the-fly fixes: If a single reply is off, I can jump back and tweak it without reloading the entire thread, and avoid forgetting to run /chat save beforehand—which otherwise would force restarting the conversation from scratch.
  • Streamlined workflow: Keeps the conversation flow smooth—no extra commands or context juggling.

Thanks for considering!

Additional context

Related discussion: https://github.com/google-gemini/gemini-cli/discussions/1538

chachako avatar Jun 26 '25 04:06 chachako

Yeah, I want this by default.

The UX around this is quite bad.

Atlassian's RovoDev CLI does it better. They save all threads in history so if for any reason, it errors out, you can go back to an old thread & "Continue".. please try that CLI & encorporate its best parts in this.

I love the UX of Gemini but this is one of the most missing features that is instant value.

deadcoder0904 avatar Jun 27 '25 06:06 deadcoder0904

Also would be nice to remove messages from the end of the chat history. Like "/chat pop" or similar.

akorchemniy avatar Jul 02 '25 01:07 akorchemniy

So just to perhaps put a user flow to this

  1. User starts a conversation 1.1 User prompt 1: 'Write a python function that adds two numbers'. 1.2 User prompt 2: 'Now make it substract'

  2. Model gets confused and gives generic answer that doesn't help (as a hypothetical)

  3. User presses up arrow key once

  4. Input box populates with last prompt ('Now make it substract')

This is current gemini-cli behaviour at the moment of step 4.

  1. User presses 'enter' after the up arrow key (or some other key combination/command - someone suggested '/chat pop'.
  2. The chat history should rewind based upon how many up arrow keys and the prompt that appears in the input box - in this example the gemini response that was generic is removed.
  3. After the rewind - The cursor is active in the input box with prompt 2
  4. User edits the incorrect prompt to 'Now make it subtract'
  5. User presses enter to submit the correct prompt
  6. Conversation continues correctly as gemini provides the right response.

Happy to work on this if my understanding is correct and there's alignment on UX.

medic-code avatar Nov 05 '25 08:11 medic-code

Thanks for volunteering! The up arrow is already an established pattern. I use up arrow to intentionally execute something from history. I would be surprised if it changed to do something else like rewind.

"/chat pop" expresses my intent more directly to modify the context. It would be natural to extend it for more sophisticated history editing like "/chat drop 3" (sure this will mess with context caching, but I want the context control since this is what I can do in AI studio and many other interfaces).

Also needs clarification: I'm assuming /chat pop would leave my files as is, since it's referring to "chat" specifically. If there is a feature to also undo the changes, it should be a separate command like /undo or something.

akorchemniy avatar Nov 06 '25 02:11 akorchemniy

I think we can keep it simple. In Claude Code and Codex, we only need to press Esc twice to enter this browsing history mode. This interaction is very simple and fast, and I think we can adopt this good design.

chachako avatar Nov 06 '25 06:11 chachako

Thanks for your thoughts.

Agreed something like a double esc works, but this key binding already removes text for this in gemini-cli, I don't think enter is the correct keyboard either too confusing (I merely put it in there to aid discussion towards a spec). Something like '/reverse' works, open to suggestions, Adding in things like drop 3 etc... feels a little overcomplicated when you have a UI to do this type of work but i understand the appeal.

in Claude code, i see there's the ability to change code and change conversation or both, I think for now as an MVP conversation would be the first step imo, but would love ideas from those internally.

Still a little fuzzy on what the user should see when in reverse mode (step 6 in my list), should the user see the prompts which doesn't provide context or a summary of the model's output together (are these outputs even stored?) with the prompt so that you understand at which checkpoint to select back to ? If that is the case, I would suggest adding the last few prompt/output states and allow user to use arrows to navigate up or down.

medic-code avatar Nov 07 '25 07:11 medic-code

Agreed something like a double esc works, but this key binding already removes text for this in gemini-cli

Same for claude code. Double-Escape with filled text input clears the text input, with empty text input it summons the "Rewind" selector to step back in the conversation (This also rolls back file changes made by the agent in Claude Code!)
Extremely silly that a dozen companies make their own similar agent CLI each with unique downsides.

leumasme avatar Nov 20 '25 19:11 leumasme

I personally would vote for aligning with Claude Code, especially as many users will be inevitably switching over from Claude Code now Google is leading the race, makes sense to make it easy for them to transition. Also, just to emphasise, the current UX having to make a checkpoint with /chat save [x_name] is so backward. Imagine the command line crashes and you've lost your entire chat !

jamesk02 avatar Nov 21 '25 01:11 jamesk02

I belive gemini --resume without any additional arguments launches gemini and restores the last chat. I have used it yesterday because I lost my chat because of WebStorm. This --resume argument is not documented anywhere or I was unable to find info about it.

Edit: I have checked it more thoroughly: Read my observations here: https://github.com/google-gemini/gemini-cli/discussions/1538#discussioncomment-15045530

arkadiusz-gorecki avatar Nov 21 '25 08:11 arkadiusz-gorecki