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

[WIP] Support rewind feature

Open Adib234 opened this issue 1 month ago • 3 comments

Summary

Introduces a new /rewind command to the Gemini CLI, allowing users to navigate conversation history, revert file changes associated with past interactions, and restart conversations from a selected point

I plan on splitting up the changes over multiple PRs, this PR exists for high-level feedback and any major concerns in design decisions

Details

  • Introducing Rewind Feature (packages/cli/src/ui/commands/rewindCommand.tsx, packages/cli/src/ui/components/RewindViewer.tsx, packages/cli/src/ui/utils/rewindFileOps.ts):

    • A new /rewind slash command has been implemented, providing an interactive UI (RewindViewer) to browse previous messages in the conversation history.
    • Users can select a specific message to "rewind" to, effectively resetting the conversation to that point.
    • The feature includes functionality to revert file system changes that were made by the agent after the chosen rewind point, offering multiple options for rewinding.
    • When a rewind occurs, the client's internal history and the context manager are reset, and the UI is updated to reflect the chosen conversation state.
  • Integrating Rewind Command (packages/cli/src/services/BuiltinCommandLoader.ts):

    • The rewindCommand is now registered as a built-in command within the BuiltinCommandLoader, making it accessible to users of the Gemini CLI.

Related Issues

Closes #1769

How to Validate

Demo of how it works, all interactions are recorded in the rewind viewer which can be opened by running the slash command /rewind.

https://github.com/user-attachments/assets/eb4d7761-a326-40ef-956d-73d7b19f876f

Pre-Merge Checklist

  • [ ] Updated relevant documentation and README (if needed)
  • [ ] Added/updated tests (if needed)
  • [ ] Noted breaking changes (if any)
  • [ ] Validated on required platforms/methods:
    • [ ] MacOS
      • [X] npm run
      • [ ] npx
      • [ ] Docker
      • [ ] Podman
      • [ ] Seatbelt
    • [ ] Windows
      • [ ] npm run
      • [ ] npx
      • [ ] Docker
    • [ ] Linux
      • [ ] npm run
      • [ ] npx
      • [ ] Docker

Adib234 avatar Dec 10 '25 17:12 Adib234

Summary of Changes

Hello @Adib234, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant new 'rewind' feature to the CLI, enabling users to go back in their conversation history, edit a previous prompt, and effectively restart the conversation from that modified point. This enhances user control over the conversational flow by allowing corrections and alternative paths without losing the entire context. The changes span UI components for viewing and editing, command registration, and core service logic for persistent storage manipulation.

Highlights

  • New Rewind Feature: Introduces a 'rewind' capability, allowing users to navigate and modify past user prompts within the conversation history. This enables correcting previous inputs and restarting the conversation from any point, discarding subsequent interactions.
  • Interaction Grouping and In-Place Editing: The RewindViewer groups conversation history into 'User + Gemini' pairs. Editing of user prompts happens directly within the list view using a specialized InlineRewindEditor component, with Ctrl+S to save edits.
  • Safety and Persistence: Rewinding is a destructive action, so the implementation handles it by optimistically updating the UI, performing the rewind on the persistence layer (file system) via ChatRecordingService, and blocking navigation during edits to prevent state corruption.
  • New Slash Command: A new slash command, /rewind, has been added to activate the rewind viewer, providing an interface for users to access this feature.
  • Core Service Updates: The ChatRecordingService now includes a rewindTo(messageId) method to truncate conversation history and a modified writeConversation method to allow saving empty conversation arrays, supporting the rewind functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Dec 10 '25 17:12 gemini-code-assist[bot]

Size Change: +34.9 kB (+0.16%)

Total Size: 22.1 MB

Filename Size Change
./bundle/gemini.js 22.1 MB +34.9 kB (+0.16%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

github-actions[bot] avatar Dec 10 '25 17:12 github-actions[bot]

/gemini review

Adib234 avatar Dec 11 '25 23:12 Adib234