Add /idle endpoint for hosting platform idle tracking#13169
Open
isabelizimm wants to merge 2 commits intomainfrom
Open
Add /idle endpoint for hosting platform idle tracking#13169isabelizimm wants to merge 2 commits intomainfrom
isabelizimm wants to merge 2 commits intomainfrom
Conversation
Adds a /idle HTTP endpoint on the Positron server/REH build that hosting platforms (e.g. Posit Cloud) can query to determine how long the user has been idle. The response includes seconds_idle, last_activity_epoch_ms, and connected_clients. Activity signals originate from the existing IUserActivityService in the browser (DOM events: keydown, mousedown, touchstart). A new browser-side workbench contribution forwards activity timestamps to the server via a dedicated IPC channel. A new node-side service aggregates timestamps across connected clients (taking the most recent) and exposes the resulting idle info via the HTTP endpoint. Includes unit tests for the service and IPC channel pair. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the per-client Map<string, number> with a single monotonic lastActivityEpochMs. Drop the connectedClients field from the response, the clientId parameter from reportActivity, and the removeClient method. Rationale: the core signal (max activity timestamp across all clients) is naturally preserved by monotonic updates. Per-client tracking added complexity without meaningful benefit for Posit Cloud's use case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
E2E Tests 🚀 |
Contributor
Author
|
Copying comments from other PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening duplicate PR based off these instructions
BELOW COPIED FROM #13146
Summary
Adds a
/idleHTTP endpoint on the Positron server/REH build that Posit Cloud can query to determine how long the user has been idle.Architecture
The existing
IUserActivityServicekeeps track of DOM events (e.g.keydown,mousedown,touchstart. A new browser-side workbench contribution,PositronIdleReporterContribution, registers a callback to watch activity changes, upon which it forwards timestamps to a new IPC channel every 30s. A new service,PositronIdleTrackingService, keeps the most recent timestamp monotonically and exposes the result via the HTTP endpoint.Response format
Behavior notes
Since timestamps are sent every 30 seconds, the idle time may be reported up to 30s even while Positron is in use.
Opening a tab counts as activity for ~60-70s.
IUserActivityServiceinitializesisActive = trueon construction, treating the act of opening the window as an implicit activity signal (see the service's own comment). The bundledDomActivityTrackerthen verifies continued activity via DOM events: after 2 poll intervals (~60s) with nokeydown/mousedown/touchstart, plus a 10s debounce, it flips toisActive = false.In practice: if a user opens a tab and walks away without interacting,
seconds_idlewill report0for approximately 60-70 seconds before it begins to climb. This is expected and acceptable for session-management use cases where idle timeouts are on the order of minutes or hours, but it's worth noting for any consumer that expects sub-minute precision.Release Notes
New Features
Bug Fixes
QA Notes
@:sessions
This feature only activates in the server/REH build and requires Linux (license manager is Linux-only).
Automated tests
```bash
./scripts/test.sh --run src/vs/platform/positronIdleTracking/test/node/positronIdleTrackingService.test.ts
./scripts/test.sh --run src/vs/platform/positronIdleTracking/test/common/positronIdleTrackingIpc.test.ts
```
Manual verification (Linux only)
```bash
npm run build-start && npm run build-check
./scripts/code-server.sh --connection-token test-token --license-key-file /path/to/license.lic
```
```bash
curl -s "http://localhost:/idle?tkn=test-token" | jq .
```
🤖 Generated with Claude Code