Skip to content

Notification badge count disagrees with the notifications panel ("You're all caught up") #382

Closed

Description

@thinkclay

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).

Activity

  1. added
    bug
    agent-ready
    on Jul 16, 2026
  2. thinkclay commented on Jul 30, 2026

    @thinkclay
    ContributorAuthor

    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:

    1. The as { data?: { items?: unknown[] } } casts asserted a shape the SDK type would have rejected, so TypeScript never saw the mismatch.
    2. 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 .data correctly — 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions