feat(cli): Add /rewind <N> index argument for non-interactive use - #25150
feat(cli): Add /rewind <N> index argument for non-interactive use#25150tusaryan wants to merge 4 commits into
/rewind <N> index argument for non-interactive use#25150Conversation
Adds support for an optional integer index argument to the `/rewind` command. This enables non-interactive, automated workflows to trim conversation history and preserve prompt caches without navigating the TUI. Supports python-style negative indexing.
Summary of ChangesHello, I'm Gemini Code Assist1! 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 non-interactive way to rewind conversation history in the Gemini CLI by allowing users to pass an index argument to the /rewind command. This change is designed to support automated workflows and external tools that need to manage conversation state without interacting with the TUI. The implementation includes robust index validation, support for negative indexing, and ensures that the prompt text is correctly restored to the input buffer. Highlights
Using Gemini Code AssistThe 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
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 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 👍 and 👎 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces non-interactive, index-based rewinding for the /rewind command, enabling users to jump to specific messages using 0-based or negative indices. The changes include updated documentation, new test cases for index parsing and error handling, and a refactor of the rewindCommand to support asynchronous actions. Feedback suggests moving the duplicated text-cleaning logic into a shared utility to improve maintainability and ensure consistency with the interactive TUI.
Moves duplicated text cleaning logic into a shared utility file (formatters.ts) to ensure consistency between interactive and non-interactive rewind paths.
|
/gemini review -> I've just staged changes that refactor the string cleaner to |
There was a problem hiding this comment.
Code Review
This pull request introduces non-interactive, index-based rewinding to the /rewind command, allowing users to jump to specific messages using 0-based or negative indices. The implementation includes updates to the command logic to handle arguments, the migration of the getCleanedRewindText utility to a shared formatter, and comprehensive test coverage for the new functionality. Documentation has also been updated to reflect these changes. I have no feedback to provide as no review comments were submitted.
|
Thank you for your interest in contributing to the project! We are closing this PR as the issue was closed. |
Summary
Adds support for an optional
[index]argument to the/rewindcommand. This allows external tools orchestrating the CLI to trim conversation history programmatically, maintaining prompt cache efficiency without needing to navigate the TUI. This PR also addresses internal code duplication by centralizing string manipulation utilities.Details
/rewind -1for the last message).getCleanedRewindText()informatters.tsto ensure consistent string padding across all rewind paths.rewindConversation()now returns a boolean to prevent displaying a success message when rewind fails.packages/cli/src/ui/commands/rewindCommand.tsxpackages/cli/src/ui/commands/rewindCommand.test.tsxpackages/cli/src/ui/components/RewindViewer.tsxpackages/cli/src/ui/utils/formatters.tsdocs/cli/rewind.mdRelated Issues
Closes #24933
How to Validate
/rewind -1to delete the last user message and its response.npm test -w @google/gemini-cli -- src/ui/commands/rewindCommand.test.tsxPre-Merge Checklist