Skip to content

feat(gui): answer the first-launch questions in the page - #584

Merged
LargeModGames merged 3 commits into
feat/gui-frontendfrom
feat/gui-onboarding
Sep 26, 2026
Merged

LargeModGames merged 3 commits into
feat/gui-frontendfrom
feat/gui-onboarding

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Until now spotatui-gui could not run the first-launch setup: every question failed boot with a hint to run the terminal spotatui once. This moves those questions into the page. The listener now starts before boot and serves only the questions until boot is done. Boot asks each question through a blocking Onboarding that waits for the page's reply.

What changed:

  1. src/gui/onboarding.rs adds BrowserOnboarding. It keeps an OnboardingView (the transcript and the open question) in a watch channel. ask_page blocks until a reply with the open question's seq arrives, and answer drops any other reply. A typed line comes back the way read_line returns it.
  2. launch_gui starts the listener and opens the browser before bootstrap::boot, and passes BrowserOnboarding to it. TerminalSetupRequired and its test are removed. After boot the app is published through a watch (SharedApp), and each open socket resyncs once.
  3. ServerMessage::Onboarding sends the view on connect and on every change. ClientMessage::Onboarding carries an OnboardingReply. run_socket handles it itself, because the tick loop does not exist during boot. The TypeScript bindings are regenerated.
  4. Onboarding::prompt_masked defaults to prompt_line. configure_subsonic reads the password through it, and OnboardingAsk::Line carries masked. (The name avoids CodeQL's sensitive-name heuristic, which reported the path log lines that the config later reaches.)
  5. Source::note moves from tui/first_run.rs to core::source, so the page and the terminal picker show the same text.
  6. Publisher::alone_since is now an Option set at the tick loop's first check, so boot time no longer counts toward the minute without a page.
  7. The page adds Onboarding.tsx (a text or password field, yes/no buttons, source checkboxes) and showsOnboarding. Answer buttons are disabled while the socket reconnects.

Deliberate behaviour changes a user can see:

  1. A first launch of spotatui-gui asks the song-counter opt-in, the source picker, the Subsonic login, the Spotify app setup and the manual OAuth paste in the browser.
  2. The browser opens before boot, and the page shows the setup transcript while boot runs.
  3. The Subsonic password is a password field in the page. The terminal still reads it as a plain line.
  4. A question gives up after a minute with no page connected, and boot fails with "no browser page is connected".
  5. A boot error is written to the page. The process waits up to a minute for a page to connect, exits 2 s later, and the closed page keeps the transcript above its notice.

Testing

The suites ran on the top of the stack (feat/gui-onboarding), which contains this PR:

  • cargo fmt --all -- --check: clean.
  • cargo clippy --locked -- -D warnings on slim, headless, headless-streaming, mcp-only, ai-dj-only, default, the gui leg and the five-sources set with audio-viz-cpal: all Finished, no warnings.
  • cargo test --locked, 0 failed on every leg: slim 1253 passed, headless 851 passed, mcp-only 1377 passed, ai-dj-only 1530 passed (the four dead-code warnings in infra/dj test helpers predate this stack), default 1630 passed, gui leg 1369 passed.
  • Bindings drift after the gui leg test: git status --porcelain gui/src/bindings prints nothing.
  • In gui/: npm ci (found 0 vulnerabilities), npm run lint, npm run format:check (All matched files use Prettier code style!), npm run typecheck, npm test (Tests 21 passed (21)), npm run build (✓ built).

On this PR's own head (the top): cargo clippy --locked -- -D warnings on slim, headless, default and the gui leg: clean. cargo test --no-default-features --features telemetry,tui gates: ok. 10 passed. bash tools/check_gates_ratchet.sh against the PR below: ok.

Additional notes

Part 7 of 7 of a stack (#578 to #584). Base: #583.

The page and the question layout are still placeholders that exercise the bridge. Designed screens replace them later.

A live first run on an empty profile worked on Windows before the rebase onto #574 and #577. After it, #577's notice about a forgotten key tier also goes through Onboarding::info, so it lands in the page transcript; that path is not seen live yet. Not run: a first run on Linux or macOS.

Known trade-offs: a boot error that no page receives within a minute is only in the log, and the error line in the page does not name the log file. A question waits for as long as a page stays connected.

Follow-up: spotatui-gui still boots with no_update: true, so it does not update itself.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • New Features
    • First-time setup can now be completed in the browser, including server details, password entry, confirmations, and music source selection.
    • Passwords are masked during browser setup.
    • Music source options now include notes about cost or setup requirements.
  • Bug Fixes
    • Browser setup questions remain available when the app is still starting, and setup errors are shown in the onboarding flow.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e8386f42-9b5f-41da-b874-6646168a9886

📥 Commits

Reviewing files that changed from the base of the PR and between 898af80 and b612ebe.

📒 Files selected for processing (30)
  • .github/copilot-instructions.md
  • AGENTS.md
  • CLAUDE.md
  • gui/src/App.tsx
  • gui/src/Onboarding.test.tsx
  • gui/src/Onboarding.tsx
  • gui/src/bindings/ClientMessage.ts
  • gui/src/bindings/OnboardingAsk.ts
  • gui/src/bindings/OnboardingQuestion.ts
  • gui/src/bindings/OnboardingReply.ts
  • gui/src/bindings/OnboardingReplyAnswer.ts
  • gui/src/bindings/OnboardingView.ts
  • gui/src/bindings/ServerMessage.ts
  • gui/src/bindings/SourceChoice.ts
  • gui/src/connection.test.ts
  • gui/src/connection.ts
  • gui/src/style.css
  • src/core/first_run.rs
  • src/core/onboarding.rs
  • src/core/source.rs
  • src/core/test_helpers.rs
  • src/gui/bridge.rs
  • src/gui/mod.rs
  • src/gui/onboarding.rs
  • src/gui/protocol.rs
  • src/gui/server.rs
  • src/runtime/bootstrap.rs
  • src/runtime/gui.rs
  • src/tui/first_run.rs
  • tools/gates.count

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 982420a3-e01f-431e-a331-1e8aca144b09

📥 Commits

Reviewing files that changed from the base of the PR and between faac38f and 898af80.

📒 Files selected for processing (30)
  • .github/copilot-instructions.md
  • AGENTS.md
  • CLAUDE.md
  • gui/src/App.tsx
  • gui/src/Onboarding.test.tsx
  • gui/src/Onboarding.tsx
  • gui/src/bindings/ClientMessage.ts
  • gui/src/bindings/OnboardingAsk.ts
  • gui/src/bindings/OnboardingQuestion.ts
  • gui/src/bindings/OnboardingReply.ts
  • gui/src/bindings/OnboardingReplyAnswer.ts
  • gui/src/bindings/OnboardingView.ts
  • gui/src/bindings/ServerMessage.ts
  • gui/src/bindings/SourceChoice.ts
  • gui/src/connection.test.ts
  • gui/src/connection.ts
  • gui/src/style.css
  • src/core/first_run.rs
  • src/core/onboarding.rs
  • src/core/source.rs
  • src/core/test_helpers.rs
  • src/gui/bridge.rs
  • src/gui/mod.rs
  • src/gui/onboarding.rs
  • src/gui/protocol.rs
  • src/gui/server.rs
  • src/runtime/bootstrap.rs
  • src/runtime/gui.rs
  • src/tui/first_run.rs
  • tools/gates.count
💤 Files with no reviewable changes (1)
  • src/runtime/bootstrap.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

GUI startup now opens the browser before boot and uses it to collect first-run answers. The socket protocol carries onboarding questions and replies. The frontend displays the transcript and prompt controls, while the bridge publishes onboarding state and later resynchronizes app state.

Changes

Browser onboarding

Layer / File(s) Summary
Core prompts and source details
src/core/onboarding.rs, src/core/first_run.rs, src/core/test_helpers.rs, src/core/source.rs, src/tui/first_run.rs
The onboarding trait adds a masked prompt method, and Subsonic setup uses it for the password. Source notes are defined on Source and displayed by both terminal pickers. Tests record masked prompts.
Browser prompt and reply handling
src/gui/protocol.rs, src/gui/onboarding.rs, src/gui/mod.rs, gui/src/bindings/*
The protocol adds onboarding messages and payload types. BrowserOnboarding publishes transcript and pending-question state, accepts sequenced replies, and handles line, masked, confirmation, and source-selection prompts.
Socket bridge and pre-boot connections
src/gui/bridge.rs, src/gui/server.rs
The bridge sends onboarding state to connected pages, handles replies, and resynchronizes app state when boot completes. Tests cover pre-boot connections and app publication.
GUI startup and boot integration
src/runtime/gui.rs, src/runtime/bootstrap.rs, .github/copilot-instructions.md, AGENTS.md, CLAUDE.md, tools/gates.count
GUI startup starts the listener before boot and passes browser onboarding to boot. Boot errors are reported through onboarding; successful boot publishes the app. The architecture descriptions and adoption baseline are updated, and a GUI-only bootstrap test is removed.
Frontend onboarding state and controls
gui/src/connection.ts, gui/src/connection.test.ts, gui/src/App.tsx, gui/src/Onboarding.tsx, gui/src/Onboarding.test.tsx, gui/src/style.css
The frontend stores onboarding views and displays the transcript and pending question before route arrival or while a question remains. It renders line, masked, confirmation, and source-selection controls, with submissions disabled while disconnected.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant launch_gui
  participant BrowserOnboarding
  participant bridge_channel
  participant BrowserPage
  participant bootstrap_boot
  launch_gui->>bridge_channel: Start listener with browser onboarding
  launch_gui->>BrowserPage: Open access-code URL
  launch_gui->>bootstrap_boot: Boot with browser onboarding
  bootstrap_boot->>BrowserOnboarding: Request first-run answers
  BrowserOnboarding->>bridge_channel: Publish onboarding view
  bridge_channel->>BrowserPage: Send pending question
  BrowserPage->>bridge_channel: Send sequenced reply
  bridge_channel->>BrowserOnboarding: Deliver onboarding reply
  BrowserOnboarding-->>bootstrap_boot: Return prompt answer
  launch_gui->>bridge_channel: Publish app after successful boot
Loading

Merge Risk: ⚪ Minimal · up to 898af

No concrete merge-blocking issue was established for browser onboarding. Normal checks can proceed, though shutdown behavior on a serve error remains unverified.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 898af

First-run setup now accepts answers from any browser connection admitted to the GUI session, including another page opened during setup. Those answers can determine saved source and credential settings. Access to the session is restricted, but the ownership of each setup decision is not tied to the page that began it.

Retained concerns

  • Medium · security · observed: A pending first-run question belongs to the shared GUI session rather than an initiating connection. A second admitted page can answer it, and accepted answers can affect persistent setup settings. This is conditional on possession of a valid session credential, not an established unauthenticated bypass.
Security review details

Security Blast Radius

  • inferred — The new decision surface is limited to clients admitted to this local GUI session, but a matching reply can influence first-run source state or saved service credentials, not merely page display.

Security Findings and Attack Paths

  • inferred — A second client possessing a valid GUI session credential can observe the current question and race to supply its answer. The demonstrated cross-page behavior establishes the path, but the evidence does not establish acquisition of that credential by an unauthorised attacker.

Trust Boundaries and Controls

  • observed — Host and Origin validation, loopback binding, launch-code or token admission, sequence matching, and answer-kind checks constrain the path. None of the inspected reply checks binds an accepted answer to a particular admitted page.

Resilience and Maintainability Implications

  • inferred — The no-page timeout contains an unattended prompt, but it does not revoke an open question when one page leaves and another admitted page remains. Setup state saved before later prompts also makes interruption a recovery consideration.

Hardening Proposals

  • proposed — Decide explicitly whether any admitted page may complete first-run setup. If setup should have one owner, bind pending questions and reply acceptance to that owner, and define how ownership transfers on disconnect and reconnect.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the allowed conventional-commit prefix feat(gui):, clearly describes the browser onboarding change, and uses a concise imperative subject.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.73684% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/source.rs 0.0% 9 Missing ⚠️
src/core/first_run.rs 63.1% 7 Missing ⚠️
src/core/onboarding.rs 0.0% 3 Missing ⚠️
src/tui/first_run.rs 0.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

Two spotatui instances at once share one state directory and one Connect
device id. Both write `mcp.json`, `last_session.yml` and the playlist
sync, and the listening history counts every listen twice. A UI launch
now takes an OS file lock first, so a second instance exits before it
writes any shared state. CLI subcommands never take the lock.

What changed:

1. New `src/runtime/instance.rs`. `acquire` locks `<state
dir>/instance.lock` with std `File::try_lock` and writes the holder's
pid to `instance.pid` for the refusal message. The locked `File` is the
guard; the OS releases it at process exit.
2. `run_cli` takes the lock only when `instance::takes_lock` sees no
subcommand, after the `--completions` and `update` early returns and
before the legacy state migrations. The module is gated on `tui`.
3. `boot` lends the guard to `restart_after_update`, which drops it just
before it runs the updated binary and waits on it, so the child can take
the lock.
4. The refusal is a typed `AlreadyRunning` error, and `run_cli` skips
the log-file notice for it. That notice (from #574) tells the user to
rerun with `--debug` before reporting a bug, which is wrong for an
expected refusal.
5. `clear_handshake` (`src/infra/mcp/control.rs`) deletes `mcp.json`
only when the file's `pid` is this process.
6. `Cargo.toml` declares `rust-version = "1.90"`. `File::try_lock` needs
1.89; the 1.90 floor is `quantette` 0.5.1, which `cover-art` pulls in
through `ratatui-image`.
7. Four tests (`test_attribute_total` 2224 to 2228), a CHANGELOG entry
and the `instance.rs` row in `CLAUDE.md`, `AGENTS.md` and
`.github/copilot-instructions.md`.

Deliberate behaviour changes a user can see:

1. A second instance exits at once with "spotatui is already running
(pid N)" and a hint to quit the running one first.
2. `--reconfigure-auth` and `--play-file` are UI launches and are
refused too, so the in-app hints to run `spotatui --reconfigure-auth`
now need the running instance quit first.
3. A second instance with a different `-c/--config` is refused as well:
the state directory does not follow `--config`.
4. The state directory gets `instance.lock` and `instance.pid`. Both
stay after exit and never block the next launch.
5. With `mcp-server`, an instance no longer deletes an `mcp.json`
another process wrote. A stale file from a killed instance stays until
an instance with MCP on replaces it; the relay already reports it as
stale.
6. Building from source needs Rust 1.90 or newer.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless and default: clean. `cargo test --no-default-features
--features telemetry,tui gates`: `ok. 10 passed`. `bash
tools/check_gates_ratchet.sh main`: `ok`. `cargo test ... instance`:
`ok. 3 passed`.

# Additional notes

Part 1 of 7 of a stack (#578 to #584). Base: main.

Rebased on #574 and #577. The only interaction is item 4: #574's
`run_cli` prints the log-file notice after any failed run.

Not run here: the lock tests on Linux and macOS (CI runs the Linux legs;
the macOS job only builds). The 1.90 floor comes from my local registry,
which lacks some Linux-only and macOS-only crates, so one of those can
still need a newer Rust. Still to run: a live pass with two instances
and `spotatui playback` beside one.

Known trade-offs:

- Only a held lock refuses. When the lock file cannot be opened or the
filesystem cannot lock, the instance starts unlocked with a log warning.
- `instance.pid` is written after the lock is taken, so a refusal during
a racing launch can name the previous holder or omit the pid.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* UI launches now prevent a second application window from starting and
display the running process ID when available. CLI subcommands remain
usable while a window is open.
* **Bug Fixes**
* Handshake cleanup now leaves files untouched if they are malformed,
unreadable, or belong to another process.
  * Update restarts release the single-instance lock before relaunching.
* **Compatibility**
  * Source builds now require Rust 1.90 or later.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

This splits the terminal launch into the steps every frontend needs and
the steps only the terminal needs. `boot` stops reading clap matches,
and the startup and exit work that `launch_ui` and `start_ui` ran around
the terminal loop moves into two functions in `src/runtime/startup.rs`.
A second frontend can then call them instead of copying about 95
order-sensitive lines of the exit path.

What changed:

1. `bootstrap::boot` takes a plain-data `BootOptions` (config path, tick
rate, subcommand name, `--reconfigure-auth`, `--play-file`,
`--no-update`) instead of `&ArgMatches`. `cli::boot_options` builds it,
so `bootstrap.rs` no longer imports clap. `run_auto_update` takes a
`skip: bool`.
2. `prepare_frontend(boot)` is the old body of `launch_ui` up to the
terminal loop: the OS media integrations, the deferred streaming
startup, the session restore and the IoEvent pump task. It returns
`FrontendHandles` and cannot fail.
3. `launch_ui` now builds the `Driver` and lends it to
`runner::start_ui`, which runs only the terminal loop and returns a
`TerminalSession`. The session holds the `Events` reader and the
terminal until the exit path ends, as the old locals did.
`TerminalSession::restore` undoes the terminal setup.
4. The exit path moves out of `start_ui` into `shutdown_frontend`,
together with `park_native_playback_before_exit`. The terminal restore
is a `restore_frontend` hook that runs at its old place: after
`history_collector.shutdown()` and before the cloud sync. The session
and then the `Driver` still drop before `clear_handshake`, and the log
lines keep their order.
5. A new test, `boot_options_carry_the_launch_flags`, pins the argument
mapping (the `-U` case only on builds with `self-update`).
`test_attribute_total` goes from 2228 to 2229.

No behaviour change.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless and default: clean. `cargo test --no-default-features
--features telemetry,tui gates`: `ok. 10 passed`. `bash
tools/check_gates_ratchet.sh` against the PR below: `ok`.

# Additional notes

Part 2 of 7 of a stack (#578 to #584). Base: #578.

Not verified here: the Linux-only MPRIS arm of `FrontendHandles` does
not compile on Windows (the `default` CI leg builds it), and the
`all-sources` test leg and the `macos` job run only in CI. Still to run:
a live terminal launch and quit with native streaming playing, which
covers the moved park, the teardown wait and the terminal restore.

Known trade-off: on the error path, the `HistoryCollectorHandle` now
drops at the end of `launch_ui` instead of when `start_ui` returns. The
only work in between is dropping the `Driver`, `clear_handshake` and the
state flush.

Follow-up: `mod startup` stays gated on `tui` here. The browser frontend
later in this stack widens the gate and calls `prepare_frontend` and
`shutdown_frontend` with an empty restore hook.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Improvements**
* App shutdown now coordinates session and state saving, terminal
restoration, playback cleanup, and history synchronization.
* Cleanup tasks use bounded wait times, helping the app finish shutting
down even when a service or connection is slow.
* Native playback teardown waits briefly for local command connections
to disconnect.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

This gives `App` one revision counter per displayed domain, so a
frontend that does not redraw every frame can tell what changed. Every
build writes the counters. Only `test` and the off-by-default `gui`
feature can read them; `src/gui/bridge.rs` (two PRs up) is the first
reader. It also stops `current_playback_snapshot` from describing the
paused Spotify track while another source starts.

What changed:

1. `DisplayRevisions` (`src/core/app/display_revisions.rs`) is a private
`App` field with a named counter per `DisplayDomain`: `Route`, `Status`,
`Source`, `Theme`, `Playback`. Both matches are exhaustive.
`App::display_revisions()` and `DisplayRevisions::get` are
`cfg(any(test, feature = "gui"))`.
2. Route, Status, Source and Theme bump inside their existing funnels,
and a no-op (a repeat push, a refused pop, an unchanged source or theme)
bumps nothing: `push_navigation_stack`, `pop_navigation_stack`,
`drop_error_routes`, `set_current_route_state`, `set_status_message`,
`set_error_status_message`, `clear_status_message`, `handle_error`,
`clear_api_error`, `set_active_source`, the adaptive-theme fade and
`apply_settings_changes`.
3. `Action::SetTheme` goes through the new `App::set_theme_colors`,
which bumps Theme only when a color changed.
4. `App::note_playback_change` compares the position-free playback view
(the `PlaybackSnapshot` with `progress_ms` zeroed, `desired_volume()`,
the device name, the liked flag) with the last one and bumps Playback on
a difference. It runs at the producer boundaries: the tail of
`Network::handle_network_event`, the pump's source-router branch, the
player event loop (skipping `PositionChanged` and `Preloading`),
`disconnect_streaming_player`, the end of `Driver::tick`, and
`App::apply` (now a wrapper around the old match).
5. `current_playback_snapshot` returns `None` when
`active_decoded_source()` holds but no source session exists yet,
instead of falling through to the suspended Spotify context.

Deliberate behaviour changes a user can see:

1. While Local Files, Subsonic, Internet Radio, YouTube or Qobuz fetches
or probes its first track over a paused Spotify track, the OS media
panels (MPRIS, Windows, macOS), Discord, the lyrics and cover-art panes
and the spotatui.com now-playing card show nothing, and the window title
falls back to the default. The same holds after such a start fails, for
as long as the source keeps its claim on the output. `CHANGELOG.md` has
the entry.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless and default: clean. `cargo test --no-default-features
--features telemetry,tui gates`: `ok. 10 passed`. `bash
tools/check_gates_ratchet.sh` against the PR below: `ok`.

# Additional notes

Part 3 of 7 of a stack (#578 to #584). Base: #579.

- 14 new tests (`test_attribute_total` 2229 to 2243) pin each funnel's
bump and non-bump, a position-only change leaving Playback alone, a
routed `FinishNativeQueue` moving Playback through `start_tokio`, and
the `None` snapshot under a claim.
- No test drives the OS panels, Discord, lyrics, cover art or the
now-playing card through the new arm. They all read the snapshot the
test pins. The MPRIS and macOS Now Playing arms compile only on their
platforms.
- Cost: `note_playback_change` builds and compares a `PlaybackSnapshot`
at every boundary in every build, although only a `gui` build reads the
result.
- The next PR adds the Party, Devices, Search, Lyrics, Artist, Library
and Queue domains and makes their fields private.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Media panels, Discord, the window title, lyrics and cover art, and the
now-playing card no longer show a stale Spotify track while another
source is loading or checking its first track.
- Playback and display updates now stay in sync when tracks, routes,
status messages, or themes change.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
spotatui-gui now opens the page before boot, and every first-launch question (the song-counter opt-in, the source picker, the Subsonic login, the Spotify app setup, the manual OAuth paste) is asked and answered there. A blocking Onboarding sends the transcript and the open question to the page and waits for its reply; a typed line comes back the way read_line returns it, the Subsonic password is a password field, and a question gives up a minute after the last page disconnects. When boot is done the same socket gets every channel. A boot error is written to the page before the process exits.
…rst check

A boot error now waits up to a minute for a page before the process exits, so a browser that starts slowly still shows it. The tick loop's no-page clock starts at its first check, not before boot. A reply is queued only for the open question. The page disables its answer buttons while it reconnects, shows the first-launch transcript on the closed page only before boot, and names each source in the picker with the label and note the terminal picker uses (Source::note moves to core). The screen condition is a tested pure function, and the server tests cover a second page answering an open question and a single resync after boot.
CodeQL treats a value returned by a function named *secret* as sensitive and then taints whole config structs, so it reported three cleartext-logging alerts on log lines that print a token path and a playlist id. None of them logs the password. Onboarding::prompt_secret becomes prompt_masked, and the OnboardingAsk::Line field secret becomes masked (the page and the bindings follow).
@LargeModGames
LargeModGames merged commit 6abfae1 into main Sep 26, 2026
35 checks passed
@LargeModGames
LargeModGames deleted the feat/gui-onboarding branch September 26, 2026 11:43
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

This makes most of the display state on `App` private, so each write
goes through a method that bumps the matching `DisplayRevisions` counter
from the PR below. A frontend can then redraw a domain only when its
revision moved. `DisplayDomain` gains `Party`, `Devices`, `Search`,
`Lyrics`, `Artist`, `Library` and `Queue`.

What changed:

1. `devices`, `search_results`, `party_status` and `party_session` are
private. Writes go through `set_devices`, `set_search_results`,
`set_party_status`, `set_party_session` and `party_session_mut`.
`set_search_results` now owns the cursor clamp, and
`clamp_search_cursors` is private. Readers outside `core/app` use
getters.
2. `lyrics`, `lyrics_status` and `lyrics_synced` are private behind
`App::set_lyrics`. The LRCLIB answer is applied by a pure
`apply_lyrics_response`.
3. The artist, album and show pages stay public and bump the `Artist`
revision where their producers finish (`App::bump_display` in
`infra/network/metadata.rs`, and in `core/app/library.rs`). `DjState`
gets a `revision` that its mutators bump: turn start and finish,
transcript lines, the step, the vibe, library indexing and the two
toggles.
4. The library pages, the playlist lists and folders, the saved-id sets,
the user and the five per-source sidebar lists are private, with one
getter and one `_mut` accessor per field. The accessor bumps the
`Library` revision. The in-app pagers and sorts use it too.
5. `queue` stays public. `note_playback_change` becomes
`note_display_changes`, which also compares the Spotify queue mirror,
the native queue and the queue-slot track at the same boundaries and
bumps `Queue` on a difference. It compares by reference and clones only
on a change.
6. `show_source_search_tracks` bumps `Search` without the clamp, so a
decoded-source search leaves the hidden result blocks' cursors for the
next Spotify search, as before.
7. `tools/gates.count`: `pub_fields_on_app` 139 -> 117,
`app_field_writes_in_tui_handlers` 186 -> 147.

The setters bump only `DisplayRevisions`. The plugin data generations
(`PluginDataKind`) bump where they did before, so plugins see no change.

No behaviour change.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless and default: clean. `cargo test --no-default-features
--features telemetry,tui gates`: `ok. 10 passed`. `bash
tools/check_gates_ratchet.sh` against the PR below: `ok`.

# Additional notes

Part 4 of 7 of a stack (#578 to #584). Base: #580.

The Linux `all-sources` test leg and the macOS job run only in CI.

Known trade-offs:

- A `_mut` accessor bumps `Library` when it is called, whether or not
the caller then writes. That can cause an extra redraw, never a missed
one.
- `DjState.revision` does not move for the setup picker or prompt edits.
Those are presentation state.
- Nothing outside tests reads the new revisions here.
`App::display_revisions` is `cfg(any(test, feature = "gui"))`.

Follow-ups:

- The track table (`track_table`, `playlist_track_*`, `recently_played`)
stays public with no revision.
- `App::raise_spotify_key_tier` (from #577) changes the artist page's
empty Top Tracks text without an `Artist` bump. Nothing sends the artist
page to a frontend yet, so it can bump when something does.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Search results now consistently reset or clamp table cursors when
replaced.
* Updates to playlists, search results, lyrics, devices, artist
information, queues, and party and DJ state are reflected more reliably
in the display.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

`spotatui-gui` was a placeholder that exited. It now boots like the
terminal UI (the same instance lock, `boot` and `prepare_frontend`),
serves an embedded page and a WebSocket on `127.0.0.1`, and opens the
browser at it.

What changed:

1. `src/gui/server.rs`: a loopback server on `httparse` and
`tokio_tungstenite::accept_hdr_async`. It checks `Host`, `Origin` and
`Sec-Fetch-Site` against DNS rebinding and cross-site pages, sends
`no-store`, `nosniff` and a strict CSP, and bounds each request and
handshake at 5 s.
2. The browser opens at `/#code=<code>`. The code is single-use, lives
60 s and is traded for a session token in `hello`. On Linux the server
also refuses loopback peers of other users (`/proc/net/tcp`).
3. `src/gui/protocol.rs` and `src/gui/bridge.rs`: `ClientMessage` in
(`action` through `App::apply`, `quit`), `Message` out: `hello`, a
resync, then each channel whose display revision moved (route, status,
theme, playback, devices, queue) and a position `tick` about every 250
ms.
4. `src/runtime/gui.rs`: a tick loop without a terminal. It boots with
`no_update: true` and quits on Ctrl-C, a `quit` from the page, or a
minute with no page.
5. `build.rs` embeds `gui/dist`. Without it `/` answers 503 with a build
hint.
6. `src/bin/spotatui-gui.rs` calls `run_gui`. A windowed release build
on Windows with no console shows its startup error in a message box.
7. `src/infra/loopback.rs` shares the token helpers with the MCP control
socket.
8. A `gui` leg in `ci.yml` (check, clippy, test), the third leg without
`tui`.

Deliberate behaviour changes a user can see:

1. Default and release builds: none. `gui` is off by default and no
release enables it.
2. `spotatui-gui` runs instead of exiting, and refuses to start beside
another spotatui UI.
3. On a fresh profile it stops and asks for one run of the terminal
`spotatui` first.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless, default and the `gui` leg (`--no-default-features --features
telemetry,gui,streaming,discord-rpc,self-update,scripting,mcp-server,mpris`):
clean. `cargo test --no-default-features --features telemetry,tui
gates`: `ok. 10 passed`. `bash tools/check_gates_ratchet.sh` against the
PR below: `ok`.

# Additional notes

Part 5 of 7 of a stack (#578 to #584). Base: #581.

Rebased onto #574 and #577. Beyond mechanical merges, the last commit
makes `run_gui` open its log through the same `start_logging` as
`run_cli`: `SPOTATUI_LOG`, a bare `--debug` (the crash notice asks for
it), and the startup header.

Not verified here: the Linux peer check and the MPRIS build without
`tui` run only in the `gui` CI leg, and no CI job builds `gui` on macOS.
A live pass on Windows ran against the top of the stack before the
rebase. This layer alone ships no page.

Residual risk: the launch code sits in the browser's command line while
it starts. macOS has no peer check, so another local user there could
race it. A private redirect file would keep the code out of argv, but
snap-confined browsers cannot read one.

`Source`, `Party`, `Search`, `Lyrics`, `Artist` and `Library` have
revisions but no message yet. The next PR adds the page, and the top PR
moves the first-launch questions into it.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added a browser-based frontend, available through the GUI app. It
opens in your default browser and supports playback, queue, theme,
device, and other app updates.
  * Added secure local access controls for browser connections.
  * Added a GUI feature configuration to the CI matrix.

* **Improvements**
* Help, version, and command-line usage errors now appear before a log
file is created.
* Shared startup and shutdown behavior now supports both the terminal
and browser frontends.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
LargeModGames added a commit that referenced this pull request Sep 26, 2026
# Summary

This adds the browser side of `spotatui-gui`: TypeScript types generated
from the Rust wire types, and a React page in `gui/` that talks to the
loopback server from the PR below. The page is a placeholder that
exercises the bridge and the CI gates. It is not a design, and the
designed screens will replace it.

What changed:

1. `Action`, the types it carries and the GUI protocol types derive
`ts_rs::TS` under `cfg_attr(all(test, feature = "gui"), ...)`. `ts-rs`
is a dev-dependency pinned to `=12.0.1`, so no shipped binary changes.
The protocol enum `Message` is now `ServerMessage`.
2. `typescript_bindings_are_written_to_the_frontend_source_tree`
rewrites `gui/src/bindings/` with `u64` as `number`, and fails when two
exported types share a name or any file contains `bigint`. The `gui`
test row in `ci.yml` fails when the committed files drift.
3. `gui/` is Vite + React + TypeScript: a queue list and a now-playing
bar (art, title, artists, a progress bar interpolated from the tick,
Previous, Play/Pause, Next), coloured from the theme channel.
4. `gui/src/connection.ts` trades the launch code for the session token
and keeps the token in `localStorage`. It reconnects 1 s after a drop
that followed a hello. A close before hello shows "This page is no
longer connected to spotatui."
5. The new `gui.yml` runs `npm ci`, `lint`, `format:check`, `typecheck`,
vitest and the build on every PR, with no paths filter.
6. `Cargo.toml` excludes `/gui/` from the published crate. The pattern
is anchored, so `src/gui` stays in.
7. The page's `Content-Security-Policy` allows `http:` images, since
many Subsonic servers serve cover art over http.

Deliberate behaviour changes a user can see:

Only builds with the `gui` feature change. It is off by default and no
release ships it.

1. With `gui/dist` built, `spotatui-gui` serves this page instead of the
"built without its frontend" answer.
2. A closed tab reopened at the same address reconnects to the running
spotatui. Each run issues its own token.

# Testing

The suites ran on the top of the stack (`feat/gui-onboarding`), which
contains this PR:

- `cargo fmt --all -- --check`: clean.
- `cargo clippy --locked -- -D warnings` on slim, headless,
headless-streaming, mcp-only, ai-dj-only, default, the `gui` leg and the
five-sources set with `audio-viz-cpal`: all `Finished`, no warnings.
- `cargo test --locked`, `0 failed` on every leg: slim `1253 passed`,
headless `851 passed`, mcp-only `1377 passed`, ai-dj-only `1530 passed`
(the four dead-code warnings in `infra/dj` test helpers predate this
stack), default `1630 passed`, `gui` leg `1369 passed`.
- Bindings drift after the `gui` leg test: `git status --porcelain
gui/src/bindings` prints nothing.
- In `gui/`: `npm ci` (`found 0 vulnerabilities`), `npm run lint`, `npm
run format:check` (`All matched files use Prettier code style!`), `npm
run typecheck`, `npm test` (`Tests 21 passed (21)`), `npm run build` (`✓
built`).

On this PR's own head: `cargo clippy --locked -- -D warnings` on slim,
headless, default and the `gui` leg: clean. `cargo test
--no-default-features --features telemetry,tui gates`: `ok. 10 passed`.
`bash tools/check_gates_ratchet.sh` against the PR below: `ok`.

# Additional notes

Part 6 of 7 of a stack (#578 to #584). Base: #582.

Not verified here: no CI job embeds the built page into the binary (the
`gui` leg builds without `gui/dist`), so serving it rests on a manual
run on Windows. `npm ci` has only run on Windows, and `gui.yml` is the
lockfile's first Linux install. No browser on macOS or Linux was tried.

Trade-offs and follow-ups:

- `ts-rs` compiles on every test leg, though only the `gui` leg uses it.
A Dependabot bump of it fails the drift step until the bindings are
regenerated, by design.
- `typescript` is pinned `~6.0` because `typescript-eslint` accepts
`<6.1.0`.
- Dependabot has no npm entry for `gui/` yet.
- The queue list skips Spotify queue episodes.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a web-based GUI for viewing the playback queue and now-playing
details, with playback controls and theme support.
  * Added automatic reconnection and connection status feedback.
* **Quality Improvements**
* Added automated checks for the GUI, including linting, formatting,
type checks, tests, and builds.
  * Enabled checks to detect outdated frontend bindings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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