Skip to content

Conversation

@abhipatel12
Copy link
Collaborator

Summary

Refactor the CLI UI to centralize tool mapping logic and decouple the legacy
scheduler from UI concerns. This establishes the necessary data contract for
Phase 2 of the Event-Driven ReAct loop migration.

Details

  • Centralized Mapping: Introduced toolMapping.ts as a pure projection
    layer. It transforms Core ToolCall objects into UI HistoryItemToolGroup
    objects, separating execution state from presentation.
  • Decoupling: Refactored useReactToolScheduler.ts to remove internal UI
    mapping logic, making it a pure execution bridge.
  • Unified Rendering: Updated useGeminiStream.ts to utilize the new
    centralized mapper, ensuring consistent rendering regardless of the underlying
    scheduler implementation.
  • Testing: Added toolMapping.test.ts with comprehensive unit tests for all
    tool state transitions (validating, success, error, etc.).

Related Issues

Related to #14306

How to Validate

  1. Unit Tests:
    • npm test -w @google/gemini-cli -- src/ui/hooks/toolMapping.test.ts
    • npm test -w @google/gemini-cli -- src/ui/hooks/useReactToolScheduler.test.ts
  2. Manual Verification:
    • Launch the CLI and execute a prompt that triggers tools (e.g.,
      list files).
    • Verify that the tool execution progress and final results render correctly
      in the history.

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:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

- Introduces toolMapping.ts as a pure projection layer from Core ToolCall to UI IndividualToolCallDisplay.
- Decouples useReactToolScheduler from shared mapping logic by moving legacy "tracked" types locally.
- Updates useGeminiStream to use the new mapping utility.
- Provides a clean, verified foundation for the event-driven scheduler migration.
@abhipatel12 abhipatel12 requested a review from a team as a code owner January 19, 2026 23:41
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Jan 19, 2026

Hi @abhipatel12, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @abhipatel12, 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 CLI UI to centralize the logic for mapping tool calls to their display representations and to decouple the legacy tool scheduler from UI concerns. This foundational work establishes a clear data contract, which is crucial for the upcoming Phase 2 of the Event-Driven ReAct loop migration. The changes aim to improve maintainability, promote consistent UI rendering, and prepare the codebase for future architectural enhancements.

Highlights

  • Centralized Tool Mapping Logic: A new module, toolMapping.ts, has been introduced to act as a pure projection layer. It is responsible for transforming Core ToolCall objects into UI HistoryItemToolGroup objects, effectively separating execution state from presentation concerns.
  • Decoupling Legacy Scheduler: The useReactToolScheduler.ts hook has been refactored to remove internal UI mapping logic, making it a pure execution bridge. This change decouples the legacy scheduler from UI-specific concerns.
  • Unified Rendering: The useGeminiStream.ts hook has been updated to utilize the new centralized toolMapping.ts module, ensuring consistent rendering of tool execution progress and results across the UI, regardless of the underlying scheduler implementation.
  • Comprehensive Testing: New unit tests have been added in toolMapping.test.ts to cover all tool state transitions (validating, success, error, etc.), ensuring the correctness and robustness of the new mapping logic.
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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

  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.

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

Size Change: -1.19 kB (-0.01%)

Total Size: 23.2 MB

Filename Size Change
./bundle/gemini.js 23.2 MB -1.19 kB (-0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

Copy link
Contributor

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

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 is a nice refactoring that centralizes the tool call mapping logic into a new toolMapping.ts module. This decouples the UI mapping from the tool scheduling logic in useReactToolScheduler.ts, improving modularity and separation of concerns. The introduction of comprehensive unit tests for the new mapping logic in toolMapping.test.ts is also a great addition.

My review focuses on improving the type safety in the new mapping function. I've suggested a small change to avoid using an any type cast, which makes the code cleaner and more robust.

@gemini-cli gemini-cli bot added the area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality label Jan 19, 2026

if (call.status === 'error') {
displayName =
call.tool === undefined ? call.request.name : call.tool.displayName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why diverge the display name in error scenarios (compared to the else block below)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We end up needing it b/c in some error states (like a
tool not being found), call.tool or call.invocation could be undefined.

I changed some things to unify the display name but keeping the description check.

export type CancelAllFn = (signal: AbortSignal) => void;

/**
* Legacy scheduler implementation based on CoreToolScheduler callbacks.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What still uses this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still the primary hook. It's just labeled legacy b/c there's a chain and we have another PR after this that switches it.

Added a comment to clarify this!

@abhipatel12 abhipatel12 enabled auto-merge January 20, 2026 00:52
@abhipatel12 abhipatel12 added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit 1b6b6d4 Jan 20, 2026
25 checks passed
@abhipatel12 abhipatel12 deleted the abhi/event-driven-tools.6 branch January 20, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants