Skip to content

feat(sessions): add resuming to geminiChat and add CLI flags for session management#10719

Merged
mrcabbage972 merged 30 commits intogoogle-gemini:mainfrom
Piebald-AI:add-cli-flags-for-session-mgmt
Nov 11, 2025
Merged

feat(sessions): add resuming to geminiChat and add CLI flags for session management#10719
mrcabbage972 merged 30 commits intogoogle-gemini:mainfrom
Piebald-AI:add-cli-flags-for-session-mgmt

Conversation

@bl-ue
Copy link
Copy Markdown
Contributor

@bl-ue bl-ue commented Oct 8, 2025

This PR implements session resuming in geminiChat.ts, session selection, listing, and deletion functions, and CLI flags --list-sessions, --delete-session <id|index>, and --resume <id|index>.

Closes #1530


Note: This PR is the 4th in a series of PRs that implement automatic chat recording and resuming in both interactive and non-interactive modes, with command line flags for non-interactive resuming and session management, and an interactive session browser.

PR #4401 was the original monolithic PR, which implemented this feature from the ground up. It's too large to merge as-is, however, and so it was broken up into several smaller PRs, of which this PR is the 4th.

Please see #4401's description for the full context of this PR. The original monolithic PR's description contains a detailed analysis of the entire system, with an example of the recording JSON and a demo video.

@bl-ue bl-ue requested a review from a team as a code owner October 8, 2025 15:23
@bl-ue bl-ue marked this pull request as draft October 8, 2025 15:23
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @bl-ue, 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, the fourth in a series, significantly enhances session management for the Gemini CLI. It primarily focuses on enabling session resumption in non-interactive mode and providing comprehensive command-line tools for listing and deleting chat sessions. Key changes include adding new CLI arguments for session control, integrating session loading and history conversion into the non-interactive chat flow, and introducing new utility functions and a SessionSelector class to manage session data efficiently. This work lays the groundwork for more robust chat recording and interactive session browsing features.

Highlights

  • Session Management CLI Flags: Introduces new CLI flags --resume, --list-sessions, and --delete-session for managing chat sessions directly from the command line. The --resume flag allows users to continue a previous conversation by specifying a session ID, index, or 'latest'. The --list-sessions flag displays all recorded sessions for the current project, and --delete-session enables removal of specific sessions.
  • Non-Interactive Session Resumption: Adds the capability to resume Gemini chat sessions in non-interactive mode. When --resume is used, the CLI loads the specified session's history and continues the conversation from that point, ensuring continuity across non-interactive runs.
  • Session Data Conversion and Utilities: New utility functions and a SessionSelector class are introduced to handle session data. convertSessionToHistoryFormats transforms stored session messages into formats suitable for both UI display and the Gemini client API. SessionSelector facilitates finding and loading sessions based on various identifiers, and new helper functions extractFirstUserMessage and formatRelativeTime improve session listing readability.
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.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This is a great step forward in improving session management. The new CLI flags for listing, deleting, and resuming sessions are valuable additions. The implementation is solid, especially the logic in SessionSelector for resolving session identifiers.

I've found one high-severity issue related to parsing session identifiers for deletion that could lead to deleting the wrong session. Please see the detailed comment below.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bl-ue
Copy link
Copy Markdown
Contributor Author

bl-ue commented Oct 8, 2025

/gemini review

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This is a great step forward in implementing session management. The new CLI flags for listing, resuming, and deleting sessions are well-implemented, and the underlying logic for session resolution and history conversion is comprehensive. I have one high-severity suggestion regarding code duplication that will improve the long-term maintainability of this new functionality. Overall, excellent work on this complex feature.

@bl-ue bl-ue marked this pull request as ready for review October 8, 2025 23:36
@mrcabbage972
Copy link
Copy Markdown
Contributor

I tried to resume a session, but the previous content of the session wasn't displayed. Is that a bug?

@bl-ue bl-ue force-pushed the add-cli-flags-for-session-mgmt branch from 1a20cfb to 0c9d470 Compare October 14, 2025 20:15
@bl-ue bl-ue marked this pull request as draft October 19, 2025 13:31
@bl-ue bl-ue requested a review from mrcabbage972 October 29, 2025 15:49
@mrcabbage972
Copy link
Copy Markdown
Contributor

/gemini review

Copy link
Copy Markdown
Contributor

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

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 significant feature: session management for the CLI. It adds the ability to list, delete, and resume previous chat sessions through new command-line flags (--list-sessions, --delete-session, and --resume). The implementation is well-structured, with logic for session discovery, selection, and data conversion neatly encapsulated in new utility files and React hooks. The changes span both interactive and non-interactive modes, ensuring a consistent experience. The addition of comprehensive unit tests for the new functionality, including argument parsing, session data conversion, and the new UI hooks, is commendable and ensures the feature is robust. Overall, this is a solid contribution that greatly enhances the usability of the CLI. I found no critical or high-severity issues in the implementation.

@bl-ue
Copy link
Copy Markdown
Contributor Author

bl-ue commented Nov 10, 2025

Hi @mrcabbage972, thank you for approving the tests. I fixed the failing ones—they were caused by changes from my merges of main over time.

@mrcabbage972 mrcabbage972 added this pull request to the merge queue Nov 11, 2025
Merged via the queue into google-gemini:main with commit 6893d27 Nov 11, 2025
21 checks passed
@bl-ue bl-ue deleted the add-cli-flags-for-session-mgmt branch November 11, 2025 01:42
@bl-ue bl-ue mentioned this pull request Nov 18, 2025
18 tasks
@bl-ue
Copy link
Copy Markdown
Contributor Author

bl-ue commented Nov 18, 2025

Next: #13300

jackwotherspoon pushed a commit that referenced this pull request Nov 19, 2025
…ion management (#10719)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Nov 19, 2025
@arjun810
Copy link
Copy Markdown

@bl-ue this has a small bug, where when you try to resume a session noninteractively with stdin, it doesn't accept it and gives you this error:

When resuming a session, you must provide a message via --prompt (-p) or stdin

the check on line 262 ( if (argv.resume && !argv.prompt && !process.stdin.isTTY) ) isn't quite right

bl-ue added a commit to Piebald-AI/gemini-cli that referenced this pull request Nov 20, 2025
bl-ue added a commit to Piebald-AI/gemini-cli that referenced this pull request Nov 20, 2025
@bl-ue
Copy link
Copy Markdown
Contributor Author

bl-ue commented Nov 20, 2025

Hi @arjun810! Thank for you for catching that! The check was out of date anyway. Fixed in #13520.

danpalmer pushed a commit to danpalmer/gemini-cli that referenced this pull request Nov 29, 2025
…ion management (google-gemini#10719)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
danpalmer pushed a commit to danpalmer/gemini-cli that referenced this pull request Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for continuing existing conversations in non-interactive mode

5 participants