Skip to content

Remember last selected debug device. #4332

Closed

Description

It would be great if the last selected device is remembered. Currently, you have to select the device every time after launching VS Code. It's annoying when you don't think about it after pressing F5 (run debug). In my case it always switches back to Windows desktop. But I want Chrome web.

screenshot

Activity

  1. ghost added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jan 6, 2023
  2. DanTup commented on Jan 9, 2023

    @DanTup
    Member

    Is this something you'd prefer was per-project, or global? Eg. if you select Chrome in one project and then start another one, would you expect it to also default to Chrome? (the flipside, is if you change that one project to Windows, it would change for the other one too).

  3. added this to the v3.58.0 milestone on Jan 9, 2023
  4. added
    in flutterRelates to running Flutter apps
    awaiting infoRequires more information from the customer to progress
    on Jan 9, 2023
  5. DanTup commented on Jan 16, 2023

    @DanTup
    Member

    Update: Selecting an Android emulator starts the emulator without starting debugging. This might be annoying. Maybe we need to change something here or ask before auto start.

    I think we would only auto-select devices. Unstarted emulators are not devices, but once started they will appear as devices (you can see the difference here by running flutter devices and flutter emulators.. an unstarted emulator only appears in the latter but a running emulator appears in both).

    So, we'd never auto-start an emulator, but if your preferred device was an emulator, when after you manually start it (or if it's already running) it would be selected.

    I was thinking we could add a setting (dart.flutterPreferredDevice?) that you could set in User or Workspace settings, and if this setting was enabled we'd just update/create that setting for you at both levels. However, many users check in workspace settings files so I'm not sure if that's a good place to put it.

    So instead, now I'm thinking we should store it somewhere else (extension context - although this is unfortunately invisible to the user) per-project so it just seems to remember the last device you used. We could optionally add a "preferred device" setting that is always user-configured and takes precedence if required. If that seems worthwhile, we can file a new issue and do that separately.

  6. DanTup commented on Jan 16, 2023

    @DanTup
    Member

    It occurs to me that this is slightly complicated by our auto-selection of mobile devices. Right now, if you connect a mobile device, we will automatically switch to it because we assume you connected it to start using.

    We can't really tell if you just connected a mobile device, or if it was connected when you opened VS Code, and it just took Flutter a short while to discover (since it searches for devices somewhat asynchronously). That means if we select a users preferred device and then a mobile device appears, we may switch to that. Perhaps we could skip that if the current selected device happens to be the previously-selected device (I think that's fairly understandable).

    I might try this out and see how it feels in a few cases.

  7. removed
    awaiting infoRequires more information from the customer to progress
    on Jan 16, 2023
  8. DanTup commented on Jan 16, 2023

    @DanTup
    Member

    I've done the above and it seems to work well in my testing. I'm going to ship this on by default, but it can be opted-out with the dart.flutterRememberSelectedDevice setting. I will likely publish a new pre-release build before the end of the week if you want to try this out before it ships to stable. You can switch to pre-release versions using the button here:

    Dart/Flutter pre-release versions

  9. DanTup commented on Jan 18, 2023

    @DanTup
    Member

    Pre-release versions have a date in the format YYYYMMDD in the last part of the version number (the current version is 3.57.20230104, release on 04 Jan 2023) so one with a newer date than today will include it.

    I'd been holding off doing the release because I was trying to land #4337 first, but it's held up a little on some Flutter changes so I'll likely publish a pre-release tomorrow that includes this. I'll ping here when I have as a reminder if you'd like to try it out. Thanks!

  10. DanTup commented on Jan 19, 2023

    @DanTup
    Member

    v3.57.20230119 has been published and includes this change. Please let me know if it works as you'd expect (flutterRememberSelectedDevice is enabled by default, so you shouldn't need to do anything). Thanks!

  11. DanTup commented on Jan 23, 2023

    @DanTup
    Member

    Great, thanks for testing!

  12. jonmountjoy commented on Jan 27, 2023

    @jonmountjoy

    Thank you so much for this - it was incredibly frustrating. 👏

  13. DanTup commented on Jan 27, 2023

    @DanTup
    Member

    Glad it's useful! If anything else is frustrating, please do file issues and don't suffer in silence! While I can't promise to address all frustrations quickly, sometimes there are simple fixes to things that have frustrated people for some time that I wasn't aware of (often because my testing is often quite contrived, and I don't work on any significant Flutter applications).

    Thanks!

  14. added a commit that references this issue on Sep 2, 2025
    3b1d9c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in flutterRelates to running Flutter appsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions