---
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-16 20:23"
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 named cover URLs while keeping the intended Presto detail-cover layout.

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 detail cover source. Preserve the intended `DETAIL_COVER_SIZE = px(200)` 400 px detail-cover layout. 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 `covers.medium` and keep the intended `DETAIL_COVER_SIZE = px(200)` 400 px detail-cover layout area 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 named cover contract and intended 400 px detail-cover layout.
- [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 named 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 while preserving `DETAIL_COVER_SIZE = px(200)`.
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 named cover contract and intended 400 px detail-cover layout.
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 uses the intended `DETAIL_COVER_SIZE = px(200)` 400 px area centered at x=40 on the 480 px display. Removed JPEG dimension probing and scale-selection logic so `draw_jpeg` decodes named 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. This record was corrected after the detail cover layout was confirmed to be 400 px rather than 460 px.

<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->

Updated the Presto app to trust the API-provided cover names. Record rows now read `covers.small`, record detail pages read `covers.medium`, and the detail cover layout remains the intended `DETAIL_COVER_SIZE = px(200)` 400 px area centered within the 480 px display.

Removed the JPEG dimension probing and scale-selection code from `draw_jpeg`; it now decodes named 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 named cover contract, and added a focused smoke test assertion for the expected 80 px row cover and 400 px centered detail-cover layout.

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 -->
