Skip to content

[flutter_tools] Ensure flutter daemon clients can detect preview device #140112

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

Merged
merged 17 commits into from
Dec 21, 2023

Conversation

christopherfujino
Copy link
Contributor

@christopherfujino christopherfujino commented Dec 14, 2023

Part of #130277

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 14, 2023
@christopherfujino christopherfujino force-pushed the upload-preview-artifact branch 2 times, most recently from 6ca846c to 1dd5162 Compare December 16, 2023 00:01
@christopherfujino christopherfujino changed the title [flutter_tools] Upload preview artifact [flutter_tools] Ensure flutter daemon clients can detect preview device Dec 16, 2023
@christopherfujino christopherfujino marked this pull request as ready for review December 16, 2023 00:03
@DanTup
Copy link
Contributor

DanTup commented Dec 19, 2023

@christopherfujino I'm still a little confused about what the platformType is intended to be here. In this code it's Windows:

https://github.com/flutter/flutter/blob/7171e3168d42f4dde118e8e2eba93f569e652db2/packages/flutter_tools/lib/src/preview_device.dart#L109

But in this code we're adding preview to the list of which platformTypes are supported:

https://github.com/flutter/flutter/blob/7171e3168d42f4dde118e8e2eba93f569e652db2/packages/flutter_tools/lib/src/commands/daemon.dart#L447-L449

If the intention is to use windows then I think that last bit is redundant?

However, I'm not sure whether using "windows" is the best option if we want to be able to conditionally show this per-project. We can't change which devices are available per-project, only filter by device-type. So the Preview device will always be sent to VS Code (when enabled) regardless of project capabilities, so if we want to be able to control its visibility (eg. to show it only when a project doesn't have plugins), I think it would need its own platform type.

For example maybe the preview device should have a platformType of windows-preview and then we conditionally return that from getSupportedPlatforms based on whether we know the project can run on the preview device or not?

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.

LGTM - I added some nits and maybe some tweaks to the structure of platformTypes in the response that I think might help improve things in the client.

@@ -416,36 +416,129 @@ class DaemonDomain extends Domain {
/// is correct.
Future<Map<String, Object>> getSupportedPlatforms(Map<String, Object?> args) async {
final String? projectRoot = _getStringArg(args, 'projectRoot', required: true);
final List<String> result = <String>[];
final List<String> platforms = <String>[];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we rename some of these variables (that aren't part of the API) platformType and/or add a comment to make it a bit clearer that almost all code here is platform types and not platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change this variable name, but I would add that--in my mind--the situation is far more confusing than just that we use the wrong terminology here.

I don't think the tool has a standardized concept of what exactly a target platform is. It is probably roughly something like operating system + device architecture, but it's complicated by for example the web (js vs WASM), the tester device, the preview device, and custom devices. In particular, there is a lot of complexity in the build_info.dart library: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_info.dart#L509

Similarly, even though we have an enum named PlatformType, I wouldn't call that a standardized concept in the tool.

}
if (!supportedPlatforms.contains(SupportedPlatform.linux)) {
isSupported = false;
reasons.add('the current Flutter project does not have a Linux platform directory');
Copy link
Contributor

Choose a reason for hiding this comment

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

Would something like "The Linux platform is not currently enabled for this project" read better? I'm thinking of when it's visible in the UI:

DEVICES

-------------------------------------------------------------------------- Available Devices
Chrome
Edge
-------------------------------------------------------------------------- Unavailable Devices
Enable Linux
The Linux platform is not currently enabled for this project
Enable macOS
The macOS platform is not enabled globally

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App 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