From 3b599f62a307acb3ff3b35adee7a07a53aed93be Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 11 May 2026 07:23:19 +0100 Subject: [PATCH] ML-179.1: track refactor task --- ...ain-loop-navigation-and-event-structure.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 backlog/tasks/ml-179.1 - Tighten-Presto-main-loop-navigation-and-event-structure.md diff --git a/backlog/tasks/ml-179.1 - Tighten-Presto-main-loop-navigation-and-event-structure.md b/backlog/tasks/ml-179.1 - Tighten-Presto-main-loop-navigation-and-event-structure.md new file mode 100644 index 00000000..00b99efd --- /dev/null +++ b/backlog/tasks/ml-179.1 - Tighten-Presto-main-loop-navigation-and-event-structure.md @@ -0,0 +1,52 @@ +--- +id: ML-179.1 +title: Tighten Presto main loop navigation and event structure +status: To Do +assignee: [] +created_date: "2026-05-10 20:30" +updated_date: "2026-05-10 20:30" +labels: [] +dependencies: [] +documentation: + - presto/AGENTS.md + - presto/README.md + - docs/project-conventions.md +modified_files: + - presto/main.py +parent_task_id: ML-179 +priority: medium +ordinal: 7000 +--- + +## Description + + + +Follow-up to ML-179. Continue the single-file, behavior-preserving Presto refactor by completing transition cleanup, moving per-screen event branches out of main(), replacing per-gesture lambda scroll call sites with named wrappers, centralizing common hit tests, and adding explicit reset helpers for grouped state. Keep deployment as one presto/main.py file and avoid user-facing behavior changes. + + + +## Acceptance Criteria + + + +- [ ] #1 All screen transitions in presto/main.py go through navigation helpers or narrowly named transition helpers; direct app.screen assignments outside initialization/navigation are removed. +- [ ] #2 main() remains responsible for boot, sleep/wake, debounce, and top-level dispatch, while search-results, day, and record event handling live in dedicated helper functions. +- [ ] #3 Day, search-results, and record-detail scroll handling use named wrapper functions instead of inline lambda closures at the main dispatch call sites. +- [ ] #4 Shared touch geometry checks such as back, home, and month navigation buttons are centralized in small hit-test helpers and used consistently by handlers. +- [ ] #5 Grouped state reset behavior is expressed through reset helpers or methods for day, search results, and detail state, preserving the existing reset semantics. +- [ ] #6 The change is behavior-preserving for home, month, day, search, record detail, display sleep/wake, image placeholder, and scrobble flows. +- [ ] #7 Presto syntax verification passes with python3 py_compile from the presto directory, and final notes state whether physical-device behavior was verified. + + +## Implementation Plan + + + +1. Inspect the current post-ML-179 `presto/main.py` event dispatch and identify remaining direct screen assignments, duplicated button geometry checks, and inline scroll lambdas. +2. Add small reset helpers or state methods for day-list, search-results, and detail state; update existing navigation helpers to call them without changing reset behavior. +3. Add shared hit-test helpers for common button geometry, including back, home, previous-month, and next-month controls; replace duplicated coordinate checks in main-loop branches and handlers. +4. Add named scroll wrapper functions for search results, day records, and record detail that call the existing shared vertical-drag helper with the correct state accessors and redraw callbacks. +5. Extract search-results, day, and record event branches from `main()` into dedicated event helper functions while keeping boot, sleep/wake, debounce, and top-level screen dispatch in `main()`. +6. 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. +