fix(central-ui): pending-updates indicator starts polling once the async auth resolve completes

OnParametersSetAsync awaits the principal. On a real cookie session that await
suspends, so the FIRST render ran with _visible still false and
OnAfterRenderAsync(firstRender: true) skipped EnsurePollingStarted(); the
render that followed the resolve was firstRender: false, and nothing else
started the poll unless AuthenticationStateChanged happened to fire. The block
therefore rendered and sat on 'Checking for updates…' for the life of the
circuit. OnParametersSetAsync now starts polling itself when visible (the
start is idempotent and the OnAfterRender call is kept).

Also corrects the comments that called the non-forced
GetAuthenticationStateAsync cheap: on CookieAuthenticationStateProvider both
entry points revalidate against the database and differ only in failClosed, so
the saving is not asking the provider on a tick and reusing the cascaded state
the router already resolved. The provider fallback is a real refresh, is only
taken when no cascade is present (AddCascadingAuthenticationState is
registered, so it is dead in production), and is now resolved at most once per
auth state rather than on every parameter set.

Claude-Session: https://claude.ai/code/session_01Y5ef34iUUMjmwnMpL9xgmB
This commit is contained in:
Joseph Doherty
2026-09-14 14:29:36 -04:00
parent 623c6d0fe8
commit 3a21cfc2f5
3 changed files with 101 additions and 24 deletions
@@ -94,14 +94,17 @@ public sealed class SiteScopeService
/// The site-scope rule as a <b>pure</b> function of an already-resolved principal —
/// no I/O, no authentication-state fetch, no session revalidation.
/// <para>
/// Every instance method here resolves the AUTHORITATIVE state first (a fail-closed
/// refresh that re-maps groups to roles against the database), which is correct
/// before a mutation but far too expensive for a component that merely decides what
/// to render — and ruinous for one that re-decides on a timer. Display-gating
/// callers holding a principal (the cascading <see cref="AuthenticationState"/>, or
/// a non-forced <c>GetAuthenticationStateAsync</c>) call this instead and pay
/// nothing. Anything that ACTS on a site must still go through
/// <see cref="IsSiteAllowedAsync"/> so the check is made against fresh claims.
/// Every instance method here resolves the state through the provider first, which
/// on <c>CookieAuthenticationStateProvider</c> re-maps groups to roles against the
/// database. Note that the non-authoritative overload is NOT a cheap alternative —
/// both entry points refresh, differing only in whether a mapping fault denies or
/// reuses the old grants — so the way to avoid the cost is to not ask the provider
/// at all. A display-gating caller that already HOLDS a principal (the cascading
/// <see cref="AuthenticationState"/> the router resolved for the page) calls this
/// instead and triggers no refresh of its own; that is what makes the rule usable
/// from a component that re-decides on a timer. Anything that ACTS on a site must
/// still go through <see cref="IsSiteAllowedAsync"/> so the check is made against
/// freshly revalidated claims.
/// </para>
/// </summary>
/// <param name="user">The principal to classify. An unauthenticated principal is scoped to nothing.</param>