Tail callbacks + first-time achievements + persistent SEEN BEFORE (roadmap #1) #26

Merged
ronnyandre merged 2 commits from feature/tail-callback into main 2026-06-04 13:23:00 +02:00
Owner

Implements roadmap #1 (zero-API delight) end-to-end — the log-time callbacks and their persistent surfaces — from docs/plan-tail-callback-achievements.md. Zero AeroDataBox calls.

1 · Tail callback (at log time)

Logging a flight on a registration you've flown before fires a FIDS toast — ✈ SEEN BEFORE · LN-FGI — your 2nd flight · last flown Apr 23 2026; a new airframe gets ✈ NEW AIRCRAFT. Works on both save intents (survives navigation on "Save").

2 · First-time achievements

  • src/lib/achievements.ts — pure core deriving firsts (airport / country / airline / aircraft), flight + distance milestones, and the longest-flight record. Derived, never stored at insert — so bulk imports, out-of-order entry, edits, and post-hoc enrichment all attribute "firsts" to the chronologically earliest flight, not the first-inserted one. Full unit suite (order-independence, tie-breaking, null distances, domestic dedup) — 15 tests.
  • getAchievements() server query + a server-only projection loader (kept out of client-imported modules per §8).
  • createFlight also returns the firsts the new flight earned → celebrated in a toast + the add-another banner.
  • New /achievements FIDS page (Overview / Milestones / Records / Firsts timeline) + header nav link.

3 · Persistent "seen before"

  • getFlight returns tailHistory {total, ordinal}; the flight detail page shows a ✈ Seen before · Nth of M badge and links the tail to its fleet page.
  • The fleet aircraft hero shows a Seen N× badge for airframes flown more than once.

How it stays clean

  • TailCallback / achievement types are exported type-only, so flights.ts stays within the client-bundle rule (§8); the db-touching projection lives in _achievements-internal.ts.
  • Shared ordinal() moved to flight-display.ts (de-dupes call sites).

Verification

  • pnpm typecheck ✅ · pnpm lint ✅ · pnpm test 67 passed (was 52) ✅
  • Dev server: /achievements, /flights/new, /fleet/$tail all serve 200; SQL semantics for tail history + callback validated against a real DB.

Supersedes the original Part-1-only description; the tail callback + achievements ship together as one delight bundle.

Implements roadmap **#1** (zero-API delight) end-to-end — the log-time callbacks **and** their persistent surfaces — from `docs/plan-tail-callback-achievements.md`. **Zero AeroDataBox calls.** ## 1 · Tail callback (at log time) Logging a flight on a registration you've flown before fires a FIDS toast — **✈ SEEN BEFORE · LN-FGI — your 2nd flight · last flown Apr 23 2026**; a new airframe gets **✈ NEW AIRCRAFT**. Works on both save intents (survives navigation on "Save"). ## 2 · First-time achievements - **`src/lib/achievements.ts`** — pure core deriving firsts (airport / country / airline / aircraft), flight + distance milestones, and the longest-flight record. **Derived, never stored at insert** — so bulk imports, out-of-order entry, edits, and post-hoc enrichment all attribute "firsts" to the *chronologically* earliest flight, not the first-inserted one. Full unit suite (order-independence, tie-breaking, null distances, domestic dedup) — **15 tests**. - **`getAchievements()`** server query + a server-only projection loader (kept out of client-imported modules per §8). - **`createFlight`** also returns the firsts the new flight earned → celebrated in a toast + the add-another banner. - New **`/achievements`** FIDS page (Overview / Milestones / Records / Firsts timeline) + header nav link. ## 3 · Persistent "seen before" - `getFlight` returns `tailHistory {total, ordinal}`; the **flight detail** page shows a **✈ Seen before · Nth of M** badge and links the tail to its fleet page. - The **fleet aircraft** hero shows a **Seen N×** badge for airframes flown more than once. ## How it stays clean - `TailCallback` / achievement types are exported **type-only**, so `flights.ts` stays within the client-bundle rule (§8); the db-touching projection lives in `_achievements-internal.ts`. - Shared `ordinal()` moved to `flight-display.ts` (de-dupes call sites). ## Verification - `pnpm typecheck` ✅ · `pnpm lint` ✅ · `pnpm test` **67 passed** (was 52) ✅ - Dev server: `/achievements`, `/flights/new`, `/fleet/$tail` all serve 200; SQL semantics for tail history + callback validated against a real DB. _Supersedes the original Part-1-only description; the tail callback + achievements ship together as one delight bundle._
Roadmap #1 (zero-API delight). When you log a flight on a registration you've
flown before, a FIDS toast announces "SEEN BEFORE · <tail> · your Nth flight ·
last flown <date>"; a new airframe gets "NEW AIRCRAFT". Pure payoff of data we
already store — zero AeroDataBox calls.

- createFlight now returns a `tailCallback` ({ new | seen }), computed
  per-user against existing flights on the same normalized registration,
  excluding the just-inserted row.
- new-flight UI fires a sonner toast (works on both save intents; survives the
  navigation on plain "save") and appends a short tag to the add-another banner.

Spec: docs/plan-tail-callback-achievements.md (Part 1). Part 2 (derived
first-time achievements) is a follow-up.
Part 2 of the delight bundle, plus the persistent counterparts to the
log-time tail callback.

Achievements (derived, never stored — correct under import/edit/reorder):
- src/lib/achievements.ts: pure core (firsts per airport/country/airline/
  aircraft, flight + distance milestones, longest-flight record), with a full
  unit-test suite incl. order-independence and tie-breaking.
- getAchievements() server query + a server-only loader that projects flights
  into the pure shape (kept out of client-imported modules per §8).
- createFlight now also returns the firsts the new flight earned; the log
  screen celebrates them in a toast + add-another banner.
- New /achievements FIDS page (overview / milestones / records / firsts
  timeline) + header nav link.

Persistent "seen before":
- getFlight returns tailHistory {total, ordinal}; flight detail shows a
  "✈ Seen before · Nth of M" badge and links the tail to its fleet page.
- fleet aircraft hero shows a "Seen N×" badge for airframes flown >1.

Shared `ordinal()` helper moved to flight-display.ts (de-dupes new.tsx).
ronnyandre changed title from Add SEEN BEFORE / NEW AIRCRAFT tail callback at log time (roadmap #1) to Tail callbacks + first-time achievements + persistent SEEN BEFORE (roadmap #1) 2026-06-04 13:21:34 +02:00
ronnyandre deleted branch feature/tail-callback 2026-06-04 13:23:01 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!26
No description provided.