v0.17.0 — ISS-008 toasts for errors/events + browser notifications #19

Merged
kamilkrzywda merged 2 commits from feat/toasts-and-notifications into master 2026-09-19 17:33:14 +02:00
Owner

What (issue #8)

Error messages like "insufficient funds: a ATR 72-600 costs 200000, you have 62721" should appear as toasts in the bottom-right corner; more event messages (e.g. plane landing); browser notifications when the window is not focused.

Toasts

  • New lib/useToasts.ts hook: {toasts, push(kind:'error'|'info', msg), dismiss(id)}, 5 s auto-dismiss, queue capped at 4
  • New components/Toasts.tsx <ToastStack> — fixed bottom-right; items [data-testid="toast"] with toast-error (red border) / toast-info (slate) variants + per-toast dismiss button
  • Action errors now toast: RightPane runAction catch calls the new optional onError prop and keeps the inline right-error; LeftPane sim-control failures (previously console.error-only) wired to the same callback

Event messages (no server event feed exists — client-side snapshot diffing, no API changes)

  • New pure lib/deriveEvents.ts: diffSnapshots(prev|null, next) → info events from existing fields only:
    • {model} landed at {airport} (flying→available)
    • Package delivered: +€X / Package expired: A → B / New package available: A → B
    • Bought {model} / Sold {model} (plane id-set diff)
  • Shell (app/page.tsx) diffs each polled snapshot and pushes info toasts

Browser notifications

  • "Enable notifications" button in the LeftPane Time section (explicit Notification.requestPermission() on click; label reflects granted/blocked/unsupported)
  • When document.hidden and permission is granted, events also fire new Notification('Flight Ops', {body})

E2E (new e2e/toasts.spec.ts)

One test, two parts: (A) select the priciest model in Market (ATR 72-600, €200k > starting cash), buy → expect a visible toast matching /insufficient funds/ + inline error still shown; (B) notifications opt-in button behavior (soft — headless may deny).

Version

  • package.json → 0.17.0; CHANGELOG.md entry at top

Checks (local)

  • tsc --noEmit clean; unit 273/273 green (was 261); playwright test --list = 36 tests in 10 files
  • e2e not run locally by design — CI verifies against the isolated stack
## What (issue #8) *Error messages like "insufficient funds: a ATR 72-600 costs 200000, you have 62721" should appear as toasts in the bottom-right corner; more event messages (e.g. plane landing); browser notifications when the window is not focused.* **Toasts** - New `lib/useToasts.ts` hook: `{toasts, push(kind:'error'|'info', msg), dismiss(id)}`, 5 s auto-dismiss, queue capped at 4 - New `components/Toasts.tsx` `<ToastStack>` — fixed bottom-right; items `[data-testid="toast"]` with `toast-error` (red border) / `toast-info` (slate) variants + per-toast dismiss button - Action errors now toast: RightPane `runAction` catch calls the new optional `onError` prop **and** keeps the inline `right-error`; LeftPane sim-control failures (previously console.error-only) wired to the same callback **Event messages** (no server event feed exists — client-side snapshot diffing, no API changes) - New pure `lib/deriveEvents.ts`: `diffSnapshots(prev|null, next)` → info events from existing fields only: - `{model} landed at {airport}` (flying→available) - `Package delivered: +€X` / `Package expired: A → B` / `New package available: A → B` - `Bought {model}` / `Sold {model}` (plane id-set diff) - Shell (`app/page.tsx`) diffs each polled snapshot and pushes info toasts **Browser notifications** - "Enable notifications" button in the LeftPane Time section (explicit `Notification.requestPermission()` on click; label reflects granted/blocked/unsupported) - When `document.hidden` and permission is granted, events also fire `new Notification('Flight Ops', {body})` ## E2E (new `e2e/toasts.spec.ts`) One test, two parts: (A) select the priciest model in Market (ATR 72-600, €200k > starting cash), buy → expect a visible toast matching /insufficient funds/ + inline error still shown; (B) notifications opt-in button behavior (soft — headless may deny). ## Version - `package.json` → **0.17.0**; `CHANGELOG.md` entry at top ## Checks (local) - `tsc --noEmit` clean; unit 273/273 green (was 261); `playwright test --list` = 36 tests in 10 files - e2e not run locally by design — CI verifies against the isolated stack
kamilkrzywda added 1 commit 2026-09-19 16:58:47 +02:00
feat: v0.17.0 — ISS-008 toasts for errors/events + browser notifications
CI / build + unit + e2e (pull_request) Failing after 6m59s
d8dc785757
kamilkrzywda added 1 commit 2026-09-19 17:23:29 +02:00
kamilkrzywda merged commit 0467b54c70 into master 2026-09-19 17:33:14 +02:00
kamilkrzywda deleted branch feat/toasts-and-notifications 2026-09-19 17:33:14 +02:00
Sign in to join this conversation.