-
Notifications
You must be signed in to change notification settings - Fork 401
Hide extension button when embedded in an IDE #9956
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
base: master
Are you sure you want to change the base?
Changes from all commits
810a2f0
7e235a2
2fc3298
0f4a7f9
61fb530
cbdb186
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||
| --- | ||||||
| name: debugging-devtools-extensions | ||||||
| description: Guidelines and step-by-step workflow for debugging DevTools extensions locally, including stub mode, fixed-port launching, browser auto-opening, URL query parameters, target app connection, and human-in-the-loop interaction. Use when debugging or testing DevTools extension behavior. | ||||||
| --- | ||||||
|
|
||||||
| # Debugging DevTools Extensions | ||||||
|
|
||||||
| Follow this workflow to test and debug DevTools extensions locally. | ||||||
|
|
||||||
| ## 1. Local Stub Extensions Mode (No Server Needed) | ||||||
|
|
||||||
| When running DevTools in standalone web mode (`flutter run -d chrome`), DevTools does not run the `devtools_server` backend by default. To test extensions without a running server backend: | ||||||
|
|
||||||
| 1. Open [`packages/devtools_app/lib/src/shared/development_helpers.dart`](file:///Users/ryjohn/code/github/flutter/devtools/packages/devtools_app/lib/src/shared/development_helpers.dart#L57). | ||||||
| 2. Set `const _debugDevToolsExtensions = true;`. | ||||||
|
|
||||||
| > [!WARNING] | ||||||
| > Never commit `_debugDevToolsExtensions = true;` to git. A repository unit test (`development_helpers_test.dart`) enforces that this flag remains `false`. | ||||||
|
|
||||||
| Activating stub mode registers the following mock extensions: | ||||||
| - `foo_ext` (`package:foo`) | ||||||
| - `bar_ext` (`package:bar`) | ||||||
| - `provider_ext` (`package:provider`) | ||||||
|
|
||||||
| ## 2. Automated Launch & Browser Navigation | ||||||
|
|
||||||
| The agent can automate running DevTools AND launching the browser directly to the target URL: | ||||||
|
|
||||||
| ### Step 2a: Launch DevTools on a Fixed Port | ||||||
| In `packages/devtools_app`, launch DevTools specifying a fixed `--web-port`: | ||||||
| ```bash | ||||||
| flutter run -d chrome --web-port=52941 | ||||||
| ``` | ||||||
|
|
||||||
| ### Step 2b: Open Browser to Target URL Automatically | ||||||
| Use the system OS open command to launch Chrome/browser directly to the desired test URL: | ||||||
|
|
||||||
| - **macOS**: `open "http://localhost:52941/foo_ext?embedMode=one"` | ||||||
| - **Linux**: `xdg-open "http://localhost:52941/foo_ext?embedMode=one"` | ||||||
| - **Windows**: `start "http://localhost:52941/foo_ext?embedMode=one"` | ||||||
|
|
||||||
| ## 3. Testing Extension URLs & Embed Modes | ||||||
|
|
||||||
| Navigating to specific query parameters tests different extension UI states: | ||||||
|
|
||||||
| - **Single Extension Screen (`embedOne`)**: | ||||||
| `http://localhost:52941/foo_ext?embedMode=one` | ||||||
| *(Renders single extension view; puzzle piece icon IS visible in status bar)* | ||||||
|
|
||||||
| - **Extensions-Only View**: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| `http://localhost:52941/?hide=all-except-extensions&embedMode=many` | ||||||
| *(Renders only extension tabs; puzzle piece icon IS visible)* | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - **Standard Core Screen (`embedOne`)**: | ||||||
| `http://localhost:52941/inspector?embedMode=one` | ||||||
| *(Renders standard tool panel; puzzle piece icon IS HIDDEN)* | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## 4. Connecting to an End-User Target App | ||||||
|
|
||||||
| To test against real pub package extensions: | ||||||
|
|
||||||
| 1. Run the sample app in `packages/devtools_extensions/example/app_that_uses_foo`: | ||||||
| ```bash | ||||||
| cd packages/devtools_extensions/example/app_that_uses_foo | ||||||
| flutter run -d chrome | ||||||
| ``` | ||||||
| 2. Ask the user to copy/paste the VM Service URI from the terminal output (e.g. `ws://127.0.0.1:8181/xxx=/ws`). | ||||||
| 3. Open the browser automatically with the `uri` parameter: | ||||||
| ```bash | ||||||
| open "http://localhost:52941/foo_ext?embedMode=one&uri=<VM_SERVICE_URI>" | ||||||
| ``` | ||||||
|
|
||||||
| ## 5. Human Interaction & User Prompting Steps | ||||||
|
|
||||||
| When an AI agent is performing this workflow: | ||||||
|
|
||||||
| - **Obtaining VM Service URI**: When connecting to a target app, ask the user to provide the VM Service URI printed in the target app's console output (using `ask_question` or a direct prompt). | ||||||
| - **Automated Browser Opening**: The agent should launch DevTools and execute `open <url>` to launch the browser automatically. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. step 2B above gives other commands depending on the OS. Should we include those other commands here or link to where this is described above? |
||||||
| - **Manual Visual Verification**: Ask the user to inspect the opened browser window and confirm whether the expected extension UI or status bar button appears. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this may need to be changed. Not every interaction with debugging extensions is going to be related to the settings button like this particular bug |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,30 @@ class EmbeddedExtensionControllerImpl extends EmbeddedExtensionController | |
|
|
||
| String get extensionUrl { | ||
| if (debugDevToolsExtensions && !isDevToolsServerAvailable) { | ||
| return 'https://flutter.dev/'; | ||
| return 'data:text/html;charset=utf-8,${Uri.encodeComponent(''' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this change necessary? Seems like unnecessary work to maintain this custom html rather than just point to something hosted like flutter.dev
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I was testing locally, the extension didn't show the flutter.dev homepage because there's an HTTP header that prevents embedding it in DevTools properly (I was getting an error screen)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something we can/should address on the site's firebase config?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but I'd prefer to use this because it doesn't depend on the Flutter website having the right headers (We might change how the site is hosted or configured in the future and this would break again)=
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For anyone testing in the future it would be great to show something like this that indicates that the extension is being displayed properly, rather than showing flutter.dev or a broken iframe.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you put this String in a named const in this file |
||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <style> | ||
| body { | ||
| font-family: sans-serif; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| height: 100vh; | ||
| margin: 0; | ||
| background-color: #202124; | ||
| color: #e8eaed; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h3>DevTools Extension Placeholder (${extensionConfig.name})</h3> | ||
| <p>Local debugging placeholder view.</p> | ||
| </body> | ||
| </html> | ||
| ''')}'; | ||
| } | ||
|
|
||
| final basePath = devtoolsAssetsBasePath( | ||
|
|
||
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.