Skip to content

Comments

refactor(core): adopt CoreToolCallStatus enum for type safety#18998

Merged
jerop merged 1 commit intomainfrom
refactor/core-status-enum
Feb 13, 2026
Merged

refactor(core): adopt CoreToolCallStatus enum for type safety#18998
jerop merged 1 commit intomainfrom
refactor/core-status-enum

Conversation

@jerop
Copy link
Contributor

@jerop jerop commented Feb 13, 2026

This change replaces hardcoded tool call status strings ('validating', 'scheduled', 'executing', 'success', 'error', 'cancelled') with a centralized 'CoreToolCallStatus' enum in the core package.

Benefits:

  • Type Safety: Prevents runtime errors and logic bugs caused by typos in status strings across the core and cli packages.
  • Maintainability: Provides a single source of truth for all possible tool call states, making it easier to track and update state transitions.
  • Developer Experience: Enables IDE autocomplete and better discoverability of tool call statuses.
  • Code Quality: Resolves several unsafe type assertions and clarifies state handling in the Scheduler and CoreToolScheduler.

This refactor establishes a more robust foundation for tool execution tracking and UI mapping.

Related to #18918.

@jerop jerop requested a review from a team as a code owner February 13, 2026 16:11
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jerop, 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 introduces a significant refactoring across the core and CLI packages by replacing all instances of hardcoded string literals for tool call statuses with a new CoreToolCallStatus enum. This change enhances the robustness and reliability of tool execution tracking and UI mapping by enforcing type safety and providing a consistent, centralized definition for all tool states. The widespread adoption of this enum streamlines development, reduces potential errors, and improves the overall maintainability of the codebase.

Highlights

  • Type Safety: Replaced hardcoded tool call status strings with a centralized CoreToolCallStatus enum, preventing runtime errors and logic bugs caused by typos.
  • Maintainability: Established a single source of truth for all possible tool call states, simplifying state transition management and updates.
  • Developer Experience: Improved IDE autocomplete and discoverability of tool call statuses for developers.
  • Code Quality: Resolved several unsafe type assertions and clarified state handling within the Scheduler and CoreToolScheduler components.
Changelog
  • packages/cli/src/config/extension-manager.ts
    • Imported CoreToolCallStatus enum.
    • Updated logExtensionInstallEvent and logExtensionUpdateEvent calls to use CoreToolCallStatus.Success and CoreToolCallStatus.Error instead of string literals.
  • packages/cli/src/ui/hooks/toolMapping.test.ts
    • Imported CoreToolCallStatus enum.
    • Replaced all string literal tool call statuses with CoreToolCallStatus enum members in test cases for mapCoreStatusToDisplayStatus and mock tool call objects.
    • Modified createMockToolCall to include mockOnConfirm.
  • packages/cli/src/ui/hooks/toolMapping.ts
    • Imported CoreToolCallStatus and checkExhaustive from @google/gemini-cli-core.
    • Replaced string literal tool call statuses with CoreToolCallStatus enum members in mapCoreStatusToDisplayStatus and mapToDisplay functions.
    • Added approvalMode to the returned display object in mapToDisplay.
  • packages/cli/src/ui/hooks/useGeminiStream.test.tsx
    • Imported CoreToolCallStatus enum.
    • Replaced string literal tool call statuses with CoreToolCallStatus enum members in various test scenarios and mock data.
    • Updated createMockToolCall to accept CoreToolCallStatus and a mock onConfirm function.
  • packages/cli/src/zed-integration/zedIntegration.ts
    • Imported CoreToolCallStatus enum.
    • Replaced string literal tool call statuses with CoreToolCallStatus enum members in sendUpdate calls, stopReason assignments, and recordCompletedToolCalls.
  • packages/core/src/core/coreToolScheduler.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated waitForStatus function signature and internal logic to use CoreToolCallStatus enum members.
    • Modified assertions to expect CoreToolCallStatus enum members for tool call statuses.
  • packages/core/src/core/coreToolScheduler.ts
    • Imported CoreToolCallStatus enum.
    • Refactored setStatusInternal overloads and implementation to use CoreToolCallStatus enum members for all status transitions.
    • Updated conditional checks and assignments across the class to leverage the CoreToolCallStatus enum.
  • packages/core/src/scheduler/confirmation.ts
    • Imported CoreToolCallStatus enum.
    • Updated resolveConfirmation to use CoreToolCallStatus.AwaitingApproval.
  • packages/core/src/scheduler/scheduler.test.ts
    • Imported CoreToolCallStatus enum.
    • Replaced string literal tool call statuses with CoreToolCallStatus enum members in mock state manager expectations, tool call objects, and executor return values.
  • packages/core/src/scheduler/scheduler.ts
    • Imported CoreToolCallStatus enum.
    • Updated cancelAll, isTerminal, _createToolNotFoundErroredToolCall, _validateAndCreateToolCall, _processQueue, _processValidatingCall, _handleConfirmationOutcome, and _execute to use CoreToolCallStatus enum members.
  • packages/core/src/scheduler/state-manager.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated createValidatingCall and various updateStatus calls and assertions to use CoreToolCallStatus enum members.
  • packages/core/src/scheduler/state-manager.ts
    • Imported CoreToolCallStatus enum.
    • Refactored updateStatus overloads and internal state transition methods (toSuccess, toError, etc.) to exclusively use CoreToolCallStatus enum members.
  • packages/core/src/scheduler/tool-executor.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated mock ScheduledToolCall objects and test assertions to use CoreToolCallStatus enum members.
  • packages/core/src/scheduler/tool-executor.ts
    • Imported CoreToolCallStatus enum.
    • Updated tool call status assignments and return values to use CoreToolCallStatus enum members.
  • packages/core/src/scheduler/tool-modifier.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated createMockWaitingToolCall to use CoreToolCallStatus.AwaitingApproval.
  • packages/core/src/scheduler/types.ts
    • Introduced the CoreToolCallStatus enum to centralize tool call status definitions.
    • Updated all relevant tool call type definitions (ValidatingToolCall, ScheduledToolCall, ErroredToolCall, SuccessfulToolCall, ExecutingToolCall, CancelledToolCall, WaitingToolCall) to use CoreToolCallStatus enum members for their status property.
  • packages/core/src/services/chatRecordingService.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated mock tool call objects to use CoreToolCallStatus enum members for their status.
  • packages/core/src/telemetry/loggers.test.circular.ts
    • Imported CoreToolCallStatus enum.
    • Updated mock CompletedToolCall objects to use CoreToolCallStatus.Success.
  • packages/core/src/telemetry/loggers.test.ts
    • Imported CoreToolCallStatus enum.
    • Updated various telemetry event constructors and mock call objects to use CoreToolCallStatus enum members for statuses and error attributes.
  • packages/core/src/telemetry/types.ts
    • Imported CoreToolCallStatus enum.
    • Updated ToolCallEvent, SlashCommandStatus, ExtensionInstallEvent, ExtensionUninstallEvent, ExtensionUpdateEvent, and EditCorrectionEvent to use CoreToolCallStatus enum members for statuses and error attributes.
  • packages/core/src/tools/edit.ts
    • Imported CoreToolCallStatus enum.
    • Updated EditCorrectionEvent constructor to use CoreToolCallStatus.Success.
  • packages/core/src/utils/tool-utils.test.ts
    • Updated import path for ReadFileTool.
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.

This change replaces hardcoded tool call status strings ('validating',
'scheduled', 'executing', 'success', 'error', 'cancelled') with a
centralized 'CoreToolCallStatus' enum in the core package.

Benefits:
- Type Safety: Prevents runtime errors and logic bugs caused by typos in
  status strings across the core and cli packages.
- Maintainability: Provides a single source of truth for all possible
  tool call states, making it easier to track and update state transitions.
- Developer Experience: Enables IDE autocomplete and better discoverability
  of tool call statuses.
- Code Quality: Resolves several unsafe type assertions and clarifies
  state handling in the Scheduler and CoreToolScheduler.

This refactor establishes a more robust foundation for tool execution
tracking and UI mapping.
@jerop jerop force-pushed the refactor/core-status-enum branch from 16f3465 to cf6d866 Compare February 13, 2026 16:12
@jerop jerop enabled auto-merge February 13, 2026 16:13
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 great refactoring that replaces hardcoded tool call status strings with a CoreToolCallStatus enum. This significantly improves type safety and maintainability across the codebase. The changes are applied consistently across core logic, tests, and UI components.

I've found one critical issue related to a type mismatch that will likely cause a compilation error. Please see my comment for details.

Overall, this is a valuable improvement to the codebase.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/cli/src/ui/hooks/toolMapping.ts (124)

critical

The property approvalMode does not seem to exist on the call object, which is of type ToolCall from @google/gemini-cli-core. The ToolCall type and its constituent types (ValidatingToolCall, ScheduledToolCall, etc.) in packages/core/src/scheduler/types.ts do not define an approvalMode property. This will likely cause a compilation error.

If approvalMode is a property of an extended type (e.g., TrackedToolCall from useToolScheduler), the type of the call parameter in the map function should be adjusted accordingly, or the mapToDisplay function signature should be updated to accept the more specific type.

@github-actions
Copy link

Size Change: +3.89 kB (+0.02%)

Total Size: 24.4 MB

Filename Size Change
./bundle/gemini.js 24.4 MB +3.89 kB (+0.02%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB

compressed-size-action

Copy link
Member

@gundermanc gundermanc left a comment

Choose a reason for hiding this comment

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

LGTM

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 13, 2026
@jerop jerop added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 60be42f Feb 13, 2026
26 of 27 checks passed
@jerop jerop deleted the refactor/core-status-enum branch February 13, 2026 16:37
@jerop jerop linked an issue Feb 13, 2026 that may be closed by this pull request
jerop added a commit that referenced this pull request Feb 13, 2026
…allDisplay

This refactor updates the CLI to store the high-fidelity 'CoreToolCallStatus' in the history data model (ToolCallEvent and IndividualToolCallDisplay) instead of the simplified 'ToolCallStatus'. The mapping to the display-oriented 'ToolCallStatus' is now deferred to the view layer (React components), ensuring that internal logic and hooks have access to the precise state of tool execution.

Follow-up to #18998

Related to #18918
jerop added a commit that referenced this pull request Feb 13, 2026
…allDisplay

This refactor updates the CLI to store the high-fidelity 'CoreToolCallStatus' in the history data model (ToolCallEvent and IndividualToolCallDisplay) instead of the simplified 'ToolCallStatus'. The mapping to the display-oriented 'ToolCallStatus' is now deferred to the view layer (React components), ensuring that internal logic and hooks have access to the precise state of tool execution.

Follow-up to #18998

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

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI] Hide plan write and edit operations from UI in plan mode

2 participants