Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion images/jupyterlab/vscode-activity-reporter/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ function activate(context) {
on(vscode.workspace.onDidChangeTextDocument, "edit");
on(vscode.window.onDidChangeTextEditorSelection, "selection");
on(vscode.window.onDidChangeTextEditorVisibleRanges, "scroll");
on(vscode.window.onDidChangeWindowState, "focus");
// Not via on(): only transitions INTO focused/active are interaction.
// The event also fires on blur and when the window goes inactive after
// a stretch of no input; counting those would extend an idle session.
context.subscriptions.push(
vscode.window.onDidChangeWindowState((s) => {
if (s.focused || s.active) {
recordActivity("focus");
}
}),
);
on(vscode.window.onDidOpenTerminal, "terminal-open");
// Not via on(): the close handler needs the terminal argument to clear
// its busy bit — disposal is the one end-of-execution path that never
Expand Down
5 changes: 4 additions & 1 deletion images/jupyterlab/vscode-activity-reporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"displayName": "Nebari Activity Reporter",
"description": "Reports real user interaction to the Jupyter server so idle culling works correctly with VS Code (nebari-dev/data-science-pack#208).",
"publisher": "nebari",
"version": "0.1.0",
"version": "0.1.1",
"license": "BSD-3-Clause",
"engines": { "vscode": "^1.93.0" },
"categories": ["Other"],
"activationEvents": ["onStartupFinished"],
"main": "./extension.js",
"capabilities": {
"untrustedWorkspaces": { "supported": true }
},
"contributes": {}
}
31 changes: 31 additions & 0 deletions tests/unit/test_activity_reporter_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""The activity-reporter extension manifest must keep it running in
VS Code's Restricted Mode.

code-server opens the user's home in Restricted Mode until they click
Trust, and VS Code disables any extension that doesn't declare
untrusted-workspace support. The proxy opt-out in
images/nebi/jupyter_server_config.py only checks that the extension is
installed, so a disabled reporter means VS Code traffic stops counting as
activity AND nothing reports real interaction: an actively-working user
gets culled at shutdownNoActivityTimeout.
"""

from __future__ import annotations

import json
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parents[2]
MANIFEST = (
REPO_ROOT / "images" / "jupyterlab" / "vscode-activity-reporter" / "package.json"
)


def test_reporter_supports_untrusted_workspaces():
pkg = json.loads(MANIFEST.read_text())
untrusted = pkg.get("capabilities", {}).get("untrustedWorkspaces", {})
assert untrusted.get("supported") is True, (
"nebari-activity-reporter must declare "
"capabilities.untrustedWorkspaces.supported=true, or VS Code disables "
"it in Restricted Mode and working users get idle-culled"
)
Loading