ML-179.2: track refactor task

This commit is contained in:
Claudio Ortolina
2026-05-11 07:23:55 +01:00
parent 3b599f62a3
commit 2f94657ade
@@ -0,0 +1,54 @@
---
id: ML-179.2
title: Refactor Presto record detail layout preparation
status: To Do
assignee: []
created_date: "2026-05-10 20:30"
updated_date: "2026-05-10 20:30"
labels: []
dependencies:
- ML-179.1
documentation:
- presto/AGENTS.md
- presto/README.md
- docs/project-conventions.md
modified_files:
- presto/main.py
parent_task_id: ML-179
priority: medium
ordinal: 8000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Follow-up to ML-179 and dependent on ML-179.1. Refactor the record detail view so detail measurement, drawing, and scrobble-button positioning share one prepared layout structure. Keep the Presto app single-file in presto/main.py and preserve current record detail behavior, scrolling, image loading, and scrobble UX.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Record detail rendering uses one prepared layout representation for title, artists, cover, genres, metadata, purchased date, and optional scrobble button positioning.
- [ ] #2 Detail content height and scrobble-button bounds are derived from the prepared layout rather than duplicated formulas in separate measure, draw, and hit-test paths.
- [ ] #3 Drag redraws for the detail view reuse prepared layout data and do not measure text, join display strings, sanitize text, compute layout heights, or fetch images in the scroll hot path.
- [ ] #4 Detail cover image behavior is preserved: prefer thumb_url then mini_cover_url then micro_cover_url, cache bytes separately from row thumbnails, and show placeholders during drag or failures as before.
- [ ] #5 Back navigation from detail to day or search results preserves the existing source-screen behavior and reset semantics from ML-179.1.
- [ ] #6 The change is behavior-preserving for detail display, detail scrolling, scrobble button visibility, scrobble tap handling, and image placeholder behavior.
- [ ] #7 Presto syntax verification passes with python3 py_compile from the presto directory, and final notes state whether physical-device behavior was verified.
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Start after ML-179.1 is complete so the detail event path, navigation helpers, and reset semantics are already tightened.
2. Inspect current detail functions in `presto/main.py`, especially `draw_record_detail`, `_measure_detail_content`, `_draw_detail_title_artists`, `_draw_detail_info_below_cover`, `_scrobble_button_hit_test`, and cover drawing.
3. Introduce a compact prepared detail layout structure stored on detail state or on the selected record dict, containing sanitized/wrapped display lines, section heights, total content height, and optional scrobble-button content-relative bounds.
4. Update detail preparation to run when a record detail page is opened, when selected record/layout data is missing, or when content must be refreshed; do not run it inside drag redraw hot paths.
5. Update detail drawing to consume the prepared layout for text sections and button placement while preserving clipping, scroll indicators, cover image positioning, and placeholder behavior.
6. Update scrobble hit testing to use the same prepared scrobble-button bounds used by drawing, adjusted by the current detail scroll offset.
7. Run the Presto syntax check from `presto/` using `python3 -c "import py_compile; py_compile.compile('main.py', cfile='/tmp/main.pyc', doraise=True)"` and record whether physical-device behavior was verified.
<!-- SECTION:PLAN:END -->