Skip to content

Lua scripting API v5: data reads, actions, timers, storage, events, navigation, and custom screens#363

Merged
LargeModGames merged 1 commit into
mainfrom
feature/lua-api-v5
Jul 10, 2026
Merged

Lua scripting API v5: data reads, actions, timers, storage, events, navigation, and custom screens#363
LargeModGames merged 1 commit into
mainfrom
feature/lua-api-v5

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Jul 10, 2026

Copy link
Copy Markdown
Owner

What's new

A major expansion of the Lua plugin API (v4 shipped in #302), made this a while ago but forgot to merge it:

  • Async data reads: get_playlists, get_queue, get_search_results, get_saved_tracks/albums/shows, get_recently_played, get_devices, get_lyrics, all with the (data, err) callback convention.
  • More actions: set_repeat/cycle_repeat, transfer_playback, play_uri/play_context, add_to_queue, playlist create/edit, and save/follow actions.
  • Timers: set_timeout, set_interval, cancel_timer.
  • Per-plugin storage: JSON-backed storage_get/set/remove/keys.
  • Navigation: navigate, back, current_route, plus a config() read of the user config.
  • New events: shuffle_change, repeat_change, device_change, search_results, route_change.
  • Custom screens: register_screen/set_screen/show_screen/close_screen with paragraph/list/gauge widgets and per-key callbacks (new RouteId::PluginScreen / ActiveBlock::PluginScreen, src/tui/ui/plugin_screen.rs, example plugin examples/plugins/queue-browser.lua).

Documented in docs/scripting.md.

Notes

Testing

  • cargo fmt, cargo clippy -- -D warnings (with and without scripting), and cargo test --no-default-features --features telemetry,scripting (572 tests) all pass.

Plugins can now read app data, drive most of the app, and build their
own screens:

- Async data reads with a (data, err) callback convention, backed by
  per-domain generation counters bumped at network write sites:
  get_playlists, get_queue, get_search_results, get_saved_tracks,
  get_saved_albums, get_saved_shows, get_recently_played, get_devices,
  get_lyrics (15s timeout). Cached sync reads: playlists(), queue(),
  search_results(). New GetDevicesSilent/GetRecentlyPlayedSilent
  IoEvents keep plugin reads from navigating the UI.
- Actions routed through whitelisted IoEvents: set_repeat/cycle_repeat,
  transfer_playback, play_uri, play_context, add_to_queue,
  create_playlist, playlist_add_track, playlist_remove_track,
  follow/unfollow_playlist, toggle_save_track, save/unsave_album,
  save/unsave_show, follow/unfollow_artist.
- Timers: set_timeout/set_interval/cancel_timer, fired from the tick
  loop with intake queues, skip-missed-period rescheduling and
  one-strike removal of erroring intervals.
- Plugin-scoped persistent storage (storage_get/set/remove/keys), one
  flat JSON file per plugin under plugin-data/, throttled flush plus
  forced flush on quit via temp-file + rename.
- New events: shuffle_change, repeat_change, device_change,
  search_results, route_change ({name} arg); navigation via
  navigate(target)/back()/current_route() with a whitelist that
  mirrors the matching keybindings.
- Retained-mode custom screens: register_screen with on_key/on_open/
  on_close, set_screen with paragraph/list/gauge widgets,
  show_screen/close_screen (ownership-checked), keys forwarded as
  config.yml-style strings, RouteId::PluginScreen routing plus a
  dedicated renderer and handler.
- config() read exposing theme colors and safe behavior scalars
  (secrets excluded).
- docs/scripting.md v5 sweep, queue-browser.lua example, changelog.

API_VERSION 4 -> 5 (additive; all v4 snapshot fields preserved).
@LargeModGames LargeModGames merged commit 769efda into main Jul 10, 2026
15 checks passed
@LargeModGames LargeModGames deleted the feature/lua-api-v5 branch July 10, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant