Files
pluriwave/openspec/changes/startup-retry-custom-stations-eq-persistence/proposal.md
Javier Bautista Fernández d579a0e107 feat: Implement startup retry mechanism for custom stations and equalizer persistence
- Added state management for startup retry and custom station handling in `EstadoRadio`.
- Created tasks for implementing strict TDD with RED tests for HTTP failure retries and EQ persistence.
- Developed verification report to ensure compliance with TDD practices.
- Introduced fake services for testing, including `FakeServicioAudio`, `FakeServicioFavoritos`, and `FakeServicioRadio`.
- Implemented widget tests for `PantallaInicio` and `PantallaFavoritos` to validate UI behavior with custom stations.
- Enhanced `ServicioRadio` to support host rotation and retry logic for API calls.
- Established a new configuration file to enforce project constraints and testing rules.
2026-04-27 17:34:04 +02:00

3.2 KiB

Proposal: Startup retry, custom stations, and equalizer persistence

Intent

Make startup resilient to transient Radio Browser/API failures, make user-added stations first-class in the main listing/favorites flow, and persist equalizer choices so the app restores the configured graph and respects station-specific EQ.

Scope

In Scope

  • Add bounded retry with host rotation for initial radio API fetches.
  • Show custom stations from Settings in the main station listing.
  • Keep custom stations favorite-capable through existing favorite persistence.
  • Persist main EQ and per-favorite station EQ.
  • Apply station EQ when present; otherwise apply main EQ.
  • Add strict-TDD tests before implementation.

Out of Scope

  • flutter build or release packaging.
  • Replacing Provider/ChangeNotifier.
  • Full redesign of radio browsing/search UX.
  • Cloud sync of EQ or station data.

Capabilities

New Capabilities

  • startup-radio-loading: resilient startup station loading with bounded retry.
  • custom-stations-listing: custom stations appear in the main listing and can be favorites.
  • equalizer-persistence: main EQ persists and loads on startup.
  • station-equalizer: favorite stations may own EQ or use main EQ.

Modified Capabilities

  • None; no existing OpenSpec source specs exist yet.

Approach

Centralize API retry in ServicioRadio, add test-friendly dependency injection, expose a combined main listing in EstadoRadio, and introduce ServicioEcualizador using SharedPreferences JSON. Use null/no entry for station EQ fallback to main EQ.

Affected Areas

Area Impact Description
lib/servicios/servicio_radio.dart Modified Retry/host rotation and injectable HTTP client/delay.
lib/estado/estado_radio.dart Modified Init flow, main listing getter, EQ load/save/apply policy.
lib/servicios/servicio_audio.dart Modified Track current station correctly for UI and EQ.
lib/servicios/servicio_ecualizador.dart New Persist main and station EQ settings.
lib/pantallas/pantalla_inicio.dart Modified Render custom stations in the main list.
lib/pantallas/pantalla_ajustes.dart Modified EQ scope controls/load state.
test/ Modified Unit/widget tests for all spec scenarios.

Risks

Risk Likelihood Mitigation
Startup delay from retries Med Cap attempts, short backoff, preserve manual retry.
Native EQ unavailable before playback Med Persist Provider state independently from Android EQ.
Constructor changes break widgets Low Keep default constructors backward compatible.

Rollback Plan

Revert the change folder and implementation commits. Since persistence uses new SharedPreferences keys, rollback can ignore them safely.

Dependencies

  • Existing shared_preferences, http, provider, flutter_test.

Success Criteria

  • Transient startup API failure retries and succeeds without showing final error.
  • Exhausted startup attempts leave the app usable with manual retry.
  • Custom stations appear in PantallaInicio and can be favorited.
  • Main EQ restores after app restart.
  • Favorite station own EQ overrides main EQ only when enabled.