Files
music_library/backlog/tasks/ml-185.2 - Use-API-sized-covers-in-Presto.md
T
2026-05-15 22:56:22 +01:00

84 lines
4.7 KiB
Markdown

---
id: ML-185.2
title: Use API-sized covers in Presto
status: Done
assignee:
- Codex
created_date: "2026-05-15 21:22"
updated_date: "2026-05-15 21:53"
labels:
- presto
- artwork
dependencies:
- ML-185.1
documentation:
- docs/project-conventions.md
- presto/AGENTS.md
- presto/README.md
modified_files:
- presto/main.py
- presto/README.md
- presto/AGENTS.md
- presto/tests/conftest.py
- presto/tests/test_screens.py
parent_task_id: ML-185
priority: medium
ordinal: 21000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Update the Presto application so it trusts the collection API to provide display-ready cover sizes.
Context for implementer: `presto/main.py` currently renders record-list covers at 80 px and record-detail covers at 480 px. It currently chooses among `mini_cover_url`, `micro_cover_url`, and `thumb_url`, then `draw_jpeg/5` selects JPEG scale flags to fit images into a bounding box. After the API task is complete, records should expose named covers where `small` is the 80 px row cover and `medium` is the 460 px detail cover. Update the detail cover layout to draw the 460 px image centered in the 480 px display so it does not fill the full view width. Preserve existing cover byte caching, placeholder rendering, and the rule that drag redraws must not fetch images over the network.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [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
<!-- SECTION:PLAN:BEGIN -->
1. Add small helper(s) for reading the named cover object from API records, returning `small` for list rows and `medium` for detail pages.
2. Replace legacy `mini_cover_url` / `micro_cover_url` / `thumb_url` selection and preload checks with the new named cover helpers.
3. Simplify JPEG drawing so it decodes the already-sized image at the requested top-left coordinate and falls back to a placeholder on failures; remove `_jpeg_scale_options` and max-width/max-height fitting behavior.
4. Keep row and detail image cache keys separate and preserve the existing drag behavior that shows placeholders when data is not already cached.
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 -->