Skip to content

Core data structure updates for Rewind functionality - #15714

Merged
Adib234 merged 7 commits into
mainfrom
adibakm/core-ds-rewind
Jan 7, 2026
Merged

Core data structure updates for Rewind functionality#15714
Adib234 merged 7 commits into
mainfrom
adibakm/core-ds-rewind

Conversation

@Adib234

@Adib234 Adib234 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR introduces foundational changes to the core data structures and services to support a new "Rewind" feature. It enables the truncation of chat history, ensures session continuity across context resets, and enriches file operation results with metadata necessary for future undo capabilities.

Details

  • Session Persistence: The GeminiClient now captures the current session's conversation data and file path before restarting the chat (e.g., during context compression), ensuring the session file is preserved and correctly resumed.
  • Chat History Rewind: A new rewindTo(messageId) method has been added to ChatRecordingService. This allows the conversation history to be truncated to a specific message, effectively "rewinding" the chat state.
  • File Operation Metadata: The FileDiff interface and associated tools (edit, smart-edit, write-file) have been updated to include filePath and isNewFile properties. This provides the essential data required to potentially revert file creations and modifications in the future.
  • Tool Result Updates: geminiChat.ts and coreToolScheduler.ts were updated to handle the expanded ToolResultDisplay types and ensure file path information is propagated correctly through the system.

Related Issues

After this PR gets merged here are the other PRs that will get reviewed in order
#15715
#15716
#15717
#15718
#15720

How to Validate

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
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@Adib234 Adib234 self-assigned this Dec 30, 2025
@Adib234
Adib234 requested a review from a team as a code owner December 30, 2025 16:34
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Adib234, 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 significant new feature allowing users to "rewind" their chat conversations to a previous state, enhancing conversational control. Concurrently, it refines how file modification details are captured and displayed by tools, providing more comprehensive information such as the full file path and whether a file is newly created. These changes improve both the user experience for managing chat history and the accuracy of tool interaction feedback.

Highlights

  • Chat Rewind Functionality: Introduced a rewindTo method in ChatRecordingService to truncate conversation history to a specific message ID, allowing users to revert chat states.
  • Session Resume on Compression: The GeminiClient now supports resuming chat sessions from recorded files, specifically after successful chat compression, by passing conversation and file path data to the startChat method.
  • Enhanced Tool Result Display: The FileDiff interface and various tool invocations (edit, smart-edit, write-file) have been updated to include filePath and isNewFile properties, providing more granular details about file modifications in the UI and for telemetry.
  • Type System Improvements: The ToolCallRecord.resultDisplay type has been refined from a simple string to the more comprehensive ToolResultDisplay interface, accommodating the richer file change information.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 👍 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.

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.

Footnotes

  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.

@Adib234 Adib234 changed the title Adibakm/core ds rewind Core data structure updates for Rewind functionality Dec 30, 2025
@github-actions

github-actions Bot commented Dec 30, 2025

Copy link
Copy Markdown

Size Change: +1.56 kB (+0.01%)

Total Size: 22.3 MB

Filename Size Change
./bundle/gemini.js 22.2 MB +1.56 kB (+0.01%)
ℹ️ 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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a "rewind" capability for chat sessions and refactors the data structures for file diffs. The core changes include:

  1. A new rewindTo method in ChatRecordingService to truncate chat history.
  2. Enhanced chat compression logic in GeminiClient to preserve and resume session data, preventing loss of context.
  3. The FileDiff interface and related objects have been updated to include filePath and isNewFile properties, with corresponding changes propagated through tool implementations and tests.

The changes are well-implemented and consistent across the codebase. The new logic for session resumption during compression is covered by a new test case. I have reviewed the changes and did not find any issues of high or critical severity. The code quality is good.

Comment thread packages/core/src/core/geminiChat.ts Outdated
const resultDisplayRaw = call.response?.resultDisplay;
const resultDisplay =
typeof resultDisplayRaw === 'string' ? resultDisplayRaw : undefined;
const resultDisplay = call.response?.resultDisplay;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this logic change? seems unrelated to the pr.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored logic and added an additional check to make sure that resultDisplay can get assigned to an object. Since it's type is ToolResultDisplay we want it to be assigned to FileDiff as well so that we have the necessary information to perform a rewind

Comment thread packages/core/src/services/chatRecordingService.ts Outdated
Comment thread packages/core/src/services/chatRecordingService.ts Outdated
Comment thread packages/core/src/services/chatRecordingService.ts Outdated
@jacob314

jacob314 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Gemini CLI - Reviewed by Jacob

1. Robustness in ChatRecordingService.ts

The rewindTo method calls readConversation(), which assumes this.conversationFile is already set. If rewindTo is called before initialization, it will throw an error during fs.readFileSync.
Recommendation: Add a check for this.conversationFile at the beginning of rewindTo, similar to other methods in the service (e.g., recordMessage).

2. UI Integration of New Metadata

The PR enriches FileDiff with filePath and isNewFile, but these aren't yet fully utilized in the UI components:

  • ToolResultDisplay.tsx: The FileDiffResult interface should be updated to include filePath?: string and isNewFile?: boolean, and these should be passed to DiffRenderer.
  • DiffRenderer.tsx: This component currently uses a heuristic to determine isNewFile. It should be updated to accept isNewFile as a prop and prioritize it over the heuristic. This will make the detection of new files more robust.

@Adib234
Adib234 force-pushed the adibakm/core-ds-rewind branch from 545599e to 2ebfff0 Compare January 6, 2026 22:56
@Adib234

Adib234 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the issue with the robustness of in chatRecordingService, will address UI integration of new metadata in a separate PR if needed

@Adib234
Adib234 force-pushed the adibakm/core-ds-rewind branch from 8231747 to 588f46c Compare January 7, 2026 00:52
const resultDisplayRaw = call.response?.resultDisplay;
const resultDisplay =
typeof resultDisplayRaw === 'string' ? resultDisplayRaw : undefined;
typeof resultDisplayRaw === 'string' ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why this change is part of the PR. Approving to unblock reviewing the followup but please review whether this is needed.

@jacob314 jacob314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Adib234
Adib234 added this pull request to the merge queue Jan 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 7, 2026
@Adib234
Adib234 added this pull request to the merge queue Jan 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 7, 2026
@Adib234
Adib234 added this pull request to the merge queue Jan 7, 2026
Merged via the queue into main with commit 57012ae Jan 7, 2026
20 checks passed
@Adib234
Adib234 deleted the adibakm/core-ds-rewind branch January 7, 2026 17:26
sumansaurabh pushed a commit to sumansaurabh/gemini-cli that referenced this pull request Jan 9, 2026
thacio added a commit to thacio/auditaria that referenced this pull request Jan 24, 2026
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
software-0ficial pushed a commit to software-0ficial/gemini-cli that referenced this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants