Skip to content

State

state

Defines a mutable cross-panel state for the GUI

Usage
  • Stores the user's configuration so that the UI doesn't have to re-load the .env on every panel

  • Holds the UI's internal state, such as whether or not an action is happening (busy)

  • Holds objects that should be accessible from any panel, such as the callback function to display a toast notification on the application-scoped NotificationBar (notify)

AppState dataclass

The GUI's Current Working State

Attributes:

Name Type Description
notify Callable[[str, str], None]

The callback function attached to the application-scoped NotificationBar that triggers the display of a toast notification when called

set_busy Callable[[bool], None]

The callback function that locks/unlocks the navigation and panel buttons while a long-running action is in progress to prevent the user from changing the configuration or navigating away mid-action

backend Backend

The chosen mirumoji transcription backend

source ImageSource

Whether to pull pre-built images or build locally

env_path Path

Path to the managed user configuration file (.env)

env dict[str, str]

Resolved environment variables (from env_path)

busy bool

Whether a long-running action is in progress

panel_sync dict[int, Callable[[], None]]

Per-panel refresh callbacks, keyed by navigation index, that re-read the managed user configuration into the panel's display elements whenever the main page shows it again

load_deployment(env)

Adopts the persisted backend / image-source choice from env

Values that are missing or unrecognised leave the current selection unchanged

Parameters:

Name Type Description Default
env Mapping[str, str]

The resolved environment values

required

register_sync(index, refresh)

Registers a panel's refresh callback under its navigation index

A panel is built once and then cached, so anything it renders from the managed configuration goes stale as soon as another panel changes it. Registering here is what makes the main page refresh it on every visit

Parameters:

Name Type Description Default
index int

The panel's navigation index

required
refresh Callable[[], None]

Re-reads the configuration into the panel's display elements

required

sync_panel(index)

Runs a panel's refresh callback, if it registered one

Parameters:

Name Type Description Default
index int

The panel's navigation index

required