Skip to content

Coder Workspace Lifecycle tie-in to Desktop App #157

Description

@diranged

I'd love a way to configure a Coder workspace (not all of them) to track the lifecycle status of my laptop... So when I open my laptop in the morning, my workspace immediately begins launching. When I close my laptop at lunch, the Coder workspace starts shutting down (with some configurable delay). Re-open my laptop after lunch or after some train ride, workspace immediately begins launching. This would not only give us some cost savings, but I think improve the experience for developers when they're starting their day.

Activity

  1. matifali commented on May 12, 2025

    @matifali

    This is a nice use case, but it could affect the workspace if it's meant to run long-running builds or tasks. So, this could be opt-in on a per-workspace basis.

    A good one to add to a dedicated workspace settings page.

  2. added theissue type on May 12, 2025
  3. diranged commented on May 14, 2025

    @diranged
    Author

    I agree that this would definitely an opt-in behavior for users. I also think it would include a "sleep timer" ... so I could say "turn it off after my laptop has been asleep for 30m" or something, so that momentary sleeps don't matter. Ideally it would also be able to use a hook from MacOS to know when the lid has been cloesd or sleep has happened, rather than just some network-disconnect behavior.

  4. diranged commented on May 24, 2025

    @diranged
    Author

    @matifali,
    Did something happen in 0.4.1 that was aimed at doing this? My Coder environments are now not sleeping anymore even when my laptop goes to sleep. I've tracked it down to either Coder Desktop running, or VSCode still running...

  5. ethanndickson commented on May 27, 2025

    @ethanndickson
    Member

    My Coder environments are now not sleeping anymore even when my laptop goes to sleep. I've tracked it down to either Coder Desktop running, or VSCode still running...

    I don't have a great understanding of how we bump autostop in response to activity, but it looks like just having Coder Desktop running is enough to bump the Last Used time of a workspace:

    Image

    I honestly thought this wasn't the case, so if that's what's used for Autostop, that would make sense.

    Did something happen in 0.4.1 that was aimed at doing this?

    But alas, no. The only potentially relevant change would be #151 which was added in 0.4.0.

  6. matifali commented on May 27, 2025

    @matifali

    I don't have a great understanding of how we bump autostop in response to activity

    We track any workspace <--> client network traffic as activity, and that prevents auto stop.

    , but it looks like just having Coder Desktop running is enough to bump the Last Used time of a workspace:

    @ethanndickson, what happens when the device is sleeping? Does Coder Desktop or the OS keep trying to make connections?

  7. ethanndickson commented on May 27, 2025

    @ethanndickson
    Member

    What happens when the device is sleeping? Does Coder Desktop or the OS keep trying to make connections?

    Yeah if it's enabled Coder Connect will try to connect indefinitely.

    EDIT: Also, macOS intermittently connects to the internet (if available) whilst the lid is closed to receive network events.

  8. matifali commented on May 27, 2025

    @matifali

    Can we have a setting where Coder Connect does not try to connect if the device is in a sleep state, like when the lid is closed?

  9. ethanndickson commented on May 27, 2025

    @ethanndickson
    Member

    Potentially? The approach we reverted in #151 doesn't work, as macOS tells the VPN to wake even when the lid is closed (as it sends wake events when checking for network updates). We'd need to use some other macOS API to check if the screen is off. We might be better off addressing this on the coderd side.

  10. ethanndickson commented on May 29, 2025

    @ethanndickson
    Member

    it looks like just having Coder Desktop running is enough to bump the Last Used time of a workspace

    This isn't true, I just had a mutagen sync session (configured outside of Coder Desktop) running in the background causing the Last Used to constantly update, and preventing my workspace's autostop. Having any SSH connection (incl. file sync) to your workspace will bump the Last Used timestamp. Just having Coder Connect running isn't enough to bump it.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions