You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Notification badge count disagrees with the notifications panel ("You're all caught up") #382
Environment: local web at 375×812 (mobile viewport). pnpm supa start, pnpm env-local pnpm exec supabase --workdir packages functions serve api (see the supabase-CLI-pin issue), pnpm web. Worker login: [email protected] / password123. Employer login: [email protected] / password123 (org unicorn).
Found during the 2026-07-16 mobile smoke test.
Actual: The header avatar shows an unread badge (1 for marcus, 5 for clay), but opening the drawer shows NOTIFICATIONS: "You're all caught up." The two read different sources (or the badge counts something the panel filters out).
Expected: Badge count and panel contents derive from the same query; badge clears when the panel shows nothing actionable. If the badge intentionally counts something else (e.g. pending invitations), the panel should show those items.
Where to look: the drawer + badge in packages/scf-core/features/drawer/DrawerLayout.tsx and the notifications hooks feeding both.
Acceptance: for both seeded logins, badge number == items visible in the notifications panel (0 shows no badge).
Fixed in 195f6fc04. The diagnosis in the report — "the two read different sources (or the badge counts something the panel filters out)" — was close, but the reality is simpler and worse: the panel showed nothing, ever.
NotificationsListResponse is { data: Notification[], pagination }. The endpoint's own zod/OpenAPI schema (data: z.array(notificationSchema)) and its handler both agree. Both rendering surfaces read .data.items, falling back to .items — neither has ever existed. So the list was always [] and the panel always rendered "You're all caught up", while the badge read .unread_count correctly off the same rows.
Reproduced against production data: user …0002 has 2 unread notifications right now. Badge 2, panel empty — the reported symptom exactly, no seeding needed.
Why it survived six months of use:
The as { data?: { items?: unknown[] } } casts asserted a shape the SDK type would have rejected, so TypeScript never saw the mismatch.
A comment in the centre screen said the endpoint "returns either { data: { items } } or { items } — handle both", documenting a belief that was never true. That reads as deliberate defensiveness, not a bug — so nobody questioned it.
Scope was wider than reported.NotificationsCenterScreen had the identical bug, so "See all" led to an equally empty page. And DrawerLayout held a third copy of the mapping, dead behind an _ prefix, which read .datacorrectly — the right version existed and went unused while both rendering paths used the wrong one.
All three are gone, replaced by one normalizer in features/notifications/normalize.ts, typed against the response so a future envelope change breaks the build instead of silently emptying the UI. Preview fallback preserved: body.preview (what notify-publish writes) → preview → message.
Demonstrated old vs new against a real response shape:
OLD (reads .data.items then .items): 0 items -> "You're all caught up."
NEW (reads .data): 2 items
UNREAD Pipeline verification — "from notify-publish" [info]
read Older row — "legacy message column" [critical]
badge: 1, panel unread shown: 1 ✓ agree
Acceptance criterion met: badge number == items visible, 0 shows no badge. scf-core type-checks clean.
Worth noting this is the same class as the envelope-mismatch note in the SDK docs — SDK-facing routes returning bare bodies vs REST routes wrapping in {data}. A cast that reaches past the declared type is where it always hides.
Activity
fix(notifications): read the list response's actual shape (#382)
thinkclay commentedon Jul 30, 2026
Fixed in
195f6fc04. The diagnosis in the report — "the two read different sources (or the badge counts something the panel filters out)" — was close, but the reality is simpler and worse: the panel showed nothing, ever.NotificationsListResponseis{ data: Notification[], pagination }. The endpoint's own zod/OpenAPI schema (data: z.array(notificationSchema)) and its handler both agree. Both rendering surfaces read.data.items, falling back to.items— neither has ever existed. So the list was always[]and the panel always rendered "You're all caught up", while the badge read.unread_countcorrectly off the same rows.Reproduced against production data: user
…0002has 2 unread notifications right now. Badge 2, panel empty — the reported symptom exactly, no seeding needed.Why it survived six months of use:
as { data?: { items?: unknown[] } }casts asserted a shape the SDK type would have rejected, so TypeScript never saw the mismatch.{ data: { items } }or{ items }— handle both", documenting a belief that was never true. That reads as deliberate defensiveness, not a bug — so nobody questioned it.Scope was wider than reported.
NotificationsCenterScreenhad the identical bug, so "See all" led to an equally empty page. AndDrawerLayoutheld a third copy of the mapping, dead behind an_prefix, which read.datacorrectly — the right version existed and went unused while both rendering paths used the wrong one.All three are gone, replaced by one normalizer in
features/notifications/normalize.ts, typed against the response so a future envelope change breaks the build instead of silently emptying the UI. Preview fallback preserved:body.preview(what notify-publish writes) →preview→message.Demonstrated old vs new against a real response shape:
Acceptance criterion met: badge number == items visible, 0 shows no badge.
scf-coretype-checks clean.Worth noting this is the same class as the envelope-mismatch note in the SDK docs — SDK-facing routes returning bare bodies vs REST routes wrapping in
{data}. A cast that reaches past the declared type is where it always hides.feat(tasks): complete a task, optionally linking a work log (#422)
fix(scf-core): invalidate notification queries once session is ready (#…