Skip to content

refactor(cli): finalize event-driven transition and remove interaction bridge - #18569

Merged
abhipatel12 merged 2 commits into
mainfrom
abhi/event-tools-cleanup.5
Feb 13, 2026
Merged

refactor(cli): finalize event-driven transition and remove interaction bridge#18569
abhipatel12 merged 2 commits into
mainfrom
abhi/event-tools-cleanup.5

Conversation

@abhipatel12

Copy link
Copy Markdown
Contributor

Summary

This final phase of the tool scheduler cleanup removes the "interaction bridge" between the modern event-driven engine and legacy UI expectations. It eliminates all manual onConfirm callback injections, ensuring that the CLI interacts with tool approvals exclusively via the MessageBus.

Details

  • useToolScheduler.ts: Removed the legacy adapter that was injecting onConfirm callbacks into tool call objects.
  • ToolActionsContext.tsx: Removed the legacy callback-based confirmation path. All tool confirmations are now dispatched purely via the MessageBus using correlationId.
  • useGeminiStream.ts: Refactored auto-approval logic (e.g., for YOLO mode or ask_user tools) to publish directly to the MessageBus.
  • Types: Simplified IndividualToolCallDisplay and associated event types to use SerializableConfirmationDetails exclusively, removing references to the callback-based ToolCallConfirmationDetails.
  • Test Cleanup: Updated over a dozen test files to remove redundant onConfirm stubs and refactored useGeminiStream.test.tsx to verify correct MessageBus interactions.

Related Issues

Final stage of the legacy scheduler cleanup in the CLI package.

How to Validate

  1. Run npm run preflight to ensure all tests pass and the build is stable.
  2. Manually verify tool approval and cancellation in the CLI to ensure responses correctly reach the core engine via the bus.

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

@abhipatel12
abhipatel12 requested a review from a team as a code owner February 8, 2026 06:23
@gemini-code-assist

Copy link
Copy Markdown
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 marks the final stage of the tool scheduler cleanup in the CLI, moving away from a hybrid approach to a pure event-driven model for handling tool confirmations. The core impact is a more consistent and maintainable architecture for tool interactions, where all approvals and cancellations are now mediated through a central MessageBus, removing direct callback dependencies and simplifying the UI's interaction with the underlying engine.

Highlights

  • Event-Driven Transition Finalization: This pull request completes the transition to a fully event-driven architecture for tool approvals within the CLI, eliminating the legacy 'interaction bridge' that relied on direct callback injections.
  • Removal of onConfirm Callbacks: All manual onConfirm callback injections have been removed, streamlining the interaction between the CLI and tool approvals to exclusively use the MessageBus.
  • Refactored Auto-Approval Logic: The logic for auto-approving tools (e.g., in YOLO mode or for ask_user tools) in useGeminiStream.ts has been updated to publish directly to the MessageBus.
  • Type Simplification: Related types, such as IndividualToolCallDisplay and event types, now exclusively use SerializableConfirmationDetails, removing references to the deprecated ToolCallConfirmationDetails.
  • Extensive Test Cleanup: Over a dozen test files have been updated to remove redundant onConfirm stubs, and useGeminiStream.test.tsx was refactored to verify the new MessageBus interactions.
Changelog
  • packages/cli/src/ui/components/AlternateBufferQuittingDisplay.test.tsx
    • Removed the onConfirm property from mock confirmationDetails.
  • packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
    • Removed the onConfirm property from mock confirmationDetails.
  • packages/cli/src/ui/components/ToolConfirmationQueue.test.tsx
    • Removed unused vi import.
    • Removed onConfirm property from multiple mock confirmationDetails objects.
  • packages/cli/src/ui/components/messages/RedirectionConfirmation.test.tsx
    • Updated type import from ToolCallConfirmationDetails to SerializableConfirmationDetails.
    • Removed the onConfirm property from mock confirmationDetails.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx
    • Updated type import from ToolCallConfirmationDetails to SerializableConfirmationDetails.
    • Removed the onConfirm property from various mock confirmationDetails objects.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx
    • Removed import for ToolCallConfirmationDetails.
    • Updated ToolConfirmationMessageProps to strictly use SerializableConfirmationDetails.
  • packages/cli/src/ui/components/messages/ToolGroupMessage.test.tsx
    • Removed the onConfirm property from mock confirmationDetails.
  • packages/cli/src/ui/contexts/ToolActionsContext.test.tsx
    • Removed import for ToolCallConfirmationDetails.
    • Removed a legacy tool call entry from the mock mockToolCalls array.
    • Updated test description to reflect the removal of the 'Legacy Path'.
    • Removed the test case specifically for 'legacy tools' that called onConfirm.
    • Updated assertions for edit tool confirmation to check mockMessageBus.publish instead of onConfirm.
  • packages/cli/src/ui/contexts/ToolActionsContext.tsx
    • Removed import for ToolCallConfirmationDetails.
    • Eliminated the 'PATH B: Legacy Callback' logic for dispatching confirmations.
    • Updated the debug warning message to reflect the reliance on correlationId.
  • packages/cli/src/ui/hooks/toolMapping.ts
    • Removed import for ToolCallConfirmationDetails.
    • Simplified the type definition for confirmationDetails to SerializableConfirmationDetails.
  • packages/cli/src/ui/hooks/useGeminiStream.test.tsx
    • Added import for MessageBusType.
    • Introduced a mockMessageBus object with publish, subscribe, and unsubscribe methods.
    • Configured the mock Config to return mockMessageBus via getMessageBus.
    • Modified the createMockToolCall helper function to no longer accept mockOnConfirm.
    • Removed onConfirm property from mock confirmationDetails within createMockToolCall.
    • Added correlationId to mock tool calls generated by createMockToolCall.
    • Updated auto-approval tests (YOLO, AUTO_EDIT) to assert on mockMessageBus.publish calls instead of mockOnConfirm.
    • Removed test cases and assertions related to the onConfirm method.
  • packages/cli/src/ui/hooks/useGeminiStream.ts
    • Added import for MessageBusType.
    • Removed import for ToolCallConfirmationDetails.
    • Refactored the handleApprovalModeChange logic to publish tool confirmation responses directly to the MessageBus using correlationId.
    • Added config to the dependency array of handleApprovalModeChange.
  • packages/cli/src/ui/hooks/useToolScheduler.test.ts
    • Removed imports for ToolConfirmationOutcome and ToolCallConfirmationDetails.
    • Removed two test cases that verified the injection of onConfirm callbacks (Adapter Pattern and Inline Edit support), as this functionality is being removed.
  • packages/cli/src/ui/hooks/useToolScheduler.ts
    • Removed imports for MessageBus, ToolConfirmationPayload, and ToolConfirmationOutcome.
    • Simplified the adaptToolCalls function by removing the logic responsible for injecting onConfirm callbacks.
    • Updated internalAdaptToolCalls to no longer depend on the messageBus object.
  • packages/cli/src/ui/types.ts
    • Removed import for ToolCallConfirmationDetails.
    • Simplified the confirmationDetails type in ToolCallEvent and IndividualToolCallDisplay interfaces to exclusively use SerializableConfirmationDetails.
  • packages/cli/src/ui/utils/textUtils.test.ts
    • Updated type import from ToolCallConfirmationDetails to SerializableConfirmationDetails.
    • Removed the onConfirm property from various mock confirmationDetails objects in tests.
Activity
  • The author has added/updated tests to cover the changes.
  • The author has validated the changes on MacOS using npm run.
  • The author has not yet updated relevant documentation or README files.
  • The author has not noted any breaking changes, implying none are expected.
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.

@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 is an excellent refactoring that finalizes the transition to a fully event-driven architecture for tool confirmations by removing the legacy onConfirm callback mechanism. The changes are thorough, consistently applied across components, hooks, types, and tests, and significantly improve code clarity and maintainability. The removal of the interaction bridge in useToolScheduler and the simplification of ToolActionsContext are particularly noteworthy improvements. The test suite has been updated comprehensively to reflect these changes, ensuring the new event-driven flow is well-covered. Overall, this is a high-quality contribution that strengthens the foundation of the CLI's tool handling logic.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 8, 2026
@abhipatel12
abhipatel12 force-pushed the abhi/event-tools-cleanup.4 branch from cd89ffd to f63186e Compare February 9, 2026 00:18
@abhipatel12
abhipatel12 force-pushed the abhi/event-tools-cleanup.5 branch from 2f0c8a5 to dab0b35 Compare February 9, 2026 00:23
@abhipatel12
abhipatel12 force-pushed the abhi/event-tools-cleanup.4 branch from f63186e to 77d4c65 Compare February 12, 2026 01:34
Base automatically changed from abhi/event-tools-cleanup.4 to main February 12, 2026 02:10
@abhipatel12
abhipatel12 force-pushed the abhi/event-tools-cleanup.5 branch from dab0b35 to 6fa69ec Compare February 12, 2026 03:25
@github-actions

github-actions Bot commented Feb 12, 2026

Copy link
Copy Markdown

Size Change: -704 B (0%)

Total Size: 24.4 MB

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

compressed-size-action

Comment thread packages/cli/src/ui/hooks/useGeminiStream.test.tsx Outdated
Comment thread packages/cli/src/ui/hooks/useGeminiStream.test.tsx Outdated

@jacob314 jacob314 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.

lgtm

@abhipatel12
abhipatel12 force-pushed the abhi/event-tools-cleanup.5 branch from 6fa69ec to a73bf00 Compare February 13, 2026 02:03
@abhipatel12
abhipatel12 added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 00f73b7 Feb 13, 2026
27 checks passed
@abhipatel12
abhipatel12 deleted the abhi/event-tools-cleanup.5 branch February 13, 2026 02:26
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
@sripasg sripasg added the size/l A large sized PR label Jun 2, 2026
software-0ficial pushed a commit to software-0ficial/gemini-cli that referenced this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l A large sized PR 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.

4 participants