presto

Architecture

This document is for contributors and maintainers. It describes the core components, how state flows through the program, and the tradeoffs behind a few important design choices.

Code map

Components

Library scan (src/library.rs)

Responsibility: given a directory, return a sorted Vec<Track>.

App state (src/app.rs)

Responsibility: hold all UI state that isn’t “owned” by the audio output.

Key fields (conceptually):

Important invariant: display_indices() is the authoritative list for “what you see” and “what actions operate on”. If rendering, navigation, and playback use different filtering/shuffle logic, you will get hard-to-debug mismatches.

UI (src/ui.rs)

Responsibility: render the screen. The UI is stateless beyond what’s in App.

Audio thread (src/audio.rs)

Responsibility: keep an OutputStream alive and respond to AudioCmd messages.

Reasons for a dedicated thread:

Queue semantics:

Seeking/scrubbing:

Soft quit:

MPRIS (src/mpris.rs)

The MPRIS service maps external commands (media keys, playerctl) into the same control flow as keyboard input. This keeps behavior consistent.

See MPRIS.md for details and troubleshooting.