Skip to content

Coder Workspace Lifecycle tie-in to Desktop App #157

@diranged

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

matifali

matifali commented on May 12, 2025

@matifali
Member

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.

added theissue type on May 12, 2025
diranged

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.

diranged

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...

ethanndickson

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.

matifali

matifali commented on May 27, 2025

@matifali
Member

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?

ethanndickson

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.

matifali

matifali commented on May 27, 2025

@matifali
Member

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?

ethanndickson

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.

ethanndickson

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

        Participants

        @diranged@matifali@ethanndickson

        Issue actions

          Coder Workspace Lifecycle tie-in to Desktop App · Issue #157 · coder/coder-desktop-macos