Fixes#345. A real Plex pin flow reached the valid API state isAuthorized: true, isLocked: false, servers: [] (a Plex account that owns / has been granted access to no eligible servers). The SPA then showed mutually contradictory state — pin-flow status "Connected to Plex." vs Connection card "Not signed in.", with Sign in offered and Sign out hidden, so the stored authorization could not be removed through the UI.
Root cause
PlexSourceScreen conflated two distinct concepts and derived every affordance from server count:
connected = serverList.length > 0 drove the Connection subtitle, Sign-in visibility (!connected), Sign-out visibility (connected), and the Servers card.
evaluatePinFlow returned success → "Connected to Plex." for any released-lock + authorized observation, regardless of whether a server was discovered.
So in the authorized/unlocked/empty state, connected was false → "Not signed in.", Sign in shown, Sign out hidden — while the pin-flow message claimed a connection.
Fix (pure SPA — no API change; the sign-out endpoint already works with empty servers)
pinFlowPoll.ts: add a distinct authorized-no-servers terminal status and a hasServers field on PinFlowObservation. The released-lock branch now returns success only when a server was actually discovered, otherwise authorized-no-servers with a message that distinguishes account authorization from server discovery (no longer "Connected to Plex.").
PlexSourceScreen.tsx: introduce hasPlexAccount = isAuthorized || hasServers and gate Sign in vs Sign out on it (not on server count), so an authorized account can always sign out. The Connection subtitle now has a four-way descriptor; the Servers card stays gated on real servers; a new explanatory summary covers the authorized/empty state and points at the sign-out → sign-in recovery path.
Maps to the issue's Done-when
Pin-flow messaging distinguishes account authorization from successful server discovery — new authorized-no-servers status + message.
An authorized account can sign out even when servers is empty — Sign out gated on hasPlexAccount.
Connection card and available actions agree for authorized/unlocked/empty — subtitle, actions, and Servers card all keyed consistently.
Regression tests cover the authorized/unlocked/empty transition and sign-out — pin-flow path and fresh-reload path in PlexSourceScreen.test.tsx, plus the new machine case in pinFlowPoll.test.ts.
Relevant SPA quality gates pass — see Verification.
#333 live validation repeated / linked — see note below.
Verification
npm test -- --run — 90 files, 779 tests pass (19 in the two touched suites, including the two new #345 scenarios).
npm run lint — clean.
npm run build (tsc -b && vite build) — clean (pre-existing chunk-size advisory only).
No /api/* change → check:api / OpenAPI regen not applicable.
Live-validation note (#333): the authorized/unlocked/empty state requires a Plex account with zero eligible servers, which can't be synthesized against the disposable test deployment on demand. The state transition and sign-out are covered deterministically by the new regression tests; the original #333 live evidence (from the issue body) remains the reproduction of record. Requesting reviewer input on whether a fresh live repro is required to tick the last box.
Review scope
Pure-SPA leaf, no server-state effect → per the skip rubric this is eligible for a cold single-reviewer pass rather than cross-model escalation. Adversarial review requested on this diff.
## Summary
Fixes #345. A real Plex pin flow reached the valid API state `isAuthorized: true`, `isLocked: false`, `servers: []` (a Plex account that owns / has been granted access to no eligible servers). The SPA then showed mutually contradictory state — pin-flow status **"Connected to Plex."** vs Connection card **"Not signed in."**, with **Sign in** offered and **Sign out** hidden, so the stored authorization could not be removed through the UI.
## Root cause
`PlexSourceScreen` conflated two distinct concepts and derived every affordance from server count:
- `connected = serverList.length > 0` drove the Connection subtitle, Sign-in visibility (`!connected`), Sign-out visibility (`connected`), and the Servers card.
- `evaluatePinFlow` returned `success` → "Connected to Plex." for **any** released-lock + authorized observation, regardless of whether a server was discovered.
So in the authorized/unlocked/empty state, `connected` was `false` → "Not signed in.", Sign in shown, Sign out hidden — while the pin-flow message claimed a connection.
## Fix (pure SPA — no API change; the sign-out endpoint already works with empty servers)
- **`pinFlowPoll.ts`**: add a distinct `authorized-no-servers` terminal status and a `hasServers` field on `PinFlowObservation`. The released-lock branch now returns `success` only when a server was actually discovered, otherwise `authorized-no-servers` with a message that distinguishes account authorization from server discovery (no longer "Connected to Plex.").
- **`PlexSourceScreen.tsx`**: introduce `hasPlexAccount = isAuthorized || hasServers` and gate **Sign in vs Sign out** on it (not on server count), so an authorized account can always sign out. The Connection subtitle now has a four-way descriptor; the Servers card stays gated on real servers; a new explanatory summary covers the authorized/empty state and points at the sign-out → sign-in recovery path.
## Maps to the issue's Done-when
- [x] Pin-flow messaging distinguishes account authorization from successful server discovery — new `authorized-no-servers` status + message.
- [x] An authorized account can sign out even when `servers` is empty — Sign out gated on `hasPlexAccount`.
- [x] Connection card and available actions agree for authorized/unlocked/empty — subtitle, actions, and Servers card all keyed consistently.
- [x] Regression tests cover the authorized/unlocked/empty transition and sign-out — pin-flow path and fresh-reload path in `PlexSourceScreen.test.tsx`, plus the new machine case in `pinFlowPoll.test.ts`.
- [x] Relevant SPA quality gates pass — see Verification.
- [ ] #333 live validation repeated / linked — see note below.
## Verification
- `npm test -- --run` — **90 files, 779 tests pass** (19 in the two touched suites, including the two new #345 scenarios).
- `npm run lint` — clean.
- `npm run build` (`tsc -b && vite build`) — clean (pre-existing chunk-size advisory only).
- No `/api/*` change → `check:api` / OpenAPI regen not applicable.
**Live-validation note (#333):** the authorized/unlocked/empty state requires a Plex account with zero eligible servers, which can't be synthesized against the disposable test deployment on demand. The state transition and sign-out are covered deterministically by the new regression tests; the original #333 live evidence (from the issue body) remains the reproduction of record. Requesting reviewer input on whether a fresh live repro is required to tick the last box.
## Review scope
Pure-SPA leaf, no server-state effect → per the skip rubric this is eligible for a cold single-reviewer pass rather than cross-model escalation. Adversarial review requested on this diff.
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
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
Two independent cold-context adversarial passes (scoped review-only):
Initial diff (0f0a0d7f) → BLOCKED (High). Caught that authorizedNoServers = isAuthorized && !hasServers ignored isLocked: because boot.state updates on every poll, the "no eligible servers — sign out and retry" subtitle + summary would render during the normal finalizing window (locked, authorized, no servers yet) alongside "Authorized — discovering your Plex servers…", and during budget-exhausted (large first sync still holding the lock, polling stopped, Sign-out enabled) it urged a sign-out mid-sync — reintroducing the contradictory-state class this PR fixes.
Fix commit (6532929c) → MERGEABLE. Gated the empty-servers presentation on !isLocked (only the released lock is terminal). Re-enumerated every isLocked:true cell (waiting / finalizing / budget-exhausted) and confirmed subtitle + buttons + Servers card + summary are now coherent, with no needed affordance hidden (Sign out stays available in all locked cells; only the misleading text is withheld). No regression to the unlocked terminals, needsFix, or normal success. Both new regression tests confirmed non-vacuous via negative control (they fail on the ungated code).
Pre-existing orthogonal note (not introduced here, not a blocker): the budget-exhausted message says "Use Refresh to check again," but there's no global Refresh control when zero servers exist — filing a backlog follow-up.
Local verification: npm test 780/780, npm run lint clean, npm run build clean. No /api change.
Review-verdict: MERGEABLE @ 6532929c
Two independent cold-context adversarial passes (scoped review-only):
1. **Initial diff (`0f0a0d7f`) → BLOCKED (High).** Caught that `authorizedNoServers = isAuthorized && !hasServers` ignored `isLocked`: because `boot.state` updates on every poll, the "no eligible servers — sign out and retry" subtitle + summary would render during the normal `finalizing` window (locked, authorized, no servers yet) alongside "Authorized — discovering your Plex servers…", and during `budget-exhausted` (large first sync still holding the lock, polling stopped, Sign-out enabled) it urged a sign-out mid-sync — reintroducing the contradictory-state class this PR fixes.
2. **Fix commit (`6532929c`) → MERGEABLE.** Gated the empty-servers presentation on `!isLocked` (only the released lock is terminal). Re-enumerated every `isLocked:true` cell (waiting / finalizing / budget-exhausted) and confirmed subtitle + buttons + Servers card + summary are now coherent, with no needed affordance hidden (Sign out stays available in all locked cells; only the misleading text is withheld). No regression to the unlocked terminals, `needsFix`, or normal success. Both new regression tests confirmed non-vacuous via negative control (they fail on the ungated code).
Pre-existing orthogonal note (not introduced here, not a blocker): the `budget-exhausted` message says "Use Refresh to check again," but there's no global Refresh control when zero servers exist — filing a backlog follow-up.
Local verification: `npm test` 780/780, `npm run lint` clean, `npm run build` clean. No `/api` change.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Fixes #345. A real Plex pin flow reached the valid API state
isAuthorized: true,isLocked: false,servers: [](a Plex account that owns / has been granted access to no eligible servers). The SPA then showed mutually contradictory state — pin-flow status "Connected to Plex." vs Connection card "Not signed in.", with Sign in offered and Sign out hidden, so the stored authorization could not be removed through the UI.Root cause
PlexSourceScreenconflated two distinct concepts and derived every affordance from server count:connected = serverList.length > 0drove the Connection subtitle, Sign-in visibility (!connected), Sign-out visibility (connected), and the Servers card.evaluatePinFlowreturnedsuccess→ "Connected to Plex." for any released-lock + authorized observation, regardless of whether a server was discovered.So in the authorized/unlocked/empty state,
connectedwasfalse→ "Not signed in.", Sign in shown, Sign out hidden — while the pin-flow message claimed a connection.Fix (pure SPA — no API change; the sign-out endpoint already works with empty servers)
pinFlowPoll.ts: add a distinctauthorized-no-serversterminal status and ahasServersfield onPinFlowObservation. The released-lock branch now returnssuccessonly when a server was actually discovered, otherwiseauthorized-no-serverswith a message that distinguishes account authorization from server discovery (no longer "Connected to Plex.").PlexSourceScreen.tsx: introducehasPlexAccount = isAuthorized || hasServersand gate Sign in vs Sign out on it (not on server count), so an authorized account can always sign out. The Connection subtitle now has a four-way descriptor; the Servers card stays gated on real servers; a new explanatory summary covers the authorized/empty state and points at the sign-out → sign-in recovery path.Maps to the issue's Done-when
authorized-no-serversstatus + message.serversis empty — Sign out gated onhasPlexAccount.PlexSourceScreen.test.tsx, plus the new machine case inpinFlowPoll.test.ts.Verification
npm test -- --run— 90 files, 779 tests pass (19 in the two touched suites, including the two new #345 scenarios).npm run lint— clean.npm run build(tsc -b && vite build) — clean (pre-existing chunk-size advisory only)./api/*change →check:api/ OpenAPI regen not applicable.Live-validation note (#333): the authorized/unlocked/empty state requires a Plex account with zero eligible servers, which can't be synthesized against the disposable test deployment on demand. The state transition and sign-out are covered deterministically by the new regression tests; the original #333 live evidence (from the issue body) remains the reproduction of record. Requesting reviewer input on whether a fresh live repro is required to tick the last box.
Review scope
Pure-SPA leaf, no server-state effect → per the skip rubric this is eligible for a cold single-reviewer pass rather than cross-model escalation. Adversarial review requested on this diff.
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 #345Review-verdict: MERGEABLE @
6532929cTwo independent cold-context adversarial passes (scoped review-only):
Initial diff (
0f0a0d7f) → BLOCKED (High). Caught thatauthorizedNoServers = isAuthorized && !hasServersignoredisLocked: becauseboot.stateupdates on every poll, the "no eligible servers — sign out and retry" subtitle + summary would render during the normalfinalizingwindow (locked, authorized, no servers yet) alongside "Authorized — discovering your Plex servers…", and duringbudget-exhausted(large first sync still holding the lock, polling stopped, Sign-out enabled) it urged a sign-out mid-sync — reintroducing the contradictory-state class this PR fixes.Fix commit (
6532929c) → MERGEABLE. Gated the empty-servers presentation on!isLocked(only the released lock is terminal). Re-enumerated everyisLocked:truecell (waiting / finalizing / budget-exhausted) and confirmed subtitle + buttons + Servers card + summary are now coherent, with no needed affordance hidden (Sign out stays available in all locked cells; only the misleading text is withheld). No regression to the unlocked terminals,needsFix, or normal success. Both new regression tests confirmed non-vacuous via negative control (they fail on the ungated code).Pre-existing orthogonal note (not introduced here, not a blocker): the
budget-exhaustedmessage says "Use Refresh to check again," but there's no global Refresh control when zero servers exist — filing a backlog follow-up.Local verification:
npm test780/780,npm run lintclean,npm run buildclean. No/apichange.