Skip to content

chat: avoid redundant editor cloud sandbox discovery - #345710

Merged
Osvaldo Ortega (osortega) merged 1 commit into
mainfrom
osortega/agents/sandbox-refresh-load
Nov 3, 2026
Merged

Osvaldo Ortega (osortega) merged 1 commit into
mainfrom
osortega/agents/sandbox-refresh-load

Conversation

@osortega

Copy link
Copy Markdown
Contributor

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

Reuse the controller's initial refresh on registration instead of forcing another scan. Carry refresh intent through the sessions model so automatic lifecycle and voice-window refreshes can reuse fresh cloud inventory without throttling user refresh. Preserve coalesced manual refreshes and lazy item resolution, and distinguish startup, automatic, and manual discovery telemetry.

Related #345234

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 01:35

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.

🟢 Approval recommended

No active review issues remain for the scoped cloud sandbox discovery changes.

No open issues 🎉

What changed in this PR

This PR reduces redundant editor-triggered cloud sandbox discovery as a scoped follow-up to #345216 and #345234. It preserves explicit user Refresh behavior while leaving task hydration, cache persistence, and feed renewal unchanged.

Changes:

  • Reuse the controller’s registration refresh when reading session items, preserving lazy resolution and coalesced refresh requests.
  • Distinguish initial, automatic, and manual refreshes so automatic requests use existing freshness controls and manual requests take precedence.
  • Add discovery attribution and regression coverage for scan counts, refresh ordering, cancellation, focus, and freshness boundaries.

No actionable findings. Reported validation includes 608 passing Chromium tests; client type-checking remains blocked by two documented baseline SDK errors, and live UI/integration validation was not run.

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 reuse, attribution, cancellation, and freshness boundaries.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​remoteAgentHost/​cloudSandboxTelemetry.test.ts Verify distinct discovery trigger attribution.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatSessions/​chatSessionsService.test.ts Verify controller refresh reason dispatch.
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 internal refresh reasons.
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 in stale checks.
src/​vs/​workbench/​contrib/​chat/​browser/​chatSessions/​chatSessions.contribution.ts Forward refresh intent and identify registration refreshes.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsService.ts Mark model initialization as automatic.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsModel.ts Reuse registration results and preserve queued refresh intent.
src/​vs/​workbench/​contrib/​agentsVoice/​browser/​agentsVoiceWindowService.ts Mark voice-window polling as automatic.
src/​vs/​platform/​agentHost/​common/​cloudSandboxAgentHost.ts Add the bounded automatic discovery trigger.

Review effort: Balanced

@osortega Osvaldo Ortega (osortega) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Nov 3, 2026
@osortega
Osvaldo Ortega (osortega) marked this pull request as ready for review November 3, 2026 01:41
@vs-code-engineering

Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.145 when merged.

@osortega
Osvaldo Ortega (osortega) merged commit 498770f into main Nov 3, 2026
56 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the osortega/agents/sandbox-refresh-load branch November 3, 2026 02:47
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Nov 3, 2026
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels 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

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants