mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-05 04:04:10 +01:00
* policy: add managed-settings freshness contract
Groundwork for making `forceRemoteSettingsRefresh` a real fail-closed
startup gate (microsoft/vscode-internalbacklog#8825). Contract only — no
behavior change, and nothing gates on freshness yet.
Adds `managedSettingsFreshness.ts`, declaring the state machine shared by
the fetch path, the policy gate and Policy Diagnostics so those consumers
cannot drift: `NotRequired` / `Pending` / `Satisfied` / `Blocked`, the
failure categories every inability-to-refresh maps to, and scoping by
account + provider + endpoint so satisfaction is never transferable
across accounts or GHE hosts.
Replaces `shouldForceRemoteSettingsRefresh` with
`resolveForceRemoteSettingsRefresh`, which resolves through
`pickManagedSettings` instead of re-implementing precedence. Two fixes
fall out: the file channel now participates (the old helper read only
native MDM and server, silently ignoring managed-file delivery), and an
explicit managed `false` is now distinguishable from an absent value,
which a later change needs in order to know when the requirement may be
cleared.
The old helper had no production caller — it was left orphaned when
661f18fdeb reworked the managed-settings fetch — so this is inert.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* policy: enforce freshness invariants in the type
Address PR feedback: `IManagedSettingsFreshness` was a bag of optional
fields, so a consumer could construct `Blocked` with no failure,
`Satisfied` with no scope, or attach `httpStatus`/`retryAfter` to states
where they mean nothing — leaving the fetch, gate and diagnostics
consumers free to drift despite the type.
Models it as a discriminated union instead, so each active state requires
the fields its contract defines. `Blocked` is itself a union keyed on the
failure category, so a status code is required for an HTTP error, a
backoff deadline for rate limiting, and neither is accepted elsewhere.
`source` is now the shared `ManagedSettingsChannel` rather than `string`,
and is required on the effective states, which also encodes that it is
never `'none'` once a channel has supplied the control.
Adds `@ts-expect-error` coverage for the three rejected shapes: the
directives fail the build if any shape becomes constructible again.
`isSameManagedSettingsFreshnessScope` is now a private helper with
required arguments — the union guarantees a scope is present, so its
undefined-tolerance was unreachable, and nothing outside this module
used it.
Also trims two over-long comments flagged in review.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: fail closed on forced managed settings refresh
Require a fresh managed-settings response before enabling AI features when forceRemoteSettingsRefresh is effective. Preserve recovery through sign-in and retry, expose diagnostics, and cover native, server, file, failure, scope, and sign-out behavior.
Related to microsoft/vscode-internalbacklog#8825.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: tighten managed settings recovery UX
Re-render the Agents window when freshness failure details change and preserve startup notification deferral.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: address managed settings review feedback
Scope cached server controls before precedence, avoid expired rate-limit poll loops, and align update-required recovery guidance across workbench and Agents window UI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: await explicit managed settings recovery refresh
Classic web initialization intentionally skips the default-account fetch. Exercise the explicit refresh path before asserting the no-token fail-closed state so the browser suite observes the same lifecycle it is validating.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: provide product name in policy overlay fixture
Ensure managed-settings messages render Code - OSS instead of an undefined product label in component screenshots.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: add managed settings failure modes
Let the mock policy server return HTTP errors, malformed JSON, immediate disconnects, or no response until client timeout through presets, the GUI, and the control API.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: tighten forced managed settings recovery
Improve forced-refresh progress and blocked-state UX, bound automatic retries after failures, preserve the ungoverned cache path, and simplify mock policy failure controls.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: close managed settings dialog on retry
Start the explicit managed-settings refresh without making the dialog wait for the network request to complete.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: separate managed settings requirement copy
Place the organization requirement and fetch failure remediation in separate paragraphs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: address managed settings review feedback
Preserve cached and blocked freshness state, report failed manual syncs, retain pending mock-server edits, and include attempted scope in diagnostics.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chat: reduce managed settings freshness implementation
Trim redundant contract commentary and tests, simplify refresh resolution, deduplicate failure transitions, and keep no-flag tests independent from retry bypass behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>