Skip to content

perf: cache header artwork image#273

Merged
GeneralD merged 2 commits into
mainfrom
perf/269/header-artwork-image-cache
Jun 12, 2026
Merged

perf: cache header artwork image#273
GeneralD merged 2 commits into
mainfrom
perf/269/header-artwork-image-cache

Conversation

@GeneralD

@GeneralD GeneralD commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Cache decoded header artwork as NSImage in HeaderPresenter when artwork data changes.
  • Render HeaderView from the presenter-owned cached image instead of decoding inside body.
  • Bump version from 2.13.9 to 2.13.10.

Background

Closes #269
Part of #258

Breaking Changes

None.

Verification

  • swift build
  • swift test --filter HeaderPresenter
  • swift test --filter HeaderView
  • swift test --filter WallpaperPresenter
  • swift format lint --strict --recursive Sources/ Tests/
  • swift test --no-parallel

Note: plain parallel swift test still showed unrelated WallpaperPresenter/loading-indicator timing failures; the isolated WallpaperPresenter suite and the full no-parallel run passed.

Summary by CodeRabbit

  • New Features

    • Enhanced artwork rendering with improved caching efficiency.
  • Tests

    • Updated test coverage for artwork handling and image display verification.
  • Chores

    • Version bumped to 2.13.10.

Copilot AI review requested due to automatic review settings June 12, 2026 03:11
@GeneralD GeneralD self-assigned this Jun 12, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5d50585-812e-4d7d-971a-d392590d9c34

📥 Commits

Reviewing files that changed from the base of the PR and between 2e86ef0 and 197de6c.

📒 Files selected for processing (6)
  • Sources/Presenters/Track/HeaderPresenter.swift
  • Sources/VersionHandler/Resources/version.txt
  • Sources/Views/Header/HeaderView.swift
  • Tests/PresentersTests/HeaderPresenterDuplicateTests.swift
  • Tests/PresentersTests/HeaderPresenterTests.swift
  • Tests/ViewsTests/ViewRenderingTests.swift

📝 Walkthrough

Walkthrough

This PR moves NSImage generation from HeaderView to HeaderPresenter to avoid repeated image decoding during animations. The presenter now exposes a cached artworkImage property derived from artworkData with dedup guards, and the view uses the pre-computed result directly.

Changes

Artwork Caching Performance Enhancement

Layer / File(s) Summary
Presenter artworkImage property and dedup helper
Sources/Presenters/Track/HeaderPresenter.swift
Add @Published artworkImage: NSImage? property; import AppKit for NSImage support; update artwork Combine sink to delegate to new receiveArtwork(_:) helper; implement helper to guard against duplicate updates and derive NSImage from Data via flatMap.
Presenter test coverage: dedup and caching
Tests/PresentersTests/HeaderPresenterTests.swift, Tests/PresentersTests/HeaderPresenterDuplicateTests.swift
Add AppKit import and fixtureArtworkData helper; convert withDependencies blocks to try await; verify identical artwork does not re-cache via reference identity (===); verify artwork changes replace cache via reference inequality (!==); update idle-update test to assert artworkImage nil.
View integration and rendering tests
Sources/Views/Header/HeaderView.swift, Tests/ViewsTests/ViewRenderingTests.swift
Update HeaderView to use presenter.artworkImage directly instead of creating NSImage from artworkData; update view rendering tests to assert on artworkImage presence, await its readiness, and use tiffRepresentation for test data generation.
Version bump
Sources/VersionHandler/Resources/version.txt
Increment version from 2.13.9 to 2.13.10.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A caching tale, so swift and neat,
NSImage joins the presenter beat,
No more decoding on every frame,
Header views render—smooth as flame! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'perf: cache header artwork image' clearly and concisely describes the main change—moving NSImage decoding from view to presenter for performance.
Linked Issues check ✅ Passed All requirements from issue #269 are met: HeaderPresenter exposes @Published artworkImage property, NSImage is cached when artworkData changes, HeaderView renders cached image instead of decoding, and tests verify the caching behavior.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #269 objectives: presenter caching, view simplification, test coverage updates, and version bump. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 perf/269/header-artwork-image-cache

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 and usage tips.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@GeneralD GeneralD merged commit 70564c9 into main Jun 12, 2026
4 checks passed
@GeneralD GeneralD deleted the perf/269/header-artwork-image-cache branch June 12, 2026 05:30
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.

perf: HeaderView の NSImage 生成を Presenter 側でキャッシュする

2 participants