fix(12-07): make ['me'] fresh on shell entry so post-wizard banner clears (gap 6)

- Root cause confirmed = mechanism (ii): ['me'] staleness, NOT a backend linking gap
  (upsertUser claim preserves users.id → credential stays linked → DB needsProviderSetup=false)
- SetupBanner ['me'] query staleTime 5min → 0 so a pre-claim stale cache entry is
  refetched on mount; banner hides once needsProviderSetup resolves false
- App.tsx boot ['me'] staleTime also set to 0 (committed with Task 1) for the same reason
- Add SetupBanner.test.tsx regression: absent when false, present (no dismiss) when true,
  stale-cache refetch hides banner; success-only dismissal contract preserved (no X button)
- Log pre-existing PWA lint errors (SetupPage.test.tsx, setupClient.contract.test.ts) to deferred-items.md
This commit is contained in:
Lucas Berger
2026-06-15 21:23:46 -04:00
parent fdcb4dc442
commit 2b3569ff20
3 changed files with 150 additions and 1 deletions
+8 -1
View File
@@ -33,11 +33,18 @@ export function SetupBanner() {
// Use HTMLButtonElement for the ref (assignable to the CredentialSheet's HTMLElement trigger)
const ctaRef = useRef<HTMLButtonElement>(null);
// staleTime 0 (gap 6): this banner gates on needsProviderSetup, which is only
// correct if ['me'] is fresh on entry to the authenticated shell after the
// wizard claim (see App.tsx for the full mechanism note). With a 5-minute
// staleTime a pre-claim cache entry kept needsProviderSetup=true and the banner
// showed even though the operator already configured the calendar in the wizard.
// The success-only dismissal contract is unchanged: this banner still clears
// ONLY when needsProviderSetup becomes false (no dismiss/X button).
const meQuery = useQuery({
queryKey: ['me'],
queryFn: fetchMe,
retry: false,
staleTime: 5 * 60 * 1000,
staleTime: 0,
});
// Only show when needsProviderSetup is explicitly true