fix(core): reset session-scoped state on resumption#26342
Conversation
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 addresses an issue where internal session state persisted incorrectly when resuming or switching between sessions. By centralizing the reset logic within the configuration service and providing explicit reset capabilities to core state managers, the system now ensures a clean slate for each session, preventing data leakage and ensuring correct file path scoping. 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
|
|
Size Change: +710 B (0%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request centralizes and expands the session state reset logic within the Config class, specifically updating setSessionId to clear various session-scoped variables and removing redundant resets in resetNewSessionState. Additionally, a reset method was added to SkillManager to clear active skill names. Feedback suggests that the reset logic in Config should be more comprehensive by including additional internal state variables, such as model quotas and availability services, to ensure a completely fresh state for new sessions.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves session state management by ensuring that a comprehensive set of session-scoped properties are reset within the Config class when a new session is initialized. These properties include topic state, skill manager status, API request tracking, and various quota-related metrics. Additionally, a reset method was added to the SkillManager to clear active skill names. I have no feedback to provide as there were no review comments to evaluate.
Code ReviewThank you for the PR! This thoroughly addresses the session state split issue and handles the necessary cleanup on resumption. I have reviewed the changes and found two minor points related to the React frontend state that need to be addressed:
Once the quota event emission is added, this should be good to go. The removal of |
|
addressed! |
Summary
Fixes the "session state split" issue where resuming a previous session kept several internal services and states bound to the initial "startup" session ID instead of transitioning to the resumed session's identity.
Details
The Problem
When the Gemini CLI starts, it immediately generates a fresh "startup" session ID (Session A). If the user then resumes a previous session (Session B) via the Session Browser or
--resumeflag, the conversation moves to Session B, but internal services like the Task Tracker and Plan Mode often remained bound to Session A's temporary directory. This led to:The Fix
This PR updates
Config.setSessionId()to perform a comprehensive reset of all session-scoped state:trackerServicetoundefined, forcing it to be re-initialized with the correct resumed path on its next use.approvedPlanPath,topicState(title/intent), andskillManager(active skills) to ensure Session B starts with a clean slate.TrackerServiceis file-backed, once it is re-initialized with the resumed path, it automatically restores visibility of all tasks previously saved in Session B.modelAvailabilityService: Clears stale fallback/terminal states.modelQuotas,lastRetrievedQuota,lastQuotaFetchTime: Ensures fresh quota information is fetched for the resumed session.QuotaChangedevent withundefinedvalues to ensure the React UI clears its display immediately upon resumption.hasAccessToPreviewModel: Re-evaluates access to preview models.Related Issues
Fixes #24639
How to Validate
~/.gemini/tmp/<project>/<session-id>/tracker).Pre-Merge Checklist
packages/core/src/config/config.test.tsverifying all 15+ reset variables.packages/core/src/skills/skillManager.test.ts.