ML-185.2: use API-sized Presto covers

This commit is contained in:
Claudio Ortolina
2026-05-15 22:56:22 +01:00
parent b4710e10c8
commit 3a7a89002a
7 changed files with 120 additions and 84 deletions
@@ -1,10 +1,10 @@
---
id: ML-185
title: Simplify Presto artwork handling
status: To Do
status: Done
assignee: []
created_date: "2026-05-15 21:19"
updated_date: "2026-05-15 21:40"
updated_date: "2026-05-15 21:53"
labels:
- api
- presto
@@ -43,11 +43,11 @@ Target state: each API record representation exposes four named cover variants:
<!-- AC:BEGIN -->
- [ ] #1 Collection API record JSON exposes four named cover variants: original, large, medium, and small.
- [ ] #2 The small cover is 80 px wide for the Presto record-list cover, the medium cover is 460 px wide for the Presto record-detail cover, the large cover is 1000 px wide, and original is unscaled.
- [ ] #3 The Presto application consumes the API-provided small and medium cover URLs directly and no longer contains client-side cover resizing or JPEG scale-selection logic.
- [ ] #4 Presto documentation and test fixtures describe the new cover contract and no longer refer to the legacy cover URL fields.
- [ ] #5 Relevant Phoenix and Presto tests are updated and pass.
- [x] #1 Collection API record JSON exposes four named cover variants: original, large, medium, and small.
- [x] #2 The small cover is 80 px wide for the Presto record-list cover, the medium cover is 460 px wide for the Presto record-detail cover, the large cover is 1000 px wide, and original is unscaled.
- [x] #3 The Presto application consumes the API-provided small and medium cover URLs directly and no longer contains client-side cover resizing or JPEG scale-selection logic.
- [x] #4 Presto documentation and test fixtures describe the new cover contract and no longer refer to the legacy cover URL fields.
- [x] #5 Relevant Phoenix and Presto tests are updated and pass.
<!-- AC:END -->
## Implementation Plan
@@ -59,3 +59,25 @@ Target state: each API record representation exposes four named cover variants:
3. Update documentation, fixtures, and smoke/contract tests so the API and device assumptions stay aligned.
4. Run the focused controller tests and Presto syntax/smoke tests; note that physical Presto behavior is not verified unless the device deployment task is run on hardware.
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Both implementation subtasks are now Done. `ML-185.1` updated the collection API to emit `covers.original`, `covers.large`, `covers.medium`, and `covers.small`. `ML-185.2` updated the Presto app to consume `covers.small` and `covers.medium`, use an 80 px row cover and centered 460 px detail cover, and remove JPEG resizing/scale-selection logic. Focused Phoenix controller tests and Presto syntax/smoke tests passed. Physical Presto hardware was not tested.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Completed the artwork handling simplification across the collection API and Presto client.
The API now exposes named cover variants: `original` unscaled, `large` at 1000 px, `medium` at 460 px, and `small` at 80 px. The legacy flat cover fields were removed from the collection JSON contract.
The Presto app now consumes `covers.small` for record rows and `covers.medium` for detail pages, centers the 460 px detail cover in the 480 px display, and no longer performs JPEG dimension probing or scale-selection resizing on-device. Documentation, guidance, mock fixtures, and smoke tests were updated for the new contract.
Tests run across the subtasks: `mix test test/music_library_web/controllers/collection_controller_test.exs`; Presto syntax check; `mise run test` from `presto/`. Physical Presto hardware was not tested.
<!-- SECTION:FINAL_SUMMARY:END -->
@@ -1,10 +1,11 @@
---
id: ML-185.2
title: Use API-sized covers in Presto
status: To Do
assignee: []
status: Done
assignee:
- Codex
created_date: "2026-05-15 21:22"
updated_date: "2026-05-15 21:40"
updated_date: "2026-05-15 21:53"
labels:
- presto
- artwork
@@ -39,12 +40,12 @@ Context for implementer: `presto/main.py` currently renders record-list covers a
<!-- AC:BEGIN -->
- [ ] #1 Record-list rows fetch and draw the API-provided 80 px small cover variant.
- [ ] #2 Record-detail pages fetch and draw the API-provided 460 px medium cover variant centered within the 480 px display.
- [ ] #3 Presto image drawing no longer selects JPEG scale flags or resizes covers to fit a bounding box.
- [ ] #4 Missing or failed cover downloads still render placeholders, and drag redraws still avoid network fetches.
- [ ] #5 Presto README, Presto guidance, and smoke-test fixtures match the new named cover contract.
- [ ] #6 The Presto syntax check and smoke tests pass, with physical device verification only claimed if run on the device.
- [x] #1 Record-list rows fetch and draw the API-provided 80 px small cover variant.
- [x] #2 Record-detail pages fetch and draw the API-provided 460 px medium cover variant centered within the 480 px display.
- [x] #3 Presto image drawing no longer selects JPEG scale flags or resizes covers to fit a bounding box.
- [x] #4 Missing or failed cover downloads still render placeholders, and drag redraws still avoid network fetches.
- [x] #5 Presto README, Presto guidance, and smoke-test fixtures match the new named cover contract.
- [x] #6 The Presto syntax check and smoke tests pass, with physical device verification only claimed if run on the device.
<!-- AC:END -->
## Implementation Plan
@@ -58,3 +59,25 @@ Context for implementer: `presto/main.py` currently renders record-list covers a
5. Update `presto/README.md`, `presto/AGENTS.md`, and test mock records to describe and exercise the new contract.
6. Run `python3 -c "import py_compile; py_compile.compile('main.py', cfile='/tmp/main.pyc', doraise=True)"` from `presto/` and `mise run test` for the Presto smoke suite.
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Updated the Presto cover path to consume only the collection API `covers` object: row covers use `covers.small`, detail covers use `covers.medium`, and the detail cover layout is now 460 px wide and centered at x=10 on the 480 px display. Removed JPEG dimension probing and scale-selection logic so `draw_jpeg` decodes API-sized JPEGs at the requested position and uses the provided dimensions only for placeholder fallback. Preserved row/detail byte cache separation and drag-time placeholder behavior. Ran `python3 -c "import py_compile; py_compile.compile('main.py', cfile='/tmp/main.pyc', doraise=True)"` and `mise run test` from `presto/`; both passed. Physical Presto hardware was not tested.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Updated the Presto app to trust the API-provided cover sizes. Record rows now read `covers.small`, record detail pages read `covers.medium`, and the detail cover is 460 px wide and centered within the 480 px display.
Removed the JPEG dimension probing and scale-selection code from `draw_jpeg`; it now decodes API-sized JPEGs directly and only uses placeholder dimensions when a fetch or decode fails. Existing row/detail image caches and no-network-during-drag behavior are preserved.
Updated Presto guidance, README API examples, and smoke-test fixtures for the new cover contract, and added a focused smoke test assertion for the expected 80 px row cover and 460 px centered detail cover.
Tests run: Presto syntax check and `mise run test` from `presto/` (8 passed). Physical device behavior was not verified on hardware.
<!-- SECTION:FINAL_SUMMARY:END -->