Skip to content

Refactor 5/6: menu parts, redraws and effects; Stash workers; locations - #100

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

seaweeduk merged 1 commit into
masterfrom
refactor/wave-4

Conversation

@seaweeduk

Copy link
Copy Markdown
Owner

Fifth layer of the structural refactor: the menu's buttons get a part kind, redraws are decided by grouped comparisons the compiler checks, what the menu changes goes through one services object, the Stash workers share one worker, and locations get one place. Nothing changes for users.

Steps in this layer: M7, M8, M9, D4, D5, D7, plus their review fixes.

M7: buttons drawn by a part kind. Button's draw flags and look fields become one PartKind and one look, and drawButtonContent is one switch on the kind. Button goes from 90 fields to 78, and drawButtonContent from 273 lines to 131. The list's "scroll to this row" is one ListViewport::setPosition.

M8: redraws decided by groups. MenuView's fields are grouped by what a change of them redraws. A field left out of the layout group's comparison doesn't compile:

// Every field, in order: one added to MenuViewLayout and not named here
// doesn't compile.
inline bool operator==(const MenuViewLayout& a, const MenuViewLayout& b) {
  const auto fields = [](const MenuViewLayout& v) {
    const auto& [halfPacked, passthrough, colourKey, /* ...all 63 */ deletable] = v;
    return std::tie(halfPacked, passthrough, colourKey, /* ... */ deletable);
  };
  return fields(a) == fields(b);
}

The Stash settings, ControlMap and GestureMap reach the menu by pointer instead of being copied into the view every frame (two or three copies of each per frame before, none now). The redraw decision is the same field for field.

M9: what the menu changes goes through MenuServices. Ratings, the download queue, saved logins, SFTP host keys and the five sign-ins that run on detached threads go through one struct set at start-up. The menu holds the library and the downloads by const pointer, so a change that skips the services doesn't compile. No effect became a command; MenuCommand is unchanged.

D5: one worker for Stash sync, write-back and folder finding. StashWorker<Shared> owns the thread, the lock, the wake and the stop, and stops and joins in its destructor. Each class keeps its own poll(), which differ. Teardown against a server that never answers takes as long as before.

D4: one place says what a location is. location holds isStream() (a link or a Stash scene) and isLink() (a link only), which were two functions with the same name, and one parentFolder() for files, SMB, SFTP and links. Listing, stat, read and remove stay with their callers: each one differs on purpose (stat vs lstat, what counts as missing, size limits), so joining them would change behaviour. Library keys come out the same for 227 test addresses.

D7: ranges in one place. Every setting's range and step is in value_ranges.h, used by the read, the command and the menu row. settings.conf comes out byte-identical.

Review fixes. The folder finder stops before its last wake again. A default MenuView points at default settings, not null. The browser's fade-in readiness takes only the Offline look, as before M7. One setter installs the menu's services and what it reads.

Before After
Button fields 90 78
drawButtonContent lines 273 131
Menu::update lines 217 185
Settings parts copied per frame 6 or 7 0
Functions of 200+ lines 26 24

Known and left as is

  • StashWorker::hand() publishes shared work under its mutex before notifying. The later folder and write-back bookkeeping stays on the main thread, and the worker's wait predicate also sees work queued before startup.

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 grouped comparisons preserve the distinction between full menu redraws and slider- or strip-only updates. Separate settings snapshots keep an in-progress browser redraw consistent without copying unchanged settings every frame. The Stash workers still publish work under the mutex and stop before joining, and the location helpers preserve the existing library keys and playback behavior for files, links, and Stash scenes.

github run

@seaweeduk
seaweeduk force-pushed the refactor/wave-3 branch 2 times, most recently from 15c0f33 to c684f02 Compare November 22, 2026 20:59
@seaweeduk
seaweeduk changed the base branch from refactor/wave-3 to master November 22, 2026 20:59
@seaweeduk
seaweeduk merged commit ba28653 into master Nov 22, 2026
1 check passed
@seaweeduk
seaweeduk deleted the refactor/wave-4 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