Skip to content

v0.15.0: a web dashboard -- the live queue, and drag to reorder - #568

Merged
cycle-five merged 21 commits into
masterfrom
feat/web-dashboard
Sep 30, 2026
Merged

cycle-five merged 21 commits into
masterfrom
feat/web-dashboard

Conversation

@cycle-five

@cycle-five cycle-five commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

What

This is the web dashboard's first arc. Guild members sign in with Discord and watch their server's queue update live. Members in the bot's voice channel can drag to reorder the upcoming tracks. Reordering is the only control in this arc.

  • Spec: docs/superpowers/specs/2026-09-30-web-dashboard-queue-design.md
  • Plans: docs/superpowers/plans/2026-09-30-web-dashboard-queue.md and docs/superpowers/plans/2026-09-30-catacombs-website-flow.md
  • Operator notes: docs/web-dashboard.md

It is dormant until configured. The web feature is on by default, but with no WEB_* env the bot logs web dashboard off; missing or unusable: … and runs as before. Production can take this image with no visible change.

Design

  • A new crack-web crate (axum 0.8) runs inside the bot process. It shares Data, the serenity cache and Http. Dashboard startup failures are logged and never propagated.
  • crack-core gets a public facade, music::remote:
    • queue_state, bot_channel, active_guilds, move_by_id, plus move_track_by_id in music::queue;
    • crack-web never touches songbird, so the clippy.toml bans (Songbird::get, TrackHandle::data) keep holding;
    • moves take the playback lease like every command, so a /gp game refuses them;
    • a game also hides the queue, since titles would give the answers away. Ownership is checked before the read and again after it.
  • Moves identify tracks by songbird uuid, not index. The browser's view can be seconds old, and an index would move whichever track now sits there.
  • Auth uses catacombs v0.1.0, the owner's Discord OAuth library. It was extended in v0.1.0: a website login flow -- /login, /callback and a session cookie catacombs#1 with a browser redirect flow, an OAuth state check and a cookie session, and is pinned as a git tag like crack-osint and crack-bf.
  • Access rules:
    • Viewing requires guild membership: the member cache, or a voice state, or Http::get_member, memoised for 5 minutes (a 404 is remembered, other errors are not). The HTTP fallback exists because the bot never requests member chunks, so a large guild's cached member list is partial.
    • Controlling requires being in the bot's voice channel.
    • A non-member gets a 404, and a Discord failure gets a 503.
  • Live updates come from polling, not notifications. A per-guild watch hub reads the queue once a second, only while someone is watching, and publishes only on change. A move wakes the poller at once. Instrumenting every mutation site instead is the "remember to notify" bug class Playback ownership: a per-guild lease for queue mutation #434 removed. Each poll runs in its own task, so a panicking read can't freeze a guild. Views are always sent whole, so a missed event is corrected by the next one.
  • Web safety:
    • The move POST requires SameSite=Lax, JSON, and an exact Origin match.
    • CSP is default-src 'none' plus Trusted Types. This replaces the plan's source-scan test, which the owner's standing rule against source scans rules out.
    • Track titles are inlined as JSON with < escaped and drawn with textContent only.
    • Track links are limited to http(s) on the server side.
    • Per-user responses carry no-store.
  • Timeouts: everything, including /auth and the event stream, sits inside a 15 s request timeout. tower-http 0.6's TimeoutLayer bounds only the time to the first response, so the stream is not cut; a test shows it outliving the timeout. The stream's 5 s presence rechecks have their own timeout.
  • Discord queue messages refresh in the background after a move. Awaiting those edits under Discord's per-channel rate limit could turn a successful move into a 503. No reply is posted to the channel, per the owner's decision.

Testing

  • cargo test --workspace: 625 passed, 0 failed.
    • crack-web: 53 tests, and the paused-clock suites passed 10 runs in a row.
    • crack-core remote and music::queue: 25.
  • Every test was run against a sabotage of the code it guards, per task and in the final fix wave, 17 of 17 caught. The per-task mutation tables are in the SDD reports.
  • Deliberately not covered by automated tests, each for the reason given:
    • the spawned update_queue_messages after a move, and the Playing arm of state_of_call / bot_channel: both need a live voice connection. Exercised on TuneTitan;
    • app.js behaviour: no browser in CI. It was exercised on TuneTitan, and a throwaway Node harness was run during the fix wave;
    • the /auth timeout wiring, which needs a stalled Discord;
    • MissedTickBehavior::Delay, and the under-lock receiver_count recheck in the hub.
  • Parked, with rulings:
    • Detached Discord refreshes are unordered, so a /queue embed could briefly show an older order.
    • A move's answer can overwrite a slightly newer stream view until the next change.

On TuneTitan (2026-09-30, branch image at ab4741e4)

homelab verify passes: 23/23 migrations applied, and the dashboard is on (a signed-out / redirects to login).

A walk through an SSH tunnel, with the owner in voice:

  • Discord login, and the picker listing the guild and its voice channel.
  • A drag moved the track (the bot logged dashboard move), and a second tab followed live.
  • Two /skips reached both tabs.
  • /queue plus a drag, and leaving and rejoining voice, behaved correctly.
  • Not walked: the /gp hidden view. It is covered by unit tests.

Rollout after merge

  1. Tag v0.15.0. cargo-dist owns the release.
  2. Production homelab PR: env and port 8090 on the bots VM, a dash.cracktun.es Caddy block, a tunnel ingress rule and CNAME, the production app's redirect https://dash.cracktun.es/auth/callback, and its client secret in Vaultwarden.
  3. cracktun.es Privacy Policy paragraph, written from docs/web-dashboard.md "What it holds".

Follow-ups, deliberately not in this arc

  • Other controls: skip, pause, remove, add.
  • catacombs:
    • prompt=none, to skip Discord's consent screen on every login;
    • friendlier auth error pages;
    • Origin checks on its own POSTs.
  • Guild existence can be probed through the 404/503 split.
  • There is no cap on SSE streams.

🤖 Generated with Claude Code

https://claude.ai/code/session_019Qh7eJv3Ct5Uispr77BF5J

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…lookups, one renderer

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…ext; move a track by id

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…overflowing

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Each poll runs in its own task; a failed read keeps the last view and the
poller keeps ticking, instead of dying and leaving the map a dead sender.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…rtableJS 1.15.7 (sha256 bf4241bc73fef7f11c59a283a69fe8051cdd31c6d8ff5a2b9ba219e7831fcf76)

Adds the GET routes (picker, queue page with inlined JSON, static
assets), the CSP and security headers, the Backend trait the routes are
generic over, and a FakeBackend for tests. SortableJS is 1.15.7, the
latest 1.15.x on jsdelivr (the plan named 1.15.6).

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
The timeout layer wrapped only the page routes, so /auth/callback and
/auth/exchange -- which call Discord through a client with no timeout of
its own -- could hold a request open indefinitely. Build the layer once
and apply it to the nested auth router too.

Tighten the security-header test to cover /auth and the fallback 404 with
exact values, and assert the CSP has no 'unsafe-' source.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
The event route moves inside the timed router (tower-http never times the
body, so the stream stays open), the recheck's presence read gets
PRESENCE_TIMEOUT, and the recheck interval delays missed ticks. New tests:
live updates reach an open stream, a closed stream stops reading, a hung
presence recheck does not stall it, unknown membership is 503.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…k links

Replaces the app.js source scan with a CSP that makes a supporting browser
throw on any string assigned to an HTML sink. track_view drops non-http(s)
urls so an href can never carry a javascript: scheme.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
… a read

move_by_id awaited update_queue_messages, which edits every stored queue
message one by one under Discord's per-channel rate limit. A busy guild or a
few quick drags pushed the move's answer past the 15s request timeout, so
the page reported a failure for a move that happened, and the dropped future
stopped the refresh halfway. It now takes Arc<Http> and spawns the refresh
after the locks are dropped.

queue_state checked playback_owner once, before the call was read: a game
that claimed and enqueued during the read could have its first title
published. The owner is now checked again after the read.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…o-store

Hub::publish sent the route's view from outside the poller, so a poll read
that began before the move could land after it and put the old order back
for a tick. Hub::refresh now wakes the guild's poller (a Notify per guild,
whose stored permit makes a read in flight be followed by another), so every
read and send happens in that task, in order. The move answers with its own
fresh read.

The fake backend's move now changes the view it serves, so a route that
reads the view before the move fails its test; a refused move is shown to
publish nothing and to answer with a fresh read.

The picker, the queue page and move answers carry Cache-Control: no-store;
assets keep no-cache.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
onEnd cleared `pending` before the move's POST, so an answer without a view
(game_in_progress, not_allowed, a network error, 401/503) redrew the
pre-drag state, and the hub, which sends only on change, never sent the
discarded view again: /gp starting mid-drag left the old queue on screen,
with handles, for the whole game. The answer now prefers its own view, then
the pending one, then the one on screen, taking can_control from the
pending state; an answer that lands during a new drag is stored, not drawn.

A failed logout shows a note instead of an unhandled rejection.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
catacombs' MemoryStorage keeps each signed-in user's profile and Discord
refresh token in process memory, in plaintext, until restart.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
@cycle-five
cycle-five marked this pull request as ready for review September 30, 2026 13:38
@cycle-five
cycle-five merged commit bec4ba2 into master Sep 30, 2026
13 checks passed
@cycle-five
cycle-five deleted the feat/web-dashboard branch September 30, 2026 13:38
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