fix(web): coherent, recoverable Plex authorized-but-no-servers state (#345) #366
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6532929cf2 |
fix(web): gate Plex authorized-no-servers messaging on released lock
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 8s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 8s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 24s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 44s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m17s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m18s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 5m56s
Adversarial review of the initial fix found that authorizedNoServers = isAuthorized && !hasServers ignored isLocked. Because boot.state updates on every poll observation, the "no eligible servers — sign out and retry" subtitle + summary rendered during the normal `finalizing` window (locked, authorized, no servers yet) alongside the "discovering your Plex servers…" status — and during `budget-exhausted` (large first sync still holding the lock, polling stopped, Sign out enabled) it urged the user to sign out mid-sync. That reintroduced the contradictory-state class the PR fixes. Gate the empty-servers presentation on !isLocked so it only appears at the genuine released-lock terminal. Add regression coverage: the pin-flow test now passes through the finalizing cell asserting the empty-servers messaging is absent while locked, plus a budget-exhausted-while-locked case. Both new guards were confirmed to fail on the ungated code (negative control). Refs #345 |
||
|
|
0f0a0d7fe5 |
fix(web): coherent, recoverable Plex authorized-but-no-servers state
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 9s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 9s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m18s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 14s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 16s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m28s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 3m26s
A real Plex pin flow reached isAuthorized:true, isLocked:false, servers:[]
(a Plex account that owns/has been granted no eligible servers). The SPA
then showed contradictory state: the pin-flow status claimed "Connected to
Plex." while the Connection card said "Not signed in.", offered Sign in, and
hid Sign out — so the stored authorization could not be removed through the UI.
Root cause: PlexSourceScreen conflated authorization (a stored token,
isAuthorized) with connection (a discovered server, servers.length > 0) by
deriving everything from `connected = servers.length > 0`, and evaluatePinFlow
returned `success` ("Connected to Plex.") for any released-lock authorized
observation regardless of server count.
Fix (pure SPA; sign-out endpoint already works with empty servers):
- pinFlowPoll: add a distinct `authorized-no-servers` terminal status and a
`hasServers` observation field; the released-lock branch now yields success
only when a server was discovered, else authorized-no-servers with an honest
message that distinguishes authorization from discovery.
- PlexSourceScreen: gate Sign in vs Sign out on `hasPlexAccount`
(isAuthorized || hasServers) instead of the server count, so an authorized
account can always sign out; add a subtitle + explanatory summary for the
authorized/empty state; keep the Servers card gated on actual servers.
- Regression tests: the authorized/unlocked/empty transition (pin-flow and
fresh-reload paths) and sign-out from that state.
fixes #345
|