Skip to content

Comments

fix(cli): allow closing debug console after auto-open via flicker#18795

Merged
SandyTao520 merged 1 commit intomainfrom
st/fix/console-close
Feb 11, 2026
Merged

fix(cli): allow closing debug console after auto-open via flicker#18795
SandyTao520 merged 1 commit intomainfrom
st/fix/console-close

Conversation

@SandyTao520
Copy link
Contributor

Summary

  • After f5b1245, pressing F12 with devtools enabled would start the DevTools server and open the browser, but not toggle showErrorDetails on the success path — so the debug console couldn't be closed once flicker auto-opened it.
  • Extracts the F12 async handler logic into a testable toggleDevToolsPanel() function in devtoolsService.ts and ensures all code paths call the toggle/setOpen callback.

Details

The original inline handler in AppContainer.tsx had three branches when devtools was enabled:

  1. Browser opens successfully → no toggle (bug)
  2. Browser fails to open → toggle
  3. shouldLaunchBrowser() is false → toggle

Now all three paths correctly invoke the callback. The logic is extracted into toggleDevToolsPanel() with full test coverage.

Related Issues

Closes the regression introduced by f5b1245 (#18695).

How to Validate

  1. Enable devtools: true in settings
  2. Trigger flicker (or an unhandled rejection) so the debug console auto-opens
  3. Press F12 → the debug console should close
  4. Run npx vitest run packages/cli/src/utils/devtoolsService.test.ts — all 18 tests pass including the 4 new toggleDevToolsPanel tests

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

@SandyTao520 SandyTao520 requested a review from a team as a code owner February 11, 2026 05:02
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 11, 2026

Hi @SandyTao520, 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 @SandyTao520, 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 addresses a regression that prevented users from closing the debug console after it was automatically opened. The core issue stemmed from inconsistent state toggling when activating DevTools via F12. The solution involves centralizing the DevTools panel activation and deactivation logic into a dedicated, well-tested utility function, ensuring that the UI state correctly reflects the panel's visibility across all possible outcomes. This improves the reliability and user experience of the DevTools integration.

Highlights

  • Bug Fix: Debug Console Closing: Resolved an issue where the debug console, after being auto-opened by flicker, could not be closed by pressing F12 because the showErrorDetails state was not consistently toggled across all execution paths.
  • Refactored DevTools Panel Logic: Extracted the asynchronous logic for handling F12 key presses and DevTools panel toggling into a new, testable function toggleDevToolsPanel() within devtoolsService.ts.
  • Improved Callback Consistency: Ensured that the toggle or setOpen callbacks are invoked in all scenarios within the toggleDevToolsPanel() function, including successful browser launch, browser launch failure, and when the browser is not launched.
  • Enhanced Test Coverage: Added comprehensive unit tests for the new toggleDevToolsPanel() function, covering various success and failure scenarios for DevTools server startup and browser opening.
Changelog
  • packages/cli/src/ui/AppContainer.tsx
    • Replaced the inline asynchronous logic for handling F12 key presses with a call to the newly introduced toggleDevToolsPanel function.
    • Passed appropriate callbacks for toggling and setting the showErrorDetails state to the new utility function.
  • packages/cli/src/utils/devtoolsService.test.ts
    • Introduced vi.hoisted mocks for shouldLaunchBrowser and openBrowserSecurely to facilitate isolated testing of DevTools-related functions.
    • Updated the mock for @google/gemini-cli-core to include warn in debugLogger and export the mocked browser utility functions.
    • Imported the new toggleDevToolsPanel function for testing.
    • Added a new describe block with four distinct test cases for toggleDevToolsPanel, verifying its behavior under various conditions (successful browser open, browser open failure, no browser launch, and DevTools server startup failure).
  • packages/cli/src/utils/devtoolsService.ts
    • Exported a new asynchronous function toggleDevToolsPanel to encapsulate the logic for starting the DevTools server, attempting to open the browser, and invoking provided toggle or setOpen callbacks.
    • Implemented error handling within toggleDevToolsPanel to ensure the setOpen callback is called if the DevTools server fails to start, and the toggle callback is called in other scenarios (browser success/failure, no browser launch).
Activity
  • The pull request fixes a regression introduced by commit f5b1245f5158c85558bb6ee456df6ccace65d9c2 (related to issue feat(cli): defer devtools startup and integrate with F12 #18695).
  • New tests have been added to cover the refactored DevTools panel logic.
  • The author has provided detailed validation steps, including enabling devtools, triggering flicker, and pressing F12 to confirm the fix, along with running specific unit tests.
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.

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 effectively fixes a bug where the debug console could not be closed after being automatically opened. The logic has been cleanly refactored from AppContainer.tsx into a new, testable toggleDevToolsPanel function in devtoolsService.ts, and the new function is well-covered by unit tests. I have one suggestion to further improve the maintainability of the new function by reducing some code duplication.

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Size Change: +17 B (0%)

Total Size: 24.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +17 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./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-closed.sb 3.29 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

compressed-size-action

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@SandyTao520 SandyTao520 added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 2af5a3a Feb 11, 2026
27 checks passed
@SandyTao520 SandyTao520 deleted the st/fix/console-close branch February 11, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants