Repository navigation
[cherry-pick] chat: avoid redundant editor cloud sandbox discovery - #345711
Conversation
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: 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 |
There was a problem hiding this comment.
🟡 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
a321b7c
into
release/1.145
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]>

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:
ChatSessionsServicealready 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.initial/automatic/manualreason 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.startup, automatic discovery asautomatic, and explicit refresh asmanualin 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
mainatae13a3ba2c63033f8c7ac81c9339433b48cf83d3, verified that the reviewed patch was unchanged, refreshed client output, and reran the focused suites: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.npm run typecheck-clientreports only the same two SDKkerberosAutherrors observed before these changes. No new diagnostics were introduced:src/vs/platform/agentHost/node/copilot/copilotAgent.ts(4426,5): TS2353,kerberosAuthis not inCopilotClientOptions.src/vs/platform/agentHost/test/node/copilotAgent.test.ts(14139,61): TS2339,kerberosAuthis not inCopilotClientOptions.git diff --cached --checkpassed 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:
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:
Changed-file ESLint — passed:
Client type-check — failed with only the two unchanged SDK baseline errors documented above:
Patch whitespace validation — passed before committing: