feat(sessions): Introduce core ChatRecordingService for automatic conversation saving#5221
Conversation
There was a problem hiding this comment.
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 introduces a foundational new service for persistent storage of chat conversations. It enables automatic recording of detailed interaction data, including messages, tool usage, and model thoughts, ensuring that chat sessions can be saved and potentially resumed. This is a significant step towards enhancing session management and data retention capabilities.
Highlights
- New Service Introduction: Introduced a new
ChatRecordingServiceresponsible for automatically recording and persisting chat conversations to disk. This service captures user and assistant messages, tool calls, token usage statistics, and assistant thoughts. - Conversation Persistence: The
ChatRecordingServicestores conversation sessions as JSON files in a project-specific temporary directory (~/.gemini/tmp/<project_hash>/chats/). It supports both creating new sessions and resuming existing ones. - Configurability for Sessions: The
Configclass has been updated to allow thesessionIdto be mutable, enabling theChatRecordingServiceto update or set the session ID dynamically, which is crucial for resuming conversations. - Core Export: The new
ChatRecordingServiceis now exported from the core package'sindex.ts, making it available for use by other parts of the application.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a new ChatRecordingService for saving conversations, which is a great addition. The implementation is mostly solid, but I've found a few issues related to file management and error handling that could lead to silent failures or data loss. I've also pointed out a state management issue where the session ID is not consistently updated. Please see my detailed comments for suggestions on how to address these points.
…ing conversations
|
Good afternoon, @bl-ue! I switched to this branch and could not resume the last chat session. I reviewed the |
|
Hi @gusbemacbe! Yes, I'm sorry about that. The maintainers requested that I break this PR up into 9 smaller PRs, so this PR is the first of 9 that implement automatic chat saving, and it only implements backend functionality. Until these 9 PRs are merged, stay on the #4401 branch if you want to save your chats. |
|
Good evening, @bl-ue! Thank you for your advice and tip! Is it possible that you will keep the |
|
@gusbemacbe Of course! I'm really glad that you're testing it! I'll keep updated. |
NTaylorMullen
left a comment
There was a problem hiding this comment.
You'll also want to write some tests for the chatRecordingService. Should be easy though if you let Gemini CLI run with it :)
…dingServer in non-debug mode
|
Hi @NTaylorMullen! You probably have tons of PRs but I don't want this one to get lost in the shuffle. Any chance you can look at this one this week? |
Thank you for mentioning me directly! Yes I get hundreds per day lol. Looking now! |
There was a problem hiding this comment.
Alright, PR 1, getting in!
@bl-ue to help make sure I don't miss things like this (so sorry about the delay) feel free to shoot me an email (it's ntaylormullen (my GH handle 😄 ) at google.com and I can send you an invite to a chat space which should be easier to poke me / the team at.
|
Ah looks like you might have a linting error. You should be able to fix by doing |
23e45a0 to
1173b62
Compare
|
Hi @NTaylorMullen! Okay, sounds great. I resolved the linting error, so it should be ready. I also sent you an email with a subject of "PR #5221 on Gemini CLI". |
|
@bl-ue looks like you may have a few test failures! |
Head branch was pushed to by a user without write access
|
Hi @NTaylorMullen, okay, fixed. The |
…ervice for automatic conversation saving (google-gemini#5221)
|
Next PR: #6721 |
It was made mutable in google-gemini#5221 as part of this google-gemini#4401 branch, but that was too early, and so was reverted in google-gemini#7219. We need it mutable as part of the setup but we'll not bring it to main until it's needed.
This PR is the first in a series of 9 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 9 smaller PRs, of which this PR is the first.
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, 30+ linked issues, and a demo video.