Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Sep 29, 2025

With the assumption that IDEs will not create a debug session for the widget previewer, the widget inspector's source navigation functionality won't function as there's no IDE to listen to navigate events sent via postEvent.

This change overrides some widget inspector behavior to allow for navigating to source locations via the DTD Editor service instead of relying on the VM service's postEvent.

This change also makes some minor changes to the diagnostic properties and descriptions displayed within the inspector to display group and custom preview annotation details.

Towards #166423

With the assumption that IDEs will not create a debug session for the
widget previewer, the widget inspector's source navigation functionality
won't function as there's no IDE to listen to `navigate` events sent via
`postEvent`.

This change overrides some widget inspector behavior to allow for
navigating to source locations via the DTD Editor service instead of
relying on the VM service's `postEvent`.

This change also makes some minor changes to the diagnostic properties
and descriptions displayed within the inspector to display group and
custom preview annotation details.

Towards #166423
@bkonyi bkonyi requested review from DanTup and elliette September 29, 2025 18:05
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 29, 2025
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 introduces a mechanism to forward widget inspector navigation events through the Dart Tooling Daemon (DTD), which is a great improvement for the widget previewer's developer experience, especially in IDEs without a debug session. The changes are well-structured, propagating the necessary source location information through the analysis and code generation phases to the scaffolded application. The introduction of PreviewWidgetElement and the custom _WidgetPreviewScaffoldInspectorService is a clean approach to intercept and handle navigation.

I've found one critical issue in the navigation event handling logic that could lead to a runtime crash, and I've provided a suggestion to fix it. Otherwise, the changes look solid and the new test case for inspector navigation is a valuable addition.

@DanTup
Copy link
Contributor

DanTup commented Sep 29, 2025

@bkonyi

With the assumption that IDEs will not create a debug session for the widget previewer

How sound is this assumption? (I asked because of the question below, and that we are already auto-attaching to the preview on Firebase Studio, so I don't think the idea of attaching to it is completely crazy - but I don't know what's already been thought about/discussed).

the widget inspector's source navigation functionality won't function

Which widget inspector do we mean here? The one that's embedded in the sidebar in Dart-Code is already quite tightly tied to a debug session, so if we're planning to connect that to the preview (and not have the preview be a debug session) then we might need to change some of these assumptions anyway.

(that's not to say it's not a good idea to switch this to DTD anyway, but it would be useful for me to better understand the end goals here)

Edit: To capture some offline discussion:

With the assumption that IDEs will not create a debug session for the widget previewer

We can't have a full debug session against the widget preview, because there's no ability to use the Chrome debug port or Dart debug extension, so actually it probably does not make sense to try and connect up a normal IDE debug session here.

Copy link
Contributor

@DanTup DanTup left a comment

Choose a reason for hiding this comment

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

I'm not terribly familiar with the widget inspector service code so I'll let you choose whether to wait for Elliot's review, but LGTM. I did add some minor nits, but nothing I think is necessary.

column: previewData.column,
);
}
final result = super.setSelection(object, groupName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a little awkward - would it be simpler to skip this call and just directly call super.postEvent() with this location instead? Or if we still need the other base code (setting the selection), what about making setSelection take an optional Location?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's definitely awkward, but super.setSelection needs to be called as there's a lot of other state that's updated as the result of a selection.

This code is called via a service extension, and DevTools doesn't know that there's anything special about the PreviewWidget, so we need to keep this logic contained within the previewer.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2025
Comment on lines +74 to +75
line: -1,
column: -1,
Copy link
Contributor

Choose a reason for hiding this comment

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

@bkonyi nit: there are a couple more of these 😄

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 30, 2025

autosubmit label was removed for flutter/flutter/176218, because - The status or check suite Mac build_ios_framework_module_test has failed. Please fix the issues identified (or deflake) before re-applying this label.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 30, 2025

autosubmit label was removed for flutter/flutter/176218, because - The status or check suite Mac build_ios_framework_module_test has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2025
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 30, 2025
Merged via the queue into master with commit 37487b3 Oct 1, 2025
159 checks passed
@auto-submit auto-submit bot deleted the widget_preview_inspector_jump_to_source branch October 1, 2025 00:28
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 1, 2025
…10160)

Manual roll requested by [email protected]

flutter/flutter@c9608e2...7811e89

2025-10-01 [email protected] Migrate to `WidgetStateTextStyle` (flutter/flutter#176330)
2025-10-01 [email protected] Migrate to `WidgetStateOutlinedBorder` (flutter/flutter#176270)
2025-10-01 [email protected] [win32] Runloop should use high resolution timer and avoid deadlock (flutter/flutter#176023)
2025-10-01 [email protected] Roll Packages from 287739d to 321a584 (3 revisions) (flutter/flutter#176357)
2025-10-01 [email protected] Add SwiftUI support for UIScene migration (flutter/flutter#176230)
2025-10-01 [email protected] Roll Skia from ecaff95f51aa to c44a36470d07 (4 revisions) (flutter/flutter#176336)
2025-10-01 [email protected] [native assets] Enable build hooks and code assets on stable (flutter/flutter#176285)
2025-10-01 [email protected] [native assets] Roll dependencies (flutter/flutter#176287)
2025-10-01 [email protected] Roll Dart SDK from 527333cfe4cf to 8ffec1435cf3 (1 revision) (flutter/flutter#176334)
2025-10-01 [email protected] Roll Skia from 6998b06397c5 to ecaff95f51aa (1 revision) (flutter/flutter#176333)
2025-10-01 [email protected] Update description in _LastFinderMixin to properly describe finding last (flutter/flutter#174232)
2025-10-01 [email protected] Roll Skia from b242cc09488d to 6998b06397c5 (2 revisions) (flutter/flutter#176331)
2025-10-01 [email protected] Roll Dart SDK from af31d2637b6b to 527333cfe4cf (17 revisions) (flutter/flutter#176325)
2025-10-01 [email protected] Stop using deprecated analyzer 7.x.y APIs. (flutter/flutter#176242)
2025-10-01 [email protected] Fix docs referencing deprecated radio properties (flutter/flutter#176244)
2025-09-30 [email protected] Roll Skia from bb3b6bd4be0d to b242cc09488d (22 revisions) (flutter/flutter#176320)
2025-09-30 [email protected] Roll Fuchsia Linux SDK from rcOl0yxJb4znJ903Y... to 1Ai6VL4vb_GdGnWhg... (flutter/flutter#176315)
2025-09-30 [email protected] Adds dart ui API for setting application level locale (flutter/flutter#175100)
2025-09-30 [email protected] replace `onPop` usage with `onPopWithResult` in `navigation_bar.2.dart ` (flutter/flutter#174841)
2025-09-30 [email protected] [ Widget Preview ] Forward Widget Inspector navigation events via DTD (flutter/flutter#176218)
2025-09-30 [email protected] Add verbose logs to module_uiscene_test_ios (flutter/flutter#176306)
2025-09-30 [email protected] Web semantics: Fix email field selection/cursor by using type="text" + inputmode="email" (flutter/flutter#175876)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah pushed a commit to okorohelijah/flutter that referenced this pull request Oct 7, 2025
…flutter#176218)

With the assumption that IDEs will not create a debug session for the
widget previewer, the widget inspector's source navigation functionality
won't function as there's no IDE to listen to `navigate` events sent via
`postEvent`.

This change overrides some widget inspector behavior to allow for
navigating to source locations via the DTD Editor service instead of
relying on the VM service's `postEvent`.

This change also makes some minor changes to the diagnostic properties
and descriptions displayed within the inspector to display group and
custom preview annotation details.

Towards flutter#166423
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…flutter#176218)

With the assumption that IDEs will not create a debug session for the
widget previewer, the widget inspector's source navigation functionality
won't function as there's no IDE to listen to `navigate` events sent via
`postEvent`.

This change overrides some widget inspector behavior to allow for
navigating to source locations via the DTD Editor service instead of
relying on the VM service's `postEvent`.

This change also makes some minor changes to the diagnostic properties
and descriptions displayed within the inspector to display group and
custom preview annotation details.

Towards flutter#166423
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants