Skip to content

[Perf] chat: avoid cloud discovery on focus with a connected feed - #345897

Merged
roblourens merged 4 commits into
mainfrom
roblou/agents/cloud-sandbox-exp-check-1441
Nov 4, 2026
Merged

roblourens merged 4 commits into
mainfrom
roblou/agents/cloud-sandbox-exp-check-1441

Conversation

@roblourens

@roblourens roblourens commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Part of #345234.

Summary

Avoid redundant cloud inventory scans when a window gains focus.

  • Forward automatic intent from Chat's focus handler through AgentSessionsControl instead of treating focus as manual Refresh.
  • While the task-status feed is connected, skip freshness-gated cloud discovery for focus, host selection, and automatic UI refreshes. Without a connected feed, preserve stale-refresh and backoff behavior.
  • Keep explicit Refresh manual, including when it coalesces with automatic work. Preserve startup/account/configuration scans, targeted push invalidations, and feed renewal/reconnect catch-up.
  • Cover the view/control/model and connected/disconnected provider paths. Other providers and the Agents window's newer local-only catalogue refresh retain their behavior.

This PR does not change feed transport, renewal/reconciliation scheduling, polling intervals, or discovery APIs. The separate renewal/reconciliation implementation is not included.

Accepted Limits: Safety Refresh

The maintainer accepted the documented recovery limits for landing this scoped PR. The feed is best effort and incompletely covered: deletes/shares/pins never hint, and new/out-of-lease/organization tasks can be missed. A connected socket and successful rename/archive hints do not prove catalogue correctness.

Mandatory renewal and reconnect refetches remain intact. Connected-state scheduled polling was already suppressed before this PR; the broader gate removes additional focus/selection/UI refresh opportunities and increases reliance on renewal-driven recovery. The upstream contract explicitly leaves renewal-as-safety versus a separate slow timer open; this PR does not resolve that choice.

Renewal reads can be incremental and retain missing entries. Fifteen minutes is full-scan eligibility for a later triggered read, not a deadline. Healthy full-scan gaps can be around 21 minutes, and failures or scan duration can extend them. Complete results also preserve connected/provisioning environments.

Remaining recovery-policy and validation work (not completed or claimed by this PR):

  • Confirm the accepted safety-refresh interpretation and missing-entry freshness expectation, including failure retries and scan duration.
  • Deliberately drop a create/rename/archive hint and exercise a new/out-of-lease/organization task; verify recovery through required list reads without relying on focus.
  • Delete a task with no task.deleted hint; verify incremental absence retains it and a later successful complete full read removes it where appropriate. Pin the intended connected/provisioning retention behavior.
  • Verify partial/failed scans do not falsely establish completeness or remove unseen rows, and run equivalent recovery cases on main and release.

The existing callback/gating and direct-renewal tests do not establish end-to-end lost-hint/out-of-lease/delete recovery. No new timer or withdrawn renewal-suppression implementation is included.

How to Test

  1. In an authenticated Code OSS test profile, enable cloud sandboxes and let initial discovery and the task-status feed connect.
  2. Switch away and back with the feed connected, including after the normal freshness interval. Focus and automatic UI refreshes should not start cloud discovery; existing in-flight work is reused.
  3. Use the editor Chat sessions sidebar's Refresh Agent Sessions toolbar action. It should still start discovery with the feed connected.
  4. With the feed disabled/unavailable in the test profile, verify that focus can still refresh stale inventory.

Real-backend checks in isolated authenticated Code OSS profiles:

  • The initial focus-intent check observed four actual native focus-ins with no additional list requests while inventory was fresh.
  • With the real feed connected and the last discovery attempt 301,003 ms old, the actual focus/selection provider checks and sessions control's automatic refresh issued zero discovery scans/list attempts. Explicit toolbar Refresh still completed a full scan with 21 page attempts.
  • A real repo-less sandbox was discovered, opened through the UI, and replied OK without tool calls. All created test resources and run-owned validation instances were cleaned up.

The aged connected-feed check exercised the provider/control boundary under Playwright's focused-window environment; it is not native-OS-event proof. The earlier external-archive repair was attributed to fallback polling, not specifically stale focus. These bounded observations are not a production savings estimate.

(Written by Copilot)

Route window-focus session refreshes through the existing automatic freshness gate while preserving explicit Refresh and coalesced manual intent. Keep providers without a freshness policy and the Agents window's local catalogue refresh unchanged.

Related to #345234.

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

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

The review reports no active issues with the change to reduce unnecessary cloud sandbox discovery requests.

No open issues 🎉

What changed in this PR

This PR reduces unnecessary cloud sandbox discovery requests by marking Chat’s window-focus refreshes as automatic, allowing the provider’s existing freshness checks to apply.

Changes:

  • Forward refresh intent through the sessions control while keeping explicit Refresh manual.
  • Add regression coverage for focus handling, manual-refresh precedence, and providers without freshness policies.
  • Verify that the Agents window retains local-only catalogue refresh behavior.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widgetHosts/​viewPane/​chatViewPane.test.ts Tests automatic focus refreshes and manual toolbar refresh intent.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentSessionViewModel.test.ts Tests coalescing precedence and providers without freshness policies through the control.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentSessionsControl.test.ts Tests refresh-reason forwarding and the manual default.
src/​vs/​workbench/​contrib/​chat/​browser/​widgetHosts/​viewPane/​chatViewPane.ts Marks window-focus refreshes as automatic.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsModel.ts Exports the existing refresh-reason type for reuse.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsControl.ts Forwards refresh reasons to the model, defaulting to manual.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessions.ts Adds the optional refresh reason to the control interface.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsList.test.ts Tests repeated local-only catalogue refreshes.

Review effort: Balanced

Let a connected task-status feed supply cloud inventory updates instead of scanning on focus, host selection, or automatic UI refresh. Keep disconnected fallback, explicit Refresh, startup, targeted updates, and existing feed catch-up paths unchanged.

Related to #345234.

Co-authored-by: Copilot <[email protected]>
@roblourens roblourens changed the title [Perf] chat: respect automatic refresh intent on window focus [Perf] chat: avoid cloud discovery on focus with a connected feed Nov 3, 2026
Document incomplete feed coverage and renewal-driven inventory recovery without promising a fixed full-scan deadline. Keep catalogue-correctness readiness tied to the accepted safety-refresh policy and missed-change evidence.

Co-authored-by: Copilot <[email protected]>
Aaron Munger (amunger) pushed a commit that referenced this pull request Nov 3, 2026
)

* chat: backport connected-feed focus suppression (Written by Copilot)

Port #345897 to release/1.145, preserving automatic focus intent and suppressing automatic cloud scans while the task-status feed is connected. Keep explicit Refresh and disconnected fallback behavior.

Source commits: ad15031 and 7ba4e56. Adapt tests to the release branch's existing model and view contexts; no renewal/reconciliation implementation is included.

Co-authored-by: Copilot <[email protected]>

* docs: clarify release cloud recovery limits (Written by Copilot)

Document the release client's incomplete feed coverage and renewal-driven full-scan eligibility. Do not equate socket connectivity with a complete catalogue or promise a fifteen-minute recovery deadline.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
@roblourens
roblourens marked this pull request as ready for review November 4, 2026 02:25
@roblourens
roblourens enabled auto-merge (squash) November 4, 2026 02:25
@roblourens
roblourens merged commit 55f60fd into main Nov 4, 2026
59 checks passed
@roblourens
roblourens deleted the roblou/agents/cloud-sandbox-exp-check-1441 branch November 4, 2026 03:37
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 4, 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.

3 participants