R2: one source of truth for state classification#46
Merged
Conversation
From the post-review refactor plan (plan.md, R2). Zero behavior change, proven by the untouched e2e suite (37/37). The "which states count as loading / error / audible" classification was hand-spelled in four places across main.ts and mediaSession.ts and had already drifted once. It now lives next to STATE_FX in radioMachine.ts: - isLoadingLike (loading|retrying), isErrorLike (error|recovering), isFeedbackAudible (their union), playbackStateFor (what the OS lock screen should report) — re-exported through radioCore like the rest of the shared surface. - mediaSession.ts: the 'pause' action handler, reassertPlaybackState and updateMediaSession (incl. the playbackState and position-clear expressions) all derive from the predicates now. - main.ts: the player 'pause' listener keeps its EXACT current set (isLoadingLike + recovering, deliberately without 'error') — the pre-existing drift is now explicit and commented; whether it is intent or a bug gets decided in R3/R5, not silently. - New unit test locks the full 7-state classification table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second phase of the post-review refactor plan (
plan.md, R2). Zero behavior change — untouched e2e suite 37/37 green, clean typecheck, 62/62 unit (61 old + 1 new), identical build.The "which states count as loading / error / audible" classification was hand-spelled in four places across
main.tsandmediaSession.ts, and the review showed they had already drifted once (commit a667b7f had to edit them when the error-sound semantics changed).What changed
STATE_FXinradioMachine.ts, re-exported throughradioCore:isLoadingLike(loading|retrying),isErrorLike(error|recovering),isFeedbackAudible(their union),playbackStateFor(what the OS lock screen should report).mediaSession.ts: the'pause'action handler,reassertPlaybackState, andupdateMediaSession(including theplaybackStateand position-clear expressions) now all derive from the predicates.main.ts: the player'pause'listener keeps its exact current set (isLoadingLike(s) || s === 'recovering', deliberately without'error') — the pre-existing drift is now explicit and commented instead of hidden in a fourth hand-typed list. Whether it's intent or a bug gets decided in R3/R5.Adding a new
RadioStatenow hits: the exhaustiveSTATE_FXrecord (compile error), the predicates one line away, and the classification test.🤖 Generated with Claude Code