Skip to content

Refactor 3/6: first features out of the frame loop - #98

Merged
seaweeduk merged 1 commit into
masterfrom
refactor/wave-2
Nov 22, 2026
Merged

seaweeduk merged 1 commit into
masterfrom
refactor/wave-2

Conversation

@seaweeduk

Copy link
Copy Markdown
Owner

Third layer of the structural refactor: the first features leave run() with their own state, the menu pages get one dispatch table, and the data layer loses its copied helpers. Nothing changes for users.

Steps in this layer: A3, A4, A5, A6, A7, M3, D3, D6.

Each feature that leaves run() becomes a class that owns its state and takes the collaborators it needs by reference when it's built. run() keeps a few calls at the same points in the frame as before.

Step New owner What it took out of run()
A3 Deletion the delete request, confirm, cancel and the polling of its two futures
A4 Passthrough Match the room, automatic passthrough and the video checks behind it
A5 StickSeek stick seek and the Scrub gesture's picture; three copies of "end the held seek" became cancel()
A6 RunningVideo the running video's state and its deferred saves (video, volume, Sharpen)
A7 ButtonJobs the controller job switch: press(job, hand, context) returns what to say, show and run
flowchart LR
  F["run(): frame"] -- "Frame{...}" --> S["StickSeek::update"]
  F -- "job, Context" --> J["ButtonJobs::press"] -- "JobAction" --> F
  F --> R["RunningVideo::saveDue"]
  F --> P["Passthrough::settle / poll / fill"]
  F --> D["Deletion::poll"]
Loading
  • M3: one dispatch table for menu pages. Menu::kPages[] has one row per page: its flags (alone, grouped, list, Stash, pictures, thumbnails, kept) and its layout, drawHeading, leave and update. The if-ladders in page layout, drawing, showPage and update, and five per-page predicates, now read the table, and Stash's three second-level switches are gone.
  • D3: one SQLite helper. Statement, exec and userVersion move to sqlite_util and are used by the library, the library index and the Stash store. The library writer's transaction, retry and reused statements don't change.
  • D6: small moves. The --stash-sync diagnostic and StashOutbox get files of their own; four identical curl write callbacks become one; five files use server_json's accessors instead of their own; frame scaling moves to frame_scaler.
Before After
main.cpp lines 4,864 3,990
run() lines 4,296 3,485

ButtonJobs::press is 166 lines: it is the old switch, one case per job with no shared state, moved unchanged.

Known and left as is

  • Delete lookup can start before the slideshow interval is cleared. The detached lookup uses captured file and source values, never the slideshow state.
  • The passthrough save and log don't read the notice timer, and a seek-press buzz only queues haptics. Neither depends on the order of the adjacent state resets.

Important

AI disclosure

Model Variant Role
anthropic/claude-opus-5-5 high Implementation, orchestration
openai/gpt-6.2-astra high Independent review

Agent harness OpenCode 2.3.2

@seaweeduk seaweeduk added the skip-changelog Left out of release notes label Nov 22, 2026
@opencode-agent

Copy link
Copy Markdown

LGTM 👍

The extracted features preserve the frame-loop ordering that matters: delete confirmation still checks the playing file, seek cancellation keeps its pause and resume behavior, and deferred settings are saved before playback switches files. The menu dispatch table retains each page’s layout, redraw, and navigation behavior. The shared data helpers leave database schemas, transaction boundaries, and download limits unchanged.

github run

@seaweeduk
seaweeduk changed the base branch from refactor/wave-1 to master November 22, 2026 20:59
@seaweeduk
seaweeduk merged commit e72b938 into master Nov 22, 2026
@seaweeduk
seaweeduk deleted the refactor/wave-2 branch November 22, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Left out of release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant