Skip to content

Adaptive theme from cover art - #439

Merged
LargeModGames merged 1 commit into
mainfrom
feature/adaptive-cover-theme
Aug 12, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
feature/adaptive-cover-theme

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds an Adaptive Theme option (Settings > Theme, off by default): UI accent colors are derived from the current track's cover art and fade in on track change, fading back to the user's own theme when art clears. Text, background, borders, and error colors stay untouched so legibility never depends on the art.

  • New core/cover_theme module (cfg cover-art): dominant-color extraction from the decoded cover (scored 4-bit color bins, saturation and mid-brightness weighted), theme derivation with a legibility clamp against the base background, and a time-based fade driven from update_on_tick.
  • Palette extraction runs in the network layer off the App lock, alongside the existing decode; App::store_cover_art / App::clear_cover_art keep the palette paired with the art at one chokepoint.
  • Settings saves reconcile with an in-flight fade so album accents never leak into custom_theme, and a save from another category keeps the base theme intact.
  • The art fetch gate is now UserConfig::needs_cover_art, so theming works with the art pane hidden (disabled or no terminal image support). Color-space math reuses csscolorparser (via the existing colorgrad dep) instead of hand-rolled conversions, and the fade shares ease_in_out_cubic with the lyrics animation.

Testing

Ran:

  • cargo fmt --all
  • cargo clippy --no-default-features --features telemetry -- -D warnings
  • cargo clippy --no-default-features --features telemetry,cover-art -- -D warnings
  • cargo check --no-default-features --features telemetry,cover-art --tests

Still to run before merge (test binaries with cover-art cannot run from the agent harness):

  • cargo test --no-default-features --features telemetry,cover-art cover_theme (12 new unit tests for extraction/derivation/lerp plus 8 state-machine tests in app.rs)
  • Smoke test with the full cargo run build

Additional notes

  • Also fixes two latent unused-variable lints (migrations.rs on non-Unix, runner.rs without local-files) that only surface in feature/platform combos CI does not build.
  • Known follow-up: the fade animates user_config.theme in place, the same field ScriptEffect::SetTheme writes, so a Lua theme write during a fade gets overwritten. A resolution-point App::theme() would fix this but touches every theme read site, so it is left for a separate PR.

Summary by CodeRabbit

  • New Features
    • Added an optional adaptive theme that derives accent colors from album cover art.
    • Added smooth transitions between album-based themes as tracks change.
    • Restores the saved user theme when adaptive theming or cover art is disabled or unavailable.
    • Added an Adaptive Theme setting, disabled by default.
  • Bug Fixes
    • Prevented album-derived colors from replacing the user’s saved theme.
    • Improved stale cover-art handling when artwork cannot be loaded.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds adaptive cover-art theming. It extracts album palettes, derives and fades accent colors, preserves user themes, adds a configuration setting, and integrates palette updates with cover-art loading and animation ticks.

Changes

Adaptive cover-art theme flow

Layer / File(s) Summary
Palette extraction and theme transitions
src/core/cover_theme.rs, src/core/mod.rs
Adds palette extraction, transparent-pixel handling, accent derivation, legibility adjustments, theme interpolation, and transition tests.
Adaptive theme configuration
src/core/user_config.rs
Adds the cover_art_theme setting, persistence, defaults, and needs_cover_art.
App theme lifecycle and settings reconciliation
src/core/app.rs
Stores palette and transition state, applies or restores adaptive themes, preserves user theme values, reconciles settings, and adds integration tests.
Cover-art loading and animation wiring
src/infra/network/playback.rs, src/tui/runner.rs, src/core/migrations.rs
Synchronizes palette and artwork storage, clears stale artwork through App, enables fade ticks, and adds the non-Unix permission fallback.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant fetch_cover_art
  participant App
  participant ThemeTransition
  fetch_cover_art->>App: store_cover_art(image, palette)
  App->>ThemeTransition: create transition to derived theme
  App->>ThemeTransition: advance on tick
  ThemeTransition-->>App: current interpolated theme
  App-->>App: restore user theme when palette or setting is cleared
Loading

Possibly related PRs

  • LargeModGames/spotatui#403: Adds scripting widgets and layouts for displaying existing cover art, while this PR adds adaptive album-art theming.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes the main change but lacks the required conventional-commit prefix and is not imperative. Rename it with a valid prefix and imperative subject, for example, "feat: add adaptive theme from cover art".
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/adaptive-cover-theme
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/adaptive-cover-theme

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tui/runner.rs (1)

1101-1113: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Gate all cover-art draw sites with do_draw_cover_art. The playbar applies this gate, but draw_cover_art_content and the plugin draw_cover_art render cached artwork based only on available(). Theme-only fetching can therefore display artwork when draw_cover_art is disabled or image support is unavailable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tui/runner.rs` around lines 1101 - 1113, Update draw_cover_art_content
and the plugin draw_cover_art paths to require do_draw_cover_art before
rendering cached artwork. Apply the same gate used by the playbar, alongside the
existing available() and image-support checks, so disabled cover-art drawing
never displays artwork.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/tui/runner.rs`:
- Around line 1101-1113: Update draw_cover_art_content and the plugin
draw_cover_art paths to require do_draw_cover_art before rendering cached
artwork. Apply the same gate used by the playbar, alongside the existing
available() and image-support checks, so disabled cover-art drawing never
displays artwork.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f1d62f3e-229e-4b41-956e-938ac7db3c9e

📥 Commits

Reviewing files that changed from the base of the PR and between c60b053 and 52c7a97.

📒 Files selected for processing (7)
  • src/core/app.rs
  • src/core/cover_theme.rs
  • src/core/migrations.rs
  • src/core/mod.rs
  • src/core/user_config.rs
  • src/infra/network/playback.rs
  • src/tui/runner.rs

@LargeModGames
LargeModGames merged commit 0d7afa2 into main Aug 12, 2026
21 checks passed
@LargeModGames
LargeModGames deleted the feature/adaptive-cover-theme branch August 12, 2026 17:00
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