Skip to content

R1: mechanical cleanup — dead surface out, one copy of each policy#45

Merged
adyz merged 1 commit into
masterfrom
r1-curatenie
Jul 4, 2026
Merged

R1: mechanical cleanup — dead surface out, one copy of each policy#45
adyz merged 1 commit into
masterfrom
r1-curatenie

Conversation

@adyz

@adyz adyz commented Jul 4, 2026

Copy link
Copy Markdown
Owner

First phase of the post-review refactor plan (see the new section in plan.md). Zero behavior change, proven by the untouched e2e suite: 37/37 green, plus clean typecheck, 61/61 unit, identical build structure (bundle slightly smaller: 58.9 KB vs ~60 KB).

What's removed (all verified dead)

  • isRetry/_isRetry plumbing — no caller ever passed it; resetAttemptCounters is now unconditional. The vestigial param invited a future caller to silently skip counter resets, resurrecting the pre-XState retry design.
  • _getRetryCount — zero usages.
  • resumeRadio/resumePlayer alias pair → one function.
  • The defensive non-promise / sync-throw branches in resume — they contradict the RadioDeps.playerPlay(): Promise<void> contract and existed only for two tests pinning behavior no browser produces (tests deleted with them).

What's deduplicated

  • isAbortError() exported from the machine, reused in the guard, handleResumeError, and both soundEffects catch sites (4 hand-typed copies → 1).
  • streamFailure(...extra) — the canRetry→retrying / else→error ladder was spelled 5 times in the machine (loading onError, loading timeout, playing STALLED, playing PLAYER_ERROR, paused PLAYER_ERROR).
  • tryRecover — error's after.RECOVERY_DELAY and on.RETRY_FROM_ERROR arrays were character-identical.
  • clearPositionState() in mediaSession — one feature-detected helper replaces 5 inline setPositionState try/catch blocks (3 of which bypassed the existing feature detection).
  • scrollOptionIntoView() in the station selector — the two hand-copied scrollIntoView option objects.

Also includes the full post-review refactor plan (R1–R6) appended to plan.md.

Net code diff (excluding plan.md): ~63 added / ~125 removed.

🤖 Generated with Claude Code

From the post-review refactor plan (plan.md, R1). Zero behavior change,
proven by the untouched e2e suite (37/37).

- Drop the vestigial isRetry/_isRetry plumbing (no caller ever passed it;
  resetAttemptCounters is now unconditional) and the unused _getRetryCount.
- Collapse resumeRadio/resumePlayer into one function and drop the
  defensive non-promise/sync-throw branches that contradicted the
  RadioDeps.playerPlay(): Promise<void> contract (with their two tests —
  they pinned behavior no browser produces).
- Export isAbortError() from the machine and reuse it in the guard,
  handleResumeError, and both soundEffects catch sites (4 copies -> 1).
- Extract the duplicated transition ladders in the machine: streamFailure()
  (the canRetry->retrying / else->error policy, was spelled 5 times) and
  tryRecover (error's after/RETRY_FROM_ERROR arrays were char-identical).
- mediaSession: one feature-detected clearPositionState() replaces the 5
  inline setPositionState try/catch blocks (3 of which bypassed the
  existing feature detection).
- stationSelector: shared scrollOptionIntoView() for the two hand-copied
  scrollIntoView option objects.
- plan.md: add the post-review refactor plan (R1-R6).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
radio Ready Ready Preview, Comment Jul 4, 2026 5:19am

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

CI Summary

Check Status Result
Typecheck PASS tsc --noEmit clean
Unit tests PASS 61/61 passed; Coverage: Lines 99.71%, Branches 90.78%, Functions 96.77%, Statements 99.71%
Build PASS Build completed
Playwright browser PASS Chromium installed
E2E tests PASS 37/37 passed

@adyz adyz merged commit de339b7 into master Jul 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant