Skip to content

[cherry-pick] chat: avoid redundant editor cloud sandbox discovery - #345711

Merged
Osvaldo Ortega (osortega) merged 1 commit into
release/1.145from
cherry-pick/345710
Nov 3, 2026
Merged

Osvaldo Ortega (osortega) merged 1 commit into
release/1.145from
cherry-pick/345710

Conversation

@vs-code-engineering

Copy link
Copy Markdown
Contributor

Cherry-pick of #345710 from main.

Related to #345234; follow-up to #345216. This is a scoped, partial improvement, not a resolution of every discovery-load source.

Summary

Remove two sources of redundant editor-triggered cloud sandbox discovery without throttling explicit user Refresh:

  • Reuse registration's initial refresh. ChatSessionsService already starts the controller refresh and waits for it when reading items. The sessions model now reads those items instead of requesting another refresh. Coalesced refresh requests and lazy item resolution are preserved.
  • Distinguish automatic and manual refresh intent. Carry an optional internal initial / automatic / manual reason through controller dispatch. Model initialization, availability/workspace/trust changes, and the voice window's three-second refresh loop are automatic. The cloud controller routes only automatic calls through its existing freshness, focus, in-flight coalescing, and backoff rules. Initialization and user Refresh bypass the freshness gate; manual intent wins when requests coalesce.
  • Attribute initialization as startup, automatic discovery as automatic, and explicit refresh as manual in the existing bounded discovery telemetry. No new telemetry event or measurement field, configuration setting, extension-host RPC, or AHP contract is introduced.

The regression scenario with initialization plus ten three-second automatic refreshes now performs 1 discovery scan instead of 11. A subsequent explicit Refresh performs a second scan and observes updated session data. This is a controlled test result, not an estimate of production-wide request reduction.

Scope

This draft contains only the two completed editor fixes. Agents-window startup rediscovery and healthy feed-renewal reconciliation remain separate follow-ups. Task-list pagination, task-detail hydration, cache persistence, and feed renewal/reconnect behavior are unchanged.

Validation

Fast-forwarded to main at ae13a3ba2c63033f8c7ac81c9339433b48cf83d3, verified that the reviewed patch was unchanged, refreshed client output, and reran the focused suites:

  • 608 Chromium tests passed, with 13 pre-existing skipped tests. Coverage includes registration while initialization is pending/complete, lazy item resolution, refresh precedence, automatic/manual attribution, repeated refresh scan counts with the feed enabled/disabled, in-flight coalescing, cancellation, unfocused initialization/manual refresh, and exact five-minute/fifteen-minute freshness boundaries with session removal/addition.
  • ESLint passed for all 13 changed TypeScript files. These files and the lint configuration were unchanged by the fast-forward.
  • Client transpilation passed. Initial output was built with npm run transpile-client; subsequent changes were compiled with the existing incremental helper. The final refresh below compiled 34 changed source files, including the upstream changes.
  • Type-check did not pass: npm run typecheck-client reports only the same two SDK kerberosAuth errors observed before these changes. No new diagnostics were introduced:
    • src/vs/platform/agentHost/node/copilot/copilotAgent.ts(4426,5): TS2353, kerberosAuth is not in CopilotClientOptions.
    • src/vs/platform/agentHost/test/node/copilotAgent.test.ts(14139,61): TS2339, kerberosAuth is not in CopilotClientOptions.
  • git diff --cached --check passed before committing.

The normal build/test bootstrap was blocked by the configured feed returning 404 for the pinned pnpm distribution. Validation used the existing transpiler and browser runner without changing dependency manifests, registry configuration, or authentication. Full integration/smoke suites and live UI validation were not run.

Exact local validation commands and results

Initial client output — passed:

npm run transpile-client

Final incremental client output refresh — passed, 34 source files:

node --input-type=module -e "import { execFileSync } from 'node:child_process'; import { applyIncrementalClientChanges } from './build/next/transpile.ts'; const files = execFileSync('git', ['diff', '--name-only', '763ca42b86dc21577554c6efd7526903dce082e4', '--', 'src'], { encoding: 'utf8' }).trim().split('\n').filter(Boolean); await applyIncrementalClientChanges(process.cwd(), 'out', files); console.log('Refreshed client output for ' + files.length + ' changed source files.');"

Focused regression suites — 608 passed, 13 pre-existing skipped:

npm run test-browser-no-install -- \
  --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentSessionViewModel.test.ts \
  --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentSessionsOpener.test.ts \
  --run src/vs/workbench/contrib/chat/test/browser/chatSessions/chatSessionsService.test.ts \
  --run src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/editorCloudSandboxContribution.test.ts \
  --run src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxTelemetry.test.ts \
  --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/cloudSandboxAgentHostContribution.test.ts \
  --browser chromium --reporter dot

Changed-file ESLint — passed:

npm run eslint -- \
  src/vs/platform/agentHost/common/cloudSandboxAgentHost.ts \
  src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.ts \
  src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.ts \
  src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.ts \
  src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts \
  src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.ts \
  src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.ts \
  src/vs/workbench/contrib/chat/common/chatSessionsService.ts \
  src/vs/workbench/contrib/chat/test/browser/agentSessions/agentSessionViewModel.test.ts \
  src/vs/workbench/contrib/chat/test/browser/chatSessions/chatSessionsService.test.ts \
  src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxTelemetry.test.ts \
  src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/editorCloudSandboxContribution.test.ts \
  src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts

Client type-check — failed with only the two unchanged SDK baseline errors documented above:

npm run typecheck-client

Patch whitespace validation — passed before committing:

git diff --cached --check

Copilot AI balanced review requested due to automatic review settings November 3, 2026 02:49
@vs-code-engineering vs-code-engineering Bot added the cherry-pick-artifact Auto-generated cherry-pick PR label Nov 3, 2026

Copilot AI commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Setup pnpm

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

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.

🟡 Changes recommended

A queued refresh can consume a manual caller’s refresh intent without propagating errors, allowing session resolution to continue after a failed refresh.

1 open issue
What changed in this PR

This cherry-pick reduces redundant cloud sandbox discovery in the editor, building on #345216 toward #345234 without throttling explicit user Refresh. Startup detail hydration and Agents-window discovery remain outside scope.

Changes:

  • Reuse the controller’s registration refresh when reading newly registered providers.
  • Carry initial, automatic, and manual refresh intent through session services, applying freshness checks only to automatic cloud discovery.
  • Extend regression coverage for coalescing, discovery counts, freshness boundaries, cancellation, and telemetry attribution.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​common/​mockChatSessionsService.ts Forward refresh reasons in the test service.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​remoteAgentHost/​editorCloudSandboxContribution.test.ts Test discovery frequency, intent, freshness, and cancellation.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​remoteAgentHost/​cloudSandboxTelemetry.test.ts Verify distinct discovery attribution.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatSessions/​chatSessionsService.test.ts Verify controller refresh reasons.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentSessionViewModel.test.ts Cover registration reuse, lazy resolution, and refresh precedence.
src/​vs/​workbench/​contrib/​chat/​common/​chatSessionsService.ts Define optional refresh intent in service contracts.
src/​vs/​workbench/​contrib/​chat/​browser/​remoteAgentHost/​editorCloudSandboxContribution.ts Route automatic refreshes through freshness checks.
src/​vs/​workbench/​contrib/​chat/​browser/​remoteAgentHost/​cloudSandboxSessionContribution.ts Accept automatic discovery attribution.
src/​vs/​workbench/​contrib/​chat/​browser/​chatSessions/​chatSessions.contribution.ts Dispatch initial and requested refresh reasons.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsService.ts Mark model initialization as automatic.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsModel.ts Separate item rereads from refreshes and preserve queued intent.
src/​vs/​workbench/​contrib/​agentsVoice/​browser/​agentsVoiceWindowService.ts Mark periodic voice-window refreshes as automatic.
src/​vs/​platform/​agentHost/​common/​cloudSandboxAgentHost.ts Add the bounded automatic discovery trigger.

Review effort: Balanced

@osortega
Osvaldo Ortega (osortega) merged commit a321b7c into release/1.145 Nov 3, 2026
55 of 56 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the cherry-pick/345710 branch November 3, 2026 03:09
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Nov 3, 2026
Osvaldo Ortega (osortega) added a commit that referenced this pull request Nov 3, 2026
A queued resolution can consume a later manual refresh before that caller's debounce expires. Keep refresh intent and errors in the same batch so callers observe the right failure even when a later request replaces their delayed task. Do not execute an already consumed batch again.

Add regressions for overlapping queues, a later successful refresh, and exactly-once error delivery to coalesced callers. Follow-up to #345710 and the review on #345711; related #345234.

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-artifact Auto-generated cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants