accounts: avoid more redundant managed settings requests - #333823
Conversation
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/vs/workbench/services/accounts/browser/defaultAccount.ts — preserveManagedSettingsCache is ineffective in the real refresh path when… |
What changed in this PR
Reduces redundant managed-settings requests during account and entitlement refreshes.
Changes:
- Adds managed-settings cache preservation for entitlement refreshes.
- Deduplicates matching authentication sessions.
- Stops session fallback after managed-settings
404responses.
| File | Description |
|---|---|
src/vs/platform/defaultAccount/common/defaultAccount.ts |
Adds refresh options for cache preservation and retries. |
src/vs/workbench/services/accounts/browser/defaultAccount.ts |
Updates caching, session matching, and request fallback. |
src/vs/workbench/services/accounts/test/browser/defaultAccount.test.ts |
Tests caching, deduplication, and 404 handling. |
src/vs/workbench/services/chat/common/chatEntitlementService.ts |
Preserves managed-settings cache during entitlement refresh. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fec1225 to
71089f4
Compare
5f4c4b7 to
23ff2fe
Compare
|
Completed a deterministic Passed scenarios
Transport caveatAn immediate socket reset produced one application-level Full evidence: session launch validation report. |
23ff2fe to
cf605df
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/vs/workbench/services/accounts/browser/defaultAccount.ts — preserveManagedSettingsCache is ineffective in the real refresh path when… View comment |
Preserve a fresh managed-settings cache during entitlement refreshes, deduplicate authentication sessions that match overlapping scope alternatives, and treat a managed-settings 404 as a final no-policy result. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the managed-settings cache exception with explicit refresh targets. Chat entitlement updates now force only account entitlements, while policy sync and retry actions force only managed settings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep only the entitlement and managed-settings refresh modes used by production callers. Remove the general target enum, all mode, helper, and unused token and MCP refresh parameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restore forceRefresh as a simple all-account-data boolean. Normal chat and managed-settings source updates now use ordinary cache-aware refreshes; only explicit policy sync and retry actions force all caches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep quota and upgrade checks fresh without forcing unrelated default-account caches. The all-or-nothing forceRefresh boolean remains reserved for explicit policy sync and retry actions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise the full account refresh path with a scoped, satisfied forceRemoteSettingsRefresh cache. Verify entitlement refresh requests only entitlement data and preserves satisfied managed-settings freshness before full force refresh. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restore unrelated test wording and retry documentation, inline the managed-settings force check, and narrow the governed entitlement regression to the behavior under review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6286fb1 to
39f097e
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation preserves fail-closed policy behavior and has appropriate regression coverage.
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
src/vs/workbench/services/accounts/browser/defaultAccount.ts — preserveManagedSettingsCache is ineffective in the real refresh path when… View resolved comment |
|
Re-ran the full deterministic E2E matrix on the current reduced head
Result: 16 exact passes, 1 pass with the documented Chromium transport caveat. All mock wiring, processes, profiles, and caches were cleaned afterward; the worktree remains clean. |
|
Completed a controlled endpoint-load A/B between the exact pre-PR merge base
Endpoint-level result:
Key hot-reload comparison:
Key governed-500 comparison after equal settled windows:
The release cherry-pick #333863 has the same stable production patch ID ( |

Summary
forceRefreshas a simple boolean that bypasses every default-account cache404as the final cacheable no-policy result instead of retrying other sessions401authentication fallback and fail-closed forced-freshness behaviorWhy
A workbench reload could turn one managed-settings lookup into four sequential GETs. A chat entitlement update was forcing all account data to refresh, one GitHub session was selected once per matching scope alternative, and the shared request helper retried
404responses as though they indicated a bad token.The refresh contract remains simple: normal operation honors fresh caches;
forceRefresh: truerefreshes everything and is reserved for explicit policy sync/retry actions. Quota dashboards, quota reset checks, and upgrade flows explicitly refresh only entitlement data so they do not remain stale for up to one hour or invalidate unrelated caches.Launch validation
Using an isolated authenticated Code OSS Dev profile:
/copilot_internal/user; token, MCP, and managed-settings caches were reusedCouncil review
GPT-5.5, Claude Opus 4.6, and GPT-5.3-Codex unanimously found that making
forceResolveEntitlementfully cache-aware would regress quota-reset, dashboard, and post-upgrade freshness for up to one hour. The current implementation fixes that with a single entitlement-only refresh option and focused regression coverage.Validation
npm run hygienenpm run compile(zero errors)npm run valid-layers-check./scripts/test.sh --run src/vs/workbench/services/accounts/test/browser/defaultAccount.test.ts --run src/vs/workbench/services/chat/test/common/chatEntitlementService.test.ts --run src/vs/workbench/services/policies/test/browser/accountPolicyGateContribution.test.ts(59 passing)