vscode-coder icon indicating copy to clipboard operation
vscode-coder copied to clipboard

Intelligently detect activity in the IDE

Open stirby opened this issue 1 year ago • 1 comments

We count any connected VSCode session as workspace activity. This is limiting because when a minimized tab of VSCode is connected or when a laptop is left on overnight, the activity bump keeps workspaces alive. This also deteriorates the accuracy of template insights.

One option is autostop requirement, but customers have noted that this not sufficient in all cases. For example, some templates occasionally need workspaces to stay alive overnight for long-running jobs. Autostop requirement is too aggressive of a system in these scenarios.

We should investigate a way to detect user activity more intelligently in VSCode and close connections when the user is not "active" in the IDE. This would make the activity-based autostop system more accurate and reliable.

I found an active property on the window object in the API. Not sure if it can be used for this purpose, just a starting point.

stirby avatar Sep 29 '24 18:09 stirby

There are a few ways to detect this based on what counts as an activity (essentially subscribe to most/all onDid* events):

  • window.onDidChangeActiveTextEditor/onDidChangeActiveNotebookEditor: Users are switching editors
  • window.onDidChangeWindowState: Focus in or out of windows
  • onDidChangeActiveTerminal: switching terminals (or focus in or out)
  • onDidChangeTextEditorSelection/onDidChangeNotebookEditorSelection: Changing the cursor position in a text editor
  • Track the open tabs

It makes sense to also show a notification to the user so they can essentially "snooze" the shutdown.

EhabY avatar Nov 10 '25 15:11 EhabY