v0.3.0-PWA

v0.3.0 — Mobile / PWA Capture Surface

Summary

Merging web → main and cutting v0.3.0. This release ships the PWA capture surface end-to-end (server, embedded shell, offline queue, presets, history heatmap) plus the TUI ↔ Serve handoff that makes pour serve a one-keypress action from inside the dashboard.

Per pour - docs/09 milestones/v1.0.0-Release.md, v0.3.0 is the planned tag for "web/PWA capture surface, when web merges to main." This PR is that moment.

  • Cargo.toml: 0.2.2 → 0.3.0.
  • CHANGELOG.md: [Unreleased] promoted to [0.2.1]; new [0.2.2] and [0.3.0] sections added.

What's landing

Server foundation (~2.7k LOC)

  • pour serve subcommand on port 8421 (default), 0.0.0.0 binding, QR code + URL printed at startup.
  • Bearer-token auth via mobile_token in ~/.pour/secrets.toml; constant-time compare; ?token= bootstrap-only.
  • Nine /api/v1/* endpoints — health, config, options, submit, captures, history, presets CRUD + reorder.
  • Idempotency layer (LRU 1024, in-flight 60 s, done 5 min) so submit retries are safe.
  • Contract-first surface frozen at pour - docs/08 specs/pour-api-contract.md; OpenAPI at pour - docs/02 references/pour-openapi.yaml.

Embedded PWA (~6k LOC)

  • Vanilla HTML/CSS/JS shell via rust-embed. Module list, form rendering, submit, history, presets, "Add to Home Screen."
  • Phase 2 closeout (2026-04-27): IndexedDB offline queue, service worker app-shell cache, sub-form overlay for create_template, preset mutation UI, 90-day history heatmap, bottom-tab navigation, cursor-paginated history list. See pour - docs/06 reports/v1.0.0-phase2-closeout.md.

TUI ↔ Serve handoff (this branch's most recent work)

  • s from the dashboard suspends the TUI, runs pour serve inline (QR visible in the cooked terminal), Ctrl+C drains gracefully (5 s budget), dashboard resumes. One process, one terminal, transient server.
  • New src/server/startup.rs — shared banner + token resolution between CLI and TUI handoff. Banner uses fixed-width Unicode box-drawing (BANNER_WIDTH = 70), truncates URLs with ellipsis on overflow.
  • New run_with_shutdown cancellable axum entry — with_graceful_shutdown + local_addr()-derived logging.
  • Signal handler installed before any setup work via a spawned task — eliminates the pre-poll Ctrl+C-kills-process window.
  • Errors (port-in-use, drain timeout, bind failure) surface through app.startup_warnings as a dismissable overlay on the next dashboard render.
  • Plan + post-implementation audit notes: pour - docs/08 specs/pour-tui-serve-handoff.md.

Adversarial audit + fixes

The handoff went through a Redline Audit before merging; 4 critical and 4 high-value issues were found and fixed in a second pass:

  • C1: Errors no longer dropped into deferred_stderr (which only flushes at process exit) — they surface via the existing startup_warnings overlay.
  • C2: tokio::signal::ctrl_c() errors no longer cause the server to "spontaneously exit" — failure falls through to pending() so the documented contract holds.
  • C3: Signal handler installed via tokio::spawn at the very top of Action::Serve, before ratatui::restore() — pre-poll kill window reduced from hundreds of ms to microseconds.
  • C4: Banner width regression fixed; tests/server_startup_banner.rs asserts every line is exactly BANNER_WIDTH chars and locks the invariant.
  • H1: Handoff reuses app.config.clone() instead of reloading from disk — TUI and server share the same config snapshot.
  • H2: run_with_shutdown log line uses listener.local_addr(), not a hardcoded 0.0.0.0:{port}.
  • H3: New tests — shutdown_with_no_connections, shutdown_drains_in_flight_request — verify the 5 s drain timeout works for the case it was added for.
  • H4: Buffered keypresses after s discarded on dashboard resume — pressing s then q quickly no longer causes pour to quit on return.

Hierarchical preset picker

  • preset_axes config (config v3); preset_tree build / validate / suggest with TUI overlay tests.

TUI form rework (src/tui/form.rs, +562 lines)

  • Sub-form UX with inline ◂ ▸ cycling indicators; Up/Down navigates rows, Left/Right cycles values; no dropdowns inside overlays.

Test hardening

  • test_pollution cleanup; POUR_HOME panics inside cargo integration tests.
  • Expanded server / preset / history coverage.
  • Test count: 816 passing across 30+ binaries.

Docs pass

  • v0.2.0 accuracy + linking pass across pour - docs/.
  • New plan + audit doc for the TUI ↔ Serve handoff.

Known limitations carried into v0.3.0

  • TUI handoff hardcodes port 8421 (matches CLI default). If 8421 is permanently occupied, the user gets a clear startup_warnings message; the workaround is to run pour serve --port X in a separate terminal. A [serve.port] config option is a reasonable v0.3.x or v0.4.0 follow-up.
  • Banner emits a pour serve: prefix even when invoked from the TUI handoff — cosmetic only.
  • serve_on_listener retained alongside run_with_shutdown to avoid touching existing integration tests; minor API duplication.
  • Panic-hook chain grows by one closure per s press (slow leak, only material in 100+ cycles).

Test plan

  • cargo test — 816 passing, 0 failed.
  • cargo clippy --all-targets — clean.
  • cargo fmt -- --check — clean.
  • Smoke: pour, pour me, pour coffee (TUI capture loop unaffected).
  • Smoke: pour serve reachable, PWA loads in browser, basic capture round-trips.
  • Smoke: TUI handoff — press s in dashboard, scan QR, capture from phone, Ctrl+C, dashboard resumes.
  • Smoke: TUI handoff with pour serve already running externally — error surfaces via startup_warnings, dashboard stays interactive.
  • Smoke: token persistence — first s press generates token in secrets.toml, second s press reuses it.

Post-merge

  • Tag v0.3.0 on main.
  • Update pour - docs/09 milestones/v1.0.0-Release.md "Path from Today" snapshot to reflect post-tag state (current snapshot dates to 2026-04-25 and predates the bump).