-
Notifications
You must be signed in to change notification settings - Fork 10.1k
feat(ui): Add confirmation dialog for disabling loop detection for current session #8231
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
|
Size Change: +3.66 kB (+0.03%) Total Size: 13.2 MB
ℹ️ View Unchanged
|
|
/gemini review |
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 introduces a valuable feature by adding a confirmation dialog for loop detection, giving users more control. The implementation is well-structured, with a new React component for the dialog, updates to the useGeminiStream hook to manage the dialog flow, and changes to the LoopDetectionService to allow disabling detection for a session. The accompanying tests are comprehensive and cover the new functionality well.
I've identified a high-severity issue related to error handling. If an error event occurs in the stream after a loop has been detected, the UI currently shows both the error message and the loop detection dialog, which can be confusing for the user. I've provided two comments with suggestions to ensure that error messages take precedence over the loop detection dialog.
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
|
Can you pick a warning icon that does trigger ink character measuring issues? |
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.
Approved once the UX concerns are 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.
…ng loop detection for current session (google-gemini#8231)
TLDR
This change introduces a user confirmation dialog when a potential infinite loop is detected. Previously, the CLI would halt the request and there is no way to stop false positives. Now, the user is prompted with a choice: either halt the request (the default) or disable loop detection for the current session and proceed.
Confirmation dialog:

After selecting no for the first prompt and yes the second time:

Dive Deeper
The core goal is to give users more control when the
LoopDetectionServiceflags a potential infinite loop. The previous behavior was abrupt and could interrupt a valid, albeit repetitive, workflow.This PR implements the following:
LoopDetectionConfirmation.tsxcomponent is created to present the dialog to the user.useGeminiStreamhook now listens for theLoopDetectedevent and, instead of just logging a message, it triggers the new confirmation dialog.disableForSession()method on theLoopDetectionService.LoopDetectionServicewas updated to include thedisableForSessionflag, which bypasses all loop checks for the remainder of the CLI session if set.This provides a much better user experience by preventing the CLI from being overly aggressive in halting user requests, empowering the user to decide if the repetitive behavior is intentional.
Reviewer Test Plan
To test this, you'll need to trigger the loop detection mechanism.
TOOL_CALL_LOOP_THRESHOLDinpackages/core/src/services/loopDetectionService.tsto a low number, like2.escapeor select the "No, keep loop detection..." option.Testing Matrix