Skip to content

refactor(cli): centralize dense payload detection in tool mapping#28408

Open
Arjan-P wants to merge 1 commit into
google-gemini:mainfrom
Arjan-P:refactor/decouple-hasDensePayload
Open

refactor(cli): centralize dense payload detection in tool mapping#28408
Arjan-P wants to merge 1 commit into
google-gemini:mainfrom
Arjan-P:refactor/decouple-hasDensePayload

Conversation

@Arjan-P

@Arjan-P Arjan-P commented Jul 15, 2026

Copy link
Copy Markdown

Title: refactor(ui): centralize dense payload detection in tool mapping

Summary

Refactors the UI to reduce its awareness of backend data internals. It moves the complex payload density
detection logic from ToolGroupMessage into mapToDisplay by introducing a hasDensePayload boolean
property to the IndividualToolCallDisplay interface.

Details

Previously, UI components (ToolGroupMessage.tsx) contained brittle type guards (isFileDiff) and object
shape checks to determine if a tool output was "dense" (e.g., a diff or structured object). This logic is
now centralized in mapToDisplay, making the UI component lighter and easier to maintain.

Related Issues

#28260

How to Validate

Run the targeted UI tests to ensure no regressions in component rendering:

npm test -w @google/gemini-cli-cli -- src/ui/components/messages/ToolGroupMessage.test.tsx
npm test -w @google/gemini-cli-cli -- src/ui/components/messages/ToolGroupMessage.compact.test.tsx
npm test -w @google/gemini-cli-cli -- src/ui/components/messages/ToolGroupMessageRegression.test.tsx

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods (Please confirm validation status)

Move dense payload detection logic from UI components to `mapToDisplay`.
Add `hasDensePayload` property to `IndividualToolCallDisplay` interface.
Cleanup redundant helper functions in `ToolGroupMessage`.
@github-actions github-actions Bot added the size/s A small PR label Jul 15, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 39
  • Additions: +14
  • Deletions: -25
  • Files changed: 3

@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/core Issues related to User Interface, OS Support, Core Functionality labels Jul 15, 2026
@Arjan-P

Arjan-P commented Jul 15, 2026

Copy link
Copy Markdown
Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 refactors the determination of whether a tool call has a dense payload. The hasDensePayload calculation has been moved from the ToolGroupMessage UI component to the mapToDisplay hook in toolMapping.ts, and the result is now exposed as an optional boolean property on the IndividualToolCallDisplay interface. This successfully decouples the UI component from core internals like isFileDiff. I have no additional feedback to provide as the changes are clean and well-structured.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 UI layer to decouple it from backend data internals. By centralizing the logic for detecting 'dense' tool payloads within the mapToDisplay function and exposing this state via the IndividualToolCallDisplay interface, the codebase becomes more maintainable and less prone to UI-specific regressions when data structures evolve.

Highlights

  • Centralized Logic: Moved the dense payload detection logic from the UI component into the mapping layer, reducing UI component complexity.
  • Interface Update: Added a new hasDensePayload boolean property to the IndividualToolCallDisplay interface to standardize payload identification.
  • Refactored Component: Simplified ToolGroupMessage by removing brittle type guards and direct dependency on isFileDiff.
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 the 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 counterproductive. 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

  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.

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

Copy link
Copy Markdown
Contributor

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 refactors the dense payload detection logic for tool calls. The hasDensePayload helper function and its import of isFileDiff have been removed from the ToolGroupMessage component. This logic is now handled during the mapping phase in toolMapping.ts, which computes and assigns the hasDensePayload boolean property directly to the IndividualToolCallDisplay objects. There are no review comments, and I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p3 Backlog - a good idea but not currently a priority. size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant