Skip to content

Managed settings: reuse cached policy more often - #333697

Merged
joshspicer merged 4 commits into
mainfrom
joshspicer/cache-managed-settings-reload
Sep 1, 2026
Merged

Managed settings: reuse cached policy more often#333697
joshspicer merged 4 commits into
mainfrom
joshspicer/cache-managed-settings-reload

Conversation

@joshspicer

@joshspicer joshspicer commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

On reload, DefaultAccountProvider restores cached policy from storage but still re-fetched /managed_settings even when we had a fresh (<1h) cache. This change continues to allow the 'ungoverned' (standard) path reuse a fresh cached response with no network round-trip (matching the sibling entitlements/token/MCP fetches, which only refetch once the 1-hour cache goes stale), so reloads within the window now make zero /managed_settings requests. The fail-closed forceRemoteSettingsRefresh path is unchanged: only a fresh successful response for the current account, provider, and endpoint clears the requirement.

Copilot AI balanced review requested due to automatic review settings September 1, 2026 00:53
@joshspicer joshspicer changed the title Managed settings: reuse cached policy on reload instead of refetching Managed settings: reuse cached policy more often 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.

Copilot review overview

Review tier: Balanced
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​vs/​workbench/​services/​accounts/​browser/​defaultAccount.ts — The cache-hit path no longer verifies managedSettingsScope. getScopedServerManagedSettings
Low severity src/​vs/​workbench/​services/​accounts/​browser/​defaultAccount.ts — This four-line inline comment exceeds the repository's comment convention and narrates the adjacent…
What changed in this PR

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

Changes:

  • Removes the per-process fetch gate.
  • Updates cache behavior and related unit tests.
File Description
defaultAccount.ts Reuses fresh cached managed settings.
defaultAccount.test.ts Updates cache and forced-refresh expectations.

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

Comment thread src/vs/workbench/services/accounts/browser/defaultAccount.ts Outdated
Comment thread src/vs/workbench/services/accounts/browser/defaultAccount.ts Outdated
@joshspicer
joshspicer force-pushed the joshspicer/cache-managed-settings-reload branch from 192191e to e042b4e Compare September 1, 2026 01:07
When forceRemoteSettingsRefresh is not effective, a fresh cached
managed-settings response now satisfies startup without a network
round-trip, matching the sibling entitlements/token/MCP fetches which
only refetch once the cache goes stale. Previously a per-process gate
(hasFetchedThisProcess) forced one /managed_settings request on every
reload even with a fresh cache and no policy requirement, which for a
user without an enterprise policy fanned out into one 404 per GitHub
session.

Cache reuse is scoped: a cached response is only reused when it was
captured for the current account, authentication provider, and endpoint
(a legacy cache with no recorded scope is trusted), so a previous GitHub
Enterprise host's policy is not applied after switching scopes.

An outstanding client_update_required compatibility error is never
served from cache: it is revalidated on the next refresh so the
fail-closed block clears once the client or server recovers, instead of
lingering for the full cache lifetime.

The fail-closed path is otherwise unchanged: when the control is
effective, only a fresh successful response for the current account,
provider, and endpoint clears the requirement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer
joshspicer force-pushed the joshspicer/cache-managed-settings-reload branch from e042b4e to 8a219be Compare September 1, 2026 01:27

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.

Copilot review overview

Review tier: Balanced
Findings: None

Issues resolved since last review (2)
Severity Finding
Low severity src/​vs/​workbench/​services/​accounts/​browser/​defaultAccount.ts — This four-line inline comment exceeds the repository's comment convention and narrates the adjacent… View resolved comment
Medium severity src/​vs/​workbench/​services/​accounts/​browser/​defaultAccount.ts — The cache-hit path no longer verifies managedSettingsScope. getScopedServerManagedSettingsView resolved comment

@joshspicer
joshspicer marked this pull request as ready for review September 1, 2026 01:35
@joshspicer
joshspicer enabled auto-merge (squash) September 1, 2026 01:40
@joshspicer joshspicer added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Sep 1, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer
joshspicer force-pushed the joshspicer/cache-managed-settings-reload branch from 6cbafc3 to 10f67ff Compare September 1, 2026 01:56
@joshspicer joshspicer removed the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Sep 1, 2026
@joshspicer
joshspicer disabled auto-merge September 1, 2026 02:47
Do not retain or relabel managed settings cached for a different account provider or endpoint when refresh fails or automatic retries are blocked.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer
joshspicer merged commit 7c90a55 into main Sep 1, 2026
37 checks passed
@joshspicer
joshspicer deleted the joshspicer/cache-managed-settings-reload branch September 1, 2026 03:21
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 1, 2026
Bhavya U (bhavyaus) pushed a commit that referenced this pull request Sep 1, 2026
* managed settings: reuse cached policy on reload instead of refetching

When forceRemoteSettingsRefresh is not effective, a fresh cached
managed-settings response now satisfies startup without a network
round-trip, matching the sibling entitlements/token/MCP fetches which
only refetch once the cache goes stale. Previously a per-process gate
(hasFetchedThisProcess) forced one /managed_settings request on every
reload even with a fresh cache and no policy requirement, which for a
user without an enterprise policy fanned out into one 404 per GitHub
session.

Cache reuse is scoped: a cached response is only reused when it was
captured for the current account, authentication provider, and endpoint
(a legacy cache with no recorded scope is trusted), so a previous GitHub
Enterprise host's policy is not applied after switching scopes.

An outstanding client_update_required compatibility error is never
served from cache: it is revalidated on the next refresh so the
fail-closed block clears once the client or server recovers, instead of
lingering for the full cache lifetime.

The fail-closed path is otherwise unchanged: when the control is
effective, only a fresh successful response for the current account,
provider, and endpoint clears the requirement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Trigger signed commit verification

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* managed settings: scope failure fallbacks

Do not retain or relabel managed settings cached for a different account provider or endpoint when refresh fails or automatic retries are blocked.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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