Skip to content

sessions: improve workspace preselection and telemetry - #335480

Merged
Benjamin Christopher Simmonds (benibenj) merged 4 commits into
mainfrom
agents/workspace-preselection-telemetry
Sep 10, 2026
Merged

sessions: improve workspace preselection and telemetry#335480
Benjamin Christopher Simmonds (benibenj) merged 4 commits into
mainfrom
agents/workspace-preselection-telemetry

Conversation

@benibenj

Copy link
Copy Markdown
Contributor

Summary

  • Make explicit workspace handoffs survive setup and late provider/view readiness, require acknowledgement from the target picker, and cancel stale requests when newer user intent wins. Offer Retry and Choose Workspace for failed explicit handoffs.
  • Suggest the invoking editor's folder for generic command and keyboard openings, using the active-file root in multi-root workspaces. Preserve existing sessions, restored drafts, input, attachments, No workspace, and explicit user choices.
  • Include folders from recent .code-workspace files, preserving history ordering, deduplication, filtering, and removal behavior. Bound file reads and handle unavailable providers, malformed files, remote paths, cancellation, and timeouts.
  • Extend agents/firstTimeWindowOpen with argument categories, selection provenance, readiness, handoff timing, and initial-versus-emission snapshots. Add agents/workspaceSelectionOutcome to measure default retention and first successful request, with focused regression tests and updated accessibility help.

Why

The opening source alone does not distinguish an existing-session handoff from a workspace request, and the legacy preselection flag cannot explain late defaults or their origin. This improves workspace selection without overriding user intent and adds diagnostics to evaluate usefulness rather than only the percentage of populated pickers.

Reviewer notes

  • Retain the existing event and legacy fields. New telemetry uses categorical state, booleans, and bounded timings/counts; no workspace identifiers or request content are emitted.
  • Workspace handoffs retry for up to 15 seconds after setup/restoration preparation. History expansion reads at most 10 workspace files, limited to 1 MiB each, with a shared five-second timeout.
  • Outcome observation applies to first-time eligible initial openings without an existing-session argument and ends at the first successful request, shutdown, or three minutes. A timeout without a request is not proof of permanent abandonment.

Validation

  • npm run precommit: passed for all 42 changed files.
  • npm run transpile-client: passed.
  • Focused unit tests: 288 passing across all 14 affected test files, using scripts\test.bat with --force-device-scale-factor=1 --reporter dot.
  • git diff --check: passed.
  • npm run gulp -- compile-client: blocked by the same three pre-existing Copilot SDK typing errors involving clientInfo in CopilotClientOptions and autoTier in CapiSessionOptions. Those source files are unchanged by this PR.
  • Real desktop sign-in/startup flow has not been manually exercised.

Suggested manual checks

  1. Open Agents from single-folder and multi-root editor windows. Verify fresh composers receive the appropriate folder while existing sessions and drafts remain intact.
  2. Complete initial setup with a pending explicit handoff, and verify delayed provider readiness applies it. Selecting another workspace or navigating to a new session should cancel the older request.
  3. Open with recent multi-root workspace history; verify folder selection, ordering, and that removed derived folders remain removed after restart.

Keep editor workspace handoffs alive until the target composer is ready while preserving newer user intent. Include multi-root workspace history and record selection provenance and first-request outcomes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 10, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Late restoration and untracked navigation paths can let stale workspace defaults override newer user state.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 1 Medium severity · 1 Low severity

New issues introduced by this change (3)
Severity Finding
High severity src/​vs/​sessions/​contrib/​chat/​browser/​agentsWindowWorkspaceHandoff.ts — Cancellation currently depends on every user-navigation path incrementing these ad hoc counters.…
Medium severity src/​vs/​sessions/​contrib/​chat/​browser/​newChatWidget.tshasRestoredDraft is a one-time snapshot, but this widget can be constructed before…
Low severity src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsWindowOpenTelemetry.ts — The implementation emits selectionNotApplied after acknowledgement times out, but this…
What changed in this PR

Improves Agents window workspace preselection, reliable handoffs, recent-workspace discovery, and related telemetry.

Changes:

  • Adds editor-context workspace defaults and resilient cross-process handoffs.
  • Expands recent .code-workspace entries with bounded reads and exclusions.
  • Adds selection provenance/outcome telemetry, accessibility guidance, and regression tests.
File Description
src/​vs/​platform/​native/​common/​native.ts Adds default-workspace handoff metadata.
src/​vs/​platform/​native/​electron-main/​nativeHostMainService.ts Forwards handoff metadata.
src/​vs/​platform/​windows/​electron-main/​windows.ts Propagates window-open workspace options.
src/​vs/​platform/​windows/​electron-main/​windowsMainService.ts Routes workspace defaults to Agents windows.
src/​vs/​sessions/​browser/​parts/​chatGroupView.ts Forwards workspace selection results.
src/​vs/​sessions/​browser/​parts/​chatGroupsView.ts Routes selection through active groups.
src/​vs/​sessions/​browser/​parts/​chatView.ts Defines selection acknowledgement contracts.
src/​vs/​sessions/​browser/​parts/​sessionView.ts Selects workspaces in the hosted composer.
src/​vs/​sessions/​common/​workspaceSelection.ts Defines selection provenance and diagnostics.
src/​vs/​sessions/​contrib/​chat/​browser/​agentsWindowOpenIntent.ts Classifies and resolves open arguments.
src/​vs/​sessions/​contrib/​chat/​browser/​agentsWindowWorkspaceHandoff.ts Implements retrying workspace handoffs.
src/​vs/​sessions/​contrib/​chat/​browser/​chat.contribution.ts Registers browser chat contributions.
src/​vs/​sessions/​contrib/​chat/​browser/​chatView.ts Exposes workspace selection routing.
src/​vs/​sessions/​contrib/​chat/​browser/​newChatInput.ts Exposes composer selection/input state.
src/​vs/​sessions/​contrib/​chat/​browser/​newChatWidget.ts Applies defaults while preserving user state.
src/​vs/​sessions/​contrib/​chat/​browser/​newSessionComposerService.ts Tracks active composer intent and requests.
src/​vs/​sessions/​contrib/​chat/​browser/​newSessionFolderQuickPickAction.ts Adds workspace-selection actions.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionWorkspacePicker.ts Tracks selection origin and history state.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionsChatAccessibilityHelp.ts Documents workspace behavior accessibly.
src/​vs/​sessions/​contrib/​chat/​browser/​voiceBridge.contribution.ts Reports voice-originated requests.
src/​vs/​sessions/​contrib/​chat/​electron-browser/​chat.contribution.ts Handles IPC handoffs and telemetry lifetime.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​agentsWindowOpenIntent.test.ts Tests argument classification.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​agentsWindowWorkspaceHandoff.test.ts Tests handoff retries and cancellation.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​chatView.test.ts Tests selection forwarding.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatWidget.fixture.ts Updates composer UI fixtures.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatWidget.test.ts Tests default-preservation behavior.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newSessionComposerService.test.ts Tests composer observation.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newSessionFolderQuickPickAction.test.ts Tests picker actions.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionWorkspacePicker.test.ts Tests provenance, history, and removal.
src/​vs/​sessions/​contrib/​chat/​test/​electron-browser/​agentsWindowWorkspaceHandoff.test.ts Tests Electron handoff wiring.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsActions.ts Records navigation and selection intent.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsWindowOpenTelemetry.ts Extends first-open telemetry.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsWorkspaceSelectionTelemetry.ts Adds selection-outcome telemetry.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsViewActions.ts Integrates workspace actions with views.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsActions.test.ts Tests session action intent tracking.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsWindowOpenTelemetry.test.ts Tests first-open telemetry snapshots.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsWorkspaceSelectionTelemetry.test.ts Tests outcome telemetry.
src/​vs/​sessions/​services/​sessions/​browser/​sessionsRecentWorkspacesService.ts Expands and filters recent workspaces.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionsRecentWorkspacesService.test.ts Tests bounded history expansion.
src/​vs/​sessions/​test/​browser/​sessionView.test.ts Tests workspace-selection forwarding.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​agentSessions/​agentSessionsActions.ts Infers invoking editor workspace.
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​agentSessionsActions.test.ts Tests editor-context inference.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/sessions/contrib/chat/browser/newChatWidget.ts Outdated
Comment thread src/vs/sessions/contrib/sessions/browser/sessionsWindowOpenTelemetry.ts Outdated
Cancel deferred workspace handoffs from central session navigation, including repeated opens of an empty composer, without cancelling their own opening or automatic draft creation.

Check live draft ownership before applying inferred defaults, wait for in-flight creation, and document the selectionNotApplied telemetry state. Add regression coverage for remote-folder navigation and late restoration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benibenj
Benjamin Christopher Simmonds (benibenj) marked this pull request as ready for review September 10, 2026 17:39
@vs-code-engineering

vs-code-engineering Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ulugbek Abdullaev (@ulugbekna)

Matched files:

  • src/vs/sessions/contrib/chat/browser/sessionWorkspacePicker.ts
  • src/vs/sessions/contrib/chat/test/browser/sessionWorkspacePicker.test.ts

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsRecentWorkspacesService.ts
  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsRecentWorkspacesService.test.ts

Preserve upstream archive-nudge and Dev Container changes alongside workspace preselection provenance, acknowledgement, and draft protections. Cover combined Dev Container mode and selection-origin behavior in regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep upstream removal of the temporary archive-nudge debug command while retaining workspace-preselection navigation tracking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit 5559183 into main Sep 10, 2026
53 of 54 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the agents/workspace-preselection-telemetry branch September 10, 2026 21:46
@vs-code-engineering vs-code-engineering Bot added this to the 1.138.0 milestone Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants