Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
matifali commentedon May 12, 2025
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.
diranged commentedon May 14, 2025
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 commentedon May 24, 2025
@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 commentedon May 27, 2025
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:
I honestly thought this wasn't the case, so if that's what's used for Autostop, that would make sense.
But alas, no. The only potentially relevant change would be #151 which was added in
0.4.0
.matifali commentedon May 27, 2025
We track any workspace <--> client network traffic as activity, and that prevents auto stop.
@ethanndickson, what happens when the device is sleeping? Does Coder Desktop or the OS keep trying to make connections?
ethanndickson commentedon May 27, 2025
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 commentedon May 27, 2025
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 commentedon May 27, 2025
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 commentedon May 29, 2025
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.