Skip to content

[cherry-pick] [cherry-pick] Managed settings: reuse cached policy more often - #333707

Open
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
cherry-pick/333704
Open

[cherry-pick] [cherry-pick] Managed settings: reuse cached policy more often#333707
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
cherry-pick/333704

Conversation

@vs-code-engineering

Copy link
Copy Markdown
Contributor

Cherry-pick of #333704 from release/1.136.

Cherry-pick of #333697 from main.

Summary

Reuse fresh, correctly scoped managed-settings cache entries during startup so window reloads do not re-fetch /copilot_internal/managed_settings for every signed-in GitHub session. Explicit refreshes, stale caches, scope changes, compatibility errors, and forceRemoteSettingsRefresh continue to require live requests.

Validation

  • 39 focused DefaultAccountProvider tests passed on release/1.136
  • Fresh cached 404: explicit sync made three requests; subsequent window reload made zero
  • Cache older than one hour re-fetched and renewed its timestamp
  • Forced-refresh policy still requested on reload and remained fail-closed on HTTP 500
  • Successful recovery fetched once; the following reload made zero requests

Copilot AI balanced review requested due to automatic review settings September 1, 2026 03:18
@vs-code-engineering vs-code-engineering Bot added the cherry-pick-artifact Auto-generated cherry-pick PR label Sep 1, 2026

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.

Pull request overview

Reuses fresh, scoped managed-settings cache entries to avoid redundant startup requests.

Changes:

  • Reuses eligible cached managed settings.
  • Preserves forced refresh, compatibility, staleness, and scope safeguards.
  • Expands focused cache behavior tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
defaultAccount.ts Updates cache reuse and scope validation.
defaultAccount.test.ts Tests caching, refresh, failures, and scope changes.

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

const cachedScope = accountPolicyData?.managedSettingsScope;
// Only reuse a cache captured for the current provider and endpoint (a legacy cache with no recorded
// scope is trusted), so a previous GitHub Enterprise host's policy is not applied after a scope switch.
const cacheScopeMatches = !cachedScope || this.getManagedSettingsScopeKey(cachedScope) === this.getManagedSettingsScopeKey(scope);
Comment on lines +99 to +102
// Without forceRefresh the fresh cache is served with no network round-trip.
const cached = await provider['getManagedSettings'](sessions, cachedPolicy);
// The forceRefresh command bypasses the fresh cache and fetches.
const forced = await provider['getManagedSettings'](sessions, cachedPolicy, { forceRefresh: true, retryManagedSettings: true });
Comment on lines +1170 to +1171
// When forceRemoteSettingsRefresh is effective, reuse also requires this scope's freshness to be
// satisfied; an outstanding compatibility error always forces revalidation.
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