-
Notifications
You must be signed in to change notification settings - Fork 10.1k
feat: auto-approve pending tool calls when auto_edit/yolo is activated #6665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @bulkypanda, 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 enhances the auto-approval workflow by integrating pending tool calls. It allows the system to automatically process pending tool calls when the user switches to YOLO or AUTO_EDIT modes via keybinds, improving the efficiency of automated operations. Additionally, it includes a minor UI adjustment for tool group messages.
Highlights
- Enhanced Auto-Approval: Implemented logic to automatically approve pending tool calls when the YOLO or AUTO_EDIT modes are activated.
- Conditional Tool Approval: In AUTO_EDIT mode, only 'replace' and 'write_file' tool calls are auto-approved, providing more granular control.
- Improved UI Spacing: Adjusted the spacing for ToolGroupMessage components to enhance visual clarity.
- Comprehensive Testing: Added extensive test coverage for the new auto-approval functionality, ensuring robustness and correctness.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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
-
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. ↩
There was a problem hiding this 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 enhances the auto-approval workflow by processing pending tool calls when switching to YOLO or AUTO_EDIT modes. The changes are well-tested and the overall approach is good. However, there is a critical issue in useAutoAcceptIndicator.ts where forEach is used with an async function, which can lead to unhandled promises and potential race conditions. I've suggested a fix to use Promise.all to correctly handle the asynchronous operations.
jacob314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great case to handle. some comments on how to handle it.
|
all addressed. |
jacob314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Approved once there are tests for the useGeminiStream.ts changes.
…ration - Integrate pending tool calls into auto-accept indicator hook - Add auto-approval of pending tool calls when switching to YOLO/AUTO_EDIT modes - Update ToolGroupMessage spacing for better visual separation - Add comprehensive test coverage for new auto-approval functionality - Export pending tool calls from useGeminiStream hook
Fixes race condition where forEach was used with async functions, which doesn't wait for promises and can cause unhandled promise rejections. Now uses Promise.all for concurrent processing with proper error handling.
…l processing - Move auto-approval logic from useAutoAcceptIndicator to useGeminiStream - Process tool calls sequentially instead of concurrently to reduce UI chaos - Remove coupling between useAutoAcceptIndicator and pendingToolCalls - Add handleApprovalModeChange callback to integrate with existing queue handling - Update tests to reflect new architecture with callback-based approach - Fix TypeScript type errors with proper TrackedWaitingToolCall type guards Addresses code review feedback for improved separation of concerns and better integration with existing tool call management infrastructure.
…niStream - Test auto-approval behavior for YOLO mode (all pending tool calls) - Test selective approval for AUTO_EDIT mode (only edit tools) - Test no approval for REQUIRE_CONFIRMATION mode - Add error handling tests for failed approvals - Add edge case tests for missing confirmation details - Test filtering by tool status (only awaiting_approval)
Fixes TypeScript build error caused by duplicate ApprovalMode identifier.
- Add type-only import for TrackedWaitingToolCall to fix verbatimModuleSyntax error - Remove marginBottom=1 from ToolGroupMessage Box components for cleaner spacing - Ensure build passes after upstream merge
Removed duplicate imports from useReactToolScheduler.js to resolve ESLint warnings.
- Fix missing pendingToolCalls parameter in useAutoAcceptIndicator call - Add ToolConfirmationOutcome import to useGeminiStream.test.tsx - Fix type import issues in useAutoAcceptIndicator.test.ts - Ensure all tests pass and build succeeds
Remove duplicate auto-approve functionality from useAutoAcceptIndicator and consolidate it in useGeminiStream.handleApprovalModeChange. - Remove auto-approve logic from useAutoAcceptIndicator - Update useAutoAcceptIndicator interface to remove pendingToolCalls param - Remove unused pendingToolCalls variable from App.tsx - Update tests to focus on approval mode change notifications only - All auto-approve logic now centralized in useGeminiStream
- Resolved merge conflicts in App.tsx (useLoadingIndicator and useAutoAcceptIndicator usage) - Resolved merge conflicts in useGeminiStream.ts (import statements) - Combined functionality from both branches
Resolved conflicts in: - packages/cli/src/ui/AppContainer.tsx - packages/cli/src/ui/hooks/useGeminiStream.ts Combined return values from both branches to preserve functionality: - Kept handleApprovalModeChange from HEAD - Added activePtyId and loopDetectionConfirmationRequest from upstream - Added pendingToolCalls export for compatibility
Extract hardcoded 'replace' and 'write_file' checks into EDIT_TOOL_NAMES constant to improve maintainability when adding new edit tools.
jacob314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1145f25
google-gemini#6665) Co-authored-by: Jacob Richman <[email protected]> Co-authored-by: Abhi <[email protected]>
…to_edit/yolo is activated (google-gemini#6665)
google-gemini#6665) Co-authored-by: Jacob Richman <[email protected]> Co-authored-by: Abhi <[email protected]>
TLDR
continue processing pending tool calls if auto edit or yolo is triggered via keybinds
Dive Deeper
Reviewer Test Plan
enable auto edit or yolo with pending tool calls using keybinds
Testing Matrix