fix(cli): exclude update_topic from confirmation queue count#24945
fix(cli): exclude update_topic from confirmation queue count#24945Abhijit-2592 wants to merge 3 commits intomainfrom
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 a UI inconsistency where auto-executing background tools were incorrectly included in the confirmation queue progress indicator. By filtering these specific tools out of the calculation, the user is presented with a more accurate representation of pending actionable tasks. 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: +1.55 kB (0%) Total Size: 34 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request updates the confirming tool state logic to filter out specific tool names, ensuring they are excluded from the pending tools list. The review highlights that filtering by display name is brittle and suggests implementing a more robust approach, such as adding an 'isSystemTool' flag to the 'IndividualToolCallDisplay' interface, to improve maintainability and adherence to project standards.
| (tool) => | ||
| tool.name !== UPDATE_TOPIC_TOOL_NAME && | ||
| tool.name !== UPDATE_TOPIC_DISPLAY_NAME, | ||
| ); |
There was a problem hiding this comment.
Filtering based on the display name (UPDATE_TOPIC_DISPLAY_NAME) makes this logic brittle. Per repository standards, if using internal or undocumented properties is unavoidable for critical functionality, define a local interface for those properties and add a detailed comment explaining the rationale and why a public API could not be used.
Could this be made more robust? For instance, by adding a boolean flag like isSystemTool to the IndividualToolCallDisplay interface to identify such tools? This would be a more resilient long-term solution.
References
- If using internal or undocumented SDK properties is unavoidable for critical functionality, define a local interface for those properties and add a detailed comment explaining the rationale.
There was a problem hiding this comment.
Mmm this is the simplest solution to the problem. As long as we aren't directly using the string, we should be Good. Any other solution will add unnecessary extra code affecting readability. I think the logic is very clear here in-terms of readability. I don't want to add an unnecessary interface just for one tool. In the future, if there is another similar tool then we can think about generalizing it.
There was a problem hiding this comment.
there is already some other filtering logic. please find and add to that rather than adding additional filter logic
The `update_topic` tool is an auto-executing background operation that does not require user interaction. Previously, it was included in the calculation of the tool confirmation queue size, causing the UI to show misleading counts (e.g., "1 of 2") when only one actionable tool was actually pending. This change filters out both the raw and display names of the topic tool when deriving the `index` and `total` for the `ConfirmingToolState`. Since `update_topic` never enters the `AwaitingApproval` state, the active confirming tool is guaranteed to be present in the filtered list, allowing for a simplified calculation of the queue position.
The logic that dictates whether a tool call should be visible in the chat history, the active tool group, or the confirmation queue was previously fragmented across the codebase (ToolGroupMessage.tsx, confirmingTool.ts, useGeminiStream.ts). This commit introduces a unified tool-visibility utility in the core package that exposes three semantic methods: - isRenderedInHistory - requiresUserConfirmation - isVisibleInToolGroup This cleanly resolves UI inconsistencies (such as background update_topic tools inflating the confirmation queue) by providing a single source of truth for tool visibility state, removing the need for the UI to manually check against specific tool names.
e1b6455 to
dd8f81c
Compare
Summary
This PR centralizes tool visibility logic to fix UI inconsistencies, such as the
update_topictool inflating the confirmation queue count ("X of Y").Details
The logic that dictates whether a tool call should be visible in the chat history, the active tool group, or the confirmation queue was previously fragmented across the codebase (
ToolGroupMessage.tsx,confirmingTool.ts,useGeminiStream.ts).Specifically, the
update_topictool is an auto-executing background operation that does not require user interaction. Because it was included in the calculation of the tool confirmation queue size inconfirmingTool.ts, the UI showed misleading counts (e.g., "1 of 2") when only one actionable tool was actually pending.This PR introduces a unified
tool-visibilityutility in the core package that exposes three semantic methods:isRenderedInHistoryrequiresUserConfirmationisVisibleInToolGroupThis cleanly resolves UI inconsistencies by providing a single source of truth for tool visibility state, removing the need for the UI to manually check against specific tool names like
update_topic.examples
Before
Queue count shows "1 of 2" when an
update_topictool is executing alongside another actionable tool.After
Queue count accurately shows "1 of 1", excluding background narrative updates.
Related Issues
Fixes #24944
How to Validate
npm test -w @google/gemini-cli-core -- src/utils/tool-visibility.test.tsto ensure the core rules are functioning correctly.npm test -w @google/gemini-clito ensure existing UI tests pass.update_topicand another tool; the count should only reflect actionable tools.Pre-Merge Checklist
[ ] Updated relevant documentation and README (if needed)
[x] Added/updated tests (if needed)
[ ] Noted breaking changes (if any)
[x] Validated on required platforms/methods:
[x] MacOS
[x] npm run