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