[Refactor] Decouple Tool-Specific Cancellation Logic from SchedulerStateManager#23699
[Refactor] Decouple Tool-Specific Cancellation Logic from SchedulerStateManager#23699akash-manna-sky wants to merge 2 commits intogoogle-gemini:mainfrom
SchedulerStateManager#23699Conversation
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 refactors the core scheduling mechanism by decoupling tool-specific cancellation logic from the 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
|
|
Hello @abhipatel12, can you please review the changes? |
There was a problem hiding this comment.
Code Review
This pull request refactors the handling of cancelResult for tool calls, moving the responsibility of providing cancellation details from the SchedulerStateManager to individual tools. The cancelResult field has been added to various SerializableConfirmationDetails types and ToolEditConfirmationDetails, and the WriteFileTool is updated to populate this field. The SchedulerStateManager now directly uses the cancelResult provided by the tool. New tests were added to verify this behavior. The review feedback indicates that the diffStat is missing from the cancelResult provided by the WriteFileTool, which is a regression, and suggests adding assertions for diffStat in the new test cases for WriteFileTool to ensure full data contract coverage.
| cancelResult: { | ||
| fileDiff, | ||
| fileName, | ||
| filePath: this.resolvedPath, | ||
| originalContent, | ||
| newContent: correctedContent, | ||
| }, |
There was a problem hiding this comment.
This refactoring correctly moves the responsibility of creating the cancelResult to the tool. However, it seems to have missed including the diffStat in the cancelResult for file edits. The previous logic in SchedulerStateManager derived these stats, and other parts of the system (like the UI and tests) may rely on them being present.
To fix this regression, please calculate and include the diffStat in the cancelResult.
cancelResult: {
fileDiff,
fileName,
filePath: this.resolvedPath,
originalContent,
newContent: correctedContent,
diffStat: getDiffStat(
fileName,
originalContent,
correctedContent,
correctedContent,
),
},| expect(confirmation.cancelResult).toEqual( | ||
| expect.objectContaining({ | ||
| fileDiff: expect.any(String), | ||
| fileName: 'cancel_result_file.txt', | ||
| filePath, | ||
| originalContent, | ||
| newContent: correctedContent, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
This test is a great addition to verify that cancelResult is populated. To make it more robust and ensure it covers the full data contract, please also assert that cancelResult.diffStat is populated correctly. The state-manager.test.ts file includes a similar check, which confirms that diffStat is an expected part of the result.
expect(confirmation.cancelResult).toEqual(
expect.objectContaining({
fileDiff: expect.any(String),
fileName: 'cancel_result_file.txt',
filePath,
originalContent,
newContent: correctedContent,
diffStat: expect.objectContaining({
model_added_lines: expect.any(Number),
model_removed_lines: expect.any(Number),
}),
}),
);
[Refactor] Decouple Tool-Specific Cancellation Logic from
SchedulerStateManagerSummary
Details
Related Issues
Fixes #16716
How to Validate
Pre-Merge Checklist