Skip to content

Comments

fix(cli): update F12 behavior to only open drawer if browser fails#18829

Merged
SandyTao520 merged 1 commit intomainfrom
st/fix/f12-behavior
Feb 11, 2026
Merged

fix(cli): update F12 behavior to only open drawer if browser fails#18829
SandyTao520 merged 1 commit intomainfrom
st/fix/f12-behavior

Conversation

@SandyTao520
Copy link
Contributor

TLDR

Updated the F12 key behavior for DevTools. Now, if the drawer is closed, pressing F12 will attempt to open the DevTools in the browser. The drawer will only open if the browser cannot be launched or fails to open. If the drawer is already open, pressing F12 will close it.

Dive Deeper

This change improves the UX by prioritizing the browser-based DevTools over the built-in debug drawer when possible. It also ensures that F12 acts as a consistent toggle for the drawer's visibility.

Key changes:

  • now takes an boolean.
  • It returns early after a successful browser launch if the drawer was closed.
  • passes the current state.
  • Updated unit tests to reflect and verify these state transitions.

Reviewer Test Plan

  1. Enable devtools in settings.
  2. Press F12 when the drawer is closed:
    • It should attempt to open your browser.
    • If the browser opens, the CLI drawer should remain closed.
  3. Press F12 when the drawer is open:
    • The drawer should close.
  4. (Optional) Simulate a browser launch failure or disable browser launching to verify the drawer still opens as a fallback.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Fixes #18795

@SandyTao520 SandyTao520 requested a review from a team as a code owner February 11, 2026 17:14
@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 refines the F12 key behavior within the CLI to enhance user experience by prioritizing the opening of browser-based DevTools. The CLI's internal DevTools drawer now serves as a fallback, opening only if the browser launch is unsuccessful or disabled. This change also ensures F12 consistently toggles the drawer's visibility when it is already open.

Highlights

  • Updated F12 Key Behavior: The F12 key now prioritizes opening browser-based DevTools. The CLI drawer will only open as a fallback if the browser launch fails or is not possible.
  • Drawer Toggle Consistency: If the DevTools drawer is already open, pressing F12 will now consistently close it.
  • New isOpen Parameter: The toggleDevToolsPanel function now accepts an isOpen boolean parameter to determine the current state of the DevTools drawer.
  • Unit Test Enhancements: Unit tests for devtoolsService were updated to reflect and verify the new logic and state transitions for the toggleDevToolsPanel function.
Changelog
  • packages/cli/src/ui/AppContainer.tsx
    • Passed the showErrorDetails boolean, representing the drawer's open state, to the toggleDevToolsPanel function.
    • Included showErrorDetails in the dependency array for the useCallback hook.
  • packages/cli/src/utils/devtoolsService.test.ts
    • Added a test case to verify that toggle is called when the drawer is already open.
    • Updated existing test cases to pass the isOpen parameter to toggleDevToolsPanel.
    • Modified assertions in tests to reflect the new logic where toggle is not called if the browser opens successfully, and setOpen is called if the browser fails or is not launched.
    • Renamed test descriptions for clarity, e.g., from "calls toggle when browser opens successfully" to "does NOT call toggle or setOpen when browser opens successfully".
  • packages/cli/src/utils/devtoolsService.ts
    • Modified the toggleDevToolsPanel function signature to accept an isOpen boolean parameter.
    • Implemented logic to immediately call toggle() and return if isOpen is true, effectively closing the drawer.
    • Changed the behavior within the try block: if openBrowserSecurely succeeds, the function now returns early, preventing the drawer from opening.
    • Updated the catch block and the shouldLaunchBrowser else branch to call setOpen() (to open the drawer) only when the browser launch fails or is not attempted.
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.

@github-actions
Copy link

Size Change: +125 B (0%)

Total Size: 24.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +125 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

@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 refactors the F12 key behavior for DevTools, prioritizing opening DevTools in a browser and providing correct closing behavior for the in-CLI drawer. While the security review agent was unable to perform a full audit due to an internal file reading error, no vulnerabilities were identified. The implementation in devtoolsService.ts, AppContainer.tsx, and devtoolsService.test.ts is clear, consistent, and thorough, successfully improving the user experience.

if (shouldLaunchBrowser()) {
try {
await openBrowserSecurely(url);
// Browser opened successfully, don't open drawer.
Copy link
Contributor

Choose a reason for hiding this comment

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

glad to see the draw not open.

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 b19b026 Feb 11, 2026
29 checks passed
@SandyTao520 SandyTao520 deleted the st/fix/f12-behavior branch February 11, 2026 17:57
krsjenmt added a commit to krsjenmt/gemini-cli that referenced this pull request Feb 12, 2026
…ini/gemini-cli (#37)

* fix(cli): resolve double rendering in shpool and address vscode lint warnings (google-gemini#18704)

* feat(plan): document and validate Plan Mode policy overrides (google-gemini#18825)

* Fix pressing any key to exit select mode. (google-gemini#18421)

* fix(cli): update F12 behavior to only open drawer if browser fails (google-gemini#18829)

* feat(plan): allow skills to be enabled in plan mode (google-gemini#18817)

Co-authored-by: Jerop Kipruto <jerop@google.com>

* docs(plan): add documentation for plan mode tools (google-gemini#18827)

* Remove experimental note in extension settings docs (google-gemini#18822)

* Update prompt and grep tool definition to limit context size (google-gemini#18780)

* docs(plan): add `ask_user` tool documentation (google-gemini#18830)

* Revert unintended credentials exposure (google-gemini#18840)

* feat(core): update internal utility models to Gemini 3 (google-gemini#18773)

* feat(a2a): add value-resolver for auth credential resolution (google-gemini#18653)

* Removed getPlainTextLength (google-gemini#18848)

* More grep prompt tweaks (google-gemini#18846)

* refactor(cli): Reactive useSettingsStore hook (google-gemini#14915)

* fix(mcp): Ensure that stdio MCP server execution has the `GEMINI_CLI=1` env variable populated. (google-gemini#18832)

* fix(core): improve headless mode detection for flags and query args (google-gemini#18855)

* refactor(cli): simplify UI and remove legacy inline tool confirmation logic (google-gemini#18566)

* feat(cli): deprecate --allowed-tools and excludeTools in favor of policy engine (google-gemini#18508)

* fix(workflows): improve maintainer detection for automated PR actions (google-gemini#18869)

* refactor(cli): consolidate useToolScheduler and delete legacy implementation (google-gemini#18567)

* Update changelog for v0.28.0 and v0.29.0-preview0 (google-gemini#18819)

* fix(core): ensure sub-agents are registered regardless of tools.allowed (google-gemini#18870)

---------

Co-authored-by: Brad Dux <959674+braddux@users.noreply.github.com>
Co-authored-by: Jerop Kipruto <jerop@google.com>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
Co-authored-by: Adib234 <30782825+Adib234@users.noreply.github.com>
Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: Christian Gunderman <gundermanc@gmail.com>
Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com>
Co-authored-by: Dev Randalpura <devrandalpura@google.com>
Co-authored-by: Pyush Sinha <pyushsinha20@gmail.com>
Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
Co-authored-by: Abhijit Balaji <abhijitbalaji@google.com>
Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
Co-authored-by: g-samroberts <158088236+g-samroberts@users.noreply.github.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
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