feat(ux): welcome banner, dashboard auth fix, docs update

- WelcomeBanner.tsx: guest-only dismissible onboarding card on dashboard
  (localStorage pv_seen_welcome, Browse Bills CTA, X dismiss)
- useDashboard: add !!token to query key so login/logout triggers
  a fresh fetch without manual refresh
- ARCHITECTURE.md: WelcomeBanner component, auth-aware query keys,
  v0.6.1 feature history entry
- Roadmap: mark welcome banner items complete
- Add MVP planning notes (Phase 3-6 roadmap draft)

Co-Authored-By: Jack Levy
This commit is contained in:
Jack Levy
2026-03-01 21:22:16 -05:00
parent 1e37c99599
commit a0e7ab4cd3
6 changed files with 190 additions and 4 deletions

View File

@@ -764,6 +764,9 @@ Compact bill preview showing bill ID, title, sponsor with party badge, latest ac
**`TrendChart.tsx`**
Line chart of `composite_score` over time with tooltip breakdown of each data source.
**`WelcomeBanner.tsx`**
Dismissible onboarding card rendered at the top of the dashboard. Shown only to guests (no JWT token). On dismiss — via the × button, the "Dismiss" link, or the "Browse Bills" CTA — sets `localStorage["pv_seen_welcome"] = "1"` and hides permanently. Reads localStorage after mount to avoid hydration mismatch; renders nothing until client-side state is resolved.
### Utility Functions (`lib/utils.ts`)
```typescript
@@ -794,6 +797,8 @@ interface AuthState {
// Persisted to localStorage as "pocketveto-auth"
```
**Auth-aware query keys:** TanStack Query keys that return different data for guests vs authenticated users include `!!token` in their key (e.g. `["dashboard", !!token]`). This ensures a fresh fetch fires automatically on login or logout without manual cache invalidation.
---
## Authentication
@@ -993,6 +998,18 @@ Nginx uses `resolver 127.0.0.11 valid=10s` (Docker's internal DNS) so upstream c
- Manual Controls split into two sections: always-visible recurring controls (Poll, Members, Trends, Actions, Resume) and a collapsible **Maintenance** section for one-time backfill tasks
- Maintenance section header shows "⚠ action needed" when any backfill has a non-zero count
### v0.6.1 — Welcome Banner & Dashboard Auth Fix
**Welcome Banner:**
- `WelcomeBanner.tsx` — dismissible onboarding card shown only to guests at the top of the dashboard
- Three bullet points: follow bills/members/topics, see what changed, Back to Source citations
- "Browse Bills" CTA navigates to `/bills` and dismisses; × and "Dismiss" button also dismiss
- Dismissed state stored in `localStorage["pv_seen_welcome"]`; never shown to logged-in users
**Dashboard Auth-Aware Query Key:**
- `useDashboard` hook query key changed from `["dashboard"]` to `["dashboard", !!token]`
- Fixes stale cache issue where logging in showed the guest feed until a manual refresh
### v0.2.2 — Sponsor Linking & Search Fixes
- **Root cause fixed:** Congress.gov list API does not return sponsor data — only the detail endpoint does. Poller now calls the detail endpoint for each new bill to get the sponsor and populate `bill.sponsor_id`
- **Backfill task:** `backfill_sponsor_ids` Celery task + `/api/admin/backfill-sponsors` endpoint + "Backfill Sponsors" button in Admin UI — fixes existing bills with `NULL` sponsor_id (~10 req/sec, ~3 min for 1,600 bills)