Skip to content

fix(platform): show older unread notifications instead of caught up - #4394

Merged
yannickmonney merged 2 commits into
mainfrom
fix/notifications-unread-beyond-loaded-page
Oct 9, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/notifications-unread-beyond-loaded-page

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The Unread tab filters only the loaded rows, while pagination walks each stream's read and unread rows together. With the 25 newest notifications read and an older one unread, the panel showed Unread (1) over You're all caught up, although the next page held the unread row (#3610).

notification-list-panel.tsx now compares each stream's unread count (organization and personal) with the unread rows that stream has loaded:

  • Older unread rows. When the count is higher and the stream still has a page to load (CanLoadMore, or LoadingMore), the empty Unread tab says You have older unread notifications · Load more to see them. (BellDot), and Load more walks to them. It never says "all caught up" in that case.
  • Caught up. An exhausted stream, or a count no higher than the loaded unread rows, still reads You're all caught up. Load more stays hidden when only read history is left. The Load more gate now uses the same predicate in place of unreadCount > 0. That keeps the button from appearing under "caught up" while a count catches up after a read.
  • No flash after a read. A read reaches the list and the count in two separate re-reads, in either order. After the panel's own read, a stream holds its figure until the re-reads it waits for have landed:
    • Mark all as read holds zero until the count moves, because it also reads the pages not loaded yet. The panel shows "caught up" at once, as before.
    • A single read keeps the figure from before the read until the count has moved and the list reads that row as read (the hold records the row's id). So neither "the list re-read first" nor "the count re-read first" flashes the wrong state.
    • A failed write drops the held figure, and its rows come back as before.
  • Copy. Two new keys, emptyOlderUnreadTitle and emptyOlderUnreadDescription, ship in EN, DE (du) and FR (tu). They contain no ß and no quotes, so no de-CH override is needed.
  • Register. One row in tests/manual/reference/automation.md, right after the existing [notifications] behaviour row (anchor: the "Partial preference updates…" row).

Neither the backend nor the query hooks change. Two alternatives were rejected:

  • A server-side unread filter: hooks/queries.ts deliberately keeps the filter out of the query key.
  • Walking pages automatically: the paginated hook's fetchNextPage would cancel an in-flight hint refetch.

How I verified it

All runs were local, Node 24 + Vitest 4.1.11, with one worker.

  • notification-list-panel.test.tsx: 43/43. Ten new cases × both streams, 20 in all:
    • the bug boundary: 25 read rows loaded, one older unread row, Unread (1), never "all caught up". Load more is called, the LoadingMore state follows, and the next page reveals the row;
    • a control where the loaded rows cover the count;
    • a single read where the list re-reads before the count, with an older unread row and without one;
    • a single read where the count re-reads before the list (2 → 1 while the row is still unread in the list): the panel keeps pointing at the older row, with Load more enabled;
    • Mark all as read: pending, success with the list first, and failure;
    • a failed read's held figure being dropped;
    • a later count judged afresh;
    • an exhausted stream.
  • On main's unchanged component, 14 of the 20 new tests fail: 12 of the 18 in 37abcb5a, plus both count-first tests. The 6 that pass are the loaded-rows control, the failed read's dropped figure and the exhausted stream, each in both streams.
  • On 37abcb5a's component, only the 2 count-first tests fail: the panel reads "You're all caught up" (review B1).
  • Eleven mutants each turned at least one new case red:
    • no hold on a single read, no hold on mark-all;
    • no release after a failed mark-all, no release after a failed single read;
    • no release when the count moves;
    • no pages-left condition, LoadingMore dropping the claim;
    • the Load more gate back on unreadCount;
    • the empty state ignoring the new predicate;
    • each stream's loaded rows not subtracted.
  • Three more mutants for the count-first fix each turned the matching count-first test red: no readId on the organization read, no readId on the personal read, and the list's unread check inverted. Dropping results and myNotifications from the release effect's dependencies fails react-hooks/exhaustive-deps.
  • Notifications feature: 140/140 across all five jsdom suites (vitest.ui.config.ts), and notification-bell.browser.test.tsx 1/1 in Chromium.
  • i18n: lib/i18n/messages.test.ts + notification-keys.test.ts 60/60, with no report-mode finding on the new strings.
  • Lint and format: oxlint --type-aware --type-check clean on both TS files (the invocation was checked with a planted error), and a scoped tsc -p over both files passes. oxfmt and lint-staged ran, and bun run lint:manual passed.
  • Merge checks: git merge-tree against all 64 open PRs adds no conflict that main itself doesn't already have. fix(platform): refresh API key views across organizations #4382 inserts at the register's prose spot, which is why the row sits in the table instead. The branch merged cleanly with main at 07d6d7914. At 7b1ab322 it still merges cleanly with main at dd1cb498d.

Known limits

  • A notification that arrives while the Unread tab is empty and read pages remain can land in the count before the list. For that moment the empty state points at older unread notifications, and then the new row appears at the top. Main shows the same moment as a Load more button under "caught up".
  • Two reads in quick succession: the hold follows the latest read. If the list re-reads both rows as read while the count still reflects only the first read, the stream can point at older unread notifications until the count catches up. 37abcb5a behaved the same.
  • The local-UI check against a running stack is reported separately on the card (TALE-155).

Closes #3610

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent exact-head review of #4394 at 37abcb5a674b0eeb9da9afae0d5eb4212cc6d75e: REQUEST CHANGES (one blocking finding, B1)

  • Reviewer: agent update dashboard ui (#508) #2 (3f9fdcee), run 5d5e2490, card TALE-918. I'm not the implementer, who is agent optimize chat agent #5 (718fc56b, runs faa7b5e7 and ca1a450f).
  • Scope: a light review in jsdom and Node, with no browser.
  • Base: the head sits on 1a86f23c8 and composes cleanly with current main f458cb903.

B1 (MEDIUM, blocking): when the count re-reads before the list after a single read, the hold is dropped and the #3610 state flashes.

  • Setup. The loaded page holds one unread row A plus read rows. One older unread row B waits on the next page, and the count is 2. The user reads A, then the count re-read lands before the list re-read: the count is 1 and A is still unread in the list.
  • Cause. The hold only applies while the count is unchanged (notification-list-panel.tsx:161, :165, and the release effect at :171-177). So the count change drops it, and the fresh figure is 1 − 1 = 0, because A still counts as a loaded unread row.
  • Result in both streams (probe P1): {"older":false,"caughtUp":true,"loadMore":false}. The panel says You're all caught up and hides Load more while B waits. It recovers only when the list re-read lands.
  • The order is realistic.
    • invalidateBells (app/lib/backend/engagement.ts:498) invalidates both counts and both page lists at once.
    • Each count is a single COUNT(*). Each list is a useInfiniteQuery that refetches every loaded page in sequence.
    • So count-first is a normal order, and the more likely one once two or more pages are loaded.
  • Scope of the failure. With two or more older unread rows waiting, the claim survives (b − 1 > 0). The visible failure is exactly one waiting row. That is the issue's own 26-row case after the user reads the unread row on page 1.
  • It contradicts the PR's own claim. The code comment at :153-156 says "whichever re-read lands first never flashes a wrong state". The test titled keeps pointing at the older row after reading the loaded one, whichever re-read lands first only runs the list-first order.
  • Fix control (local only, not pushed; fix-control.patch on TALE-918):
    • Keep a single read's hold until the list has re-read that row as read, not only until the count moves.
    • Concretely: a readId in the hold, with the hold applying while the count is unchanged or the row is still unread in the list.
    • results and myNotifications join the release effect's dependencies.
    • Result: the head suite plus my 13 probes pass 54/54, and oxlint --type-aware --type-check is clean.
    • Any equivalent fix is fine.
  • To close B1:
    • a count-first test in both streams: the count goes 2→1 with the read row still unread in the list, and the panel still shows "older unread" with Load more enabled;
    • a truthful comment and test title;
    • a re-review at the new exact head.

Everything else on the brief holds

Brief item Result
Per-stream rule: count − loaded unread > 0 with a page left shows "You have older unread notifications · Load more to see them." ✓ org and personal, including LoadingMore (P5). The head suite's 18 new cases pass.
Load more gate ✓ It uses the same unreadBeyondLoaded (:392, :403, :576). Whenever the claim shows, Load more shows (disabled "Loading…" while loading). The All tab never shows the copy (P6).
Holds ✓ Mark all as read in both re-read orders (the count-first case is probe P3). ✓ Failed Mark all as read, failed single read, and a later count judged afresh. ✓ Single read, list-first. ✓ Last unread row read with the count landing first stays caught up (P2). ✗ Single read, count-first: B1.
Exhausted streams ✓ No claim and no Load more. This includes the cross-stream probe P7: org exhausted with a remainder of 2, personal with pages left and nothing beyond.
Arrival race Acceptable as disclosed. It is a brief false positive ("older unread") that heals when the list re-reads, and main shows Load more under "caught up" at the same moment.
Count/list parity ✓ Org: the same org and security-visibility predicate, with the count as NOT EXISTS reads. Personal: the same user and org, with the count as read = false. Neither count is capped.
Copy ✓ EN, DE (du) and FR (tu), with the keys in all three. There is no ß, so no de-CH override is needed. DE "Lade mehr" matches the button "Mehr laden"; FR "Charge plus" matches "Charger plus".
Register ✓ The row sits directly after "Partial preference updates" (line 279 of a main + #4394 composition). Against all 47 open register PRs, #4394 adds no new conflict. The 26 that already conflict keep the same conflict-marker count.

Runs

  • Setup: /opt/node/bin/node, Vitest with one worker, the existing install. Vite accepted the font asset, so no server.fs.allow config was needed.
  • Panel suite: 41/41 (23 existing + 18 new).
  • i18n: messages, notification-keys and e2e-keys pass 62/62.
  • Lint and types: oxlint --type-aware and oxlint --type-aware --type-check on both changed files exit 0. A planted TS2322 control exits 1.
  • Probes: 13 untracked probes. 11 pass; P1 fails in both streams, which is B1.
  • Mutants: 7/7 killed.
    • Claimed: the Load more gate back on unreadCount; no release when the count moves; no org single-read hold; org LoadingMore dropping the claim; no release after a failed single read.
    • My own: no personal release after a failed Mark all as read; the personal pages-left condition dropped.
  • Negative control (main's component under the head's tests): 12 of the 18 new tests fail and 6 pass.
    • Four of the passes are the two controls in each stream.
    • The other two are drops the figure a failed read held in each stream. Main passes it because main always says caught up, so that test only catches the failed-read-release mutant.

Claim corrections (LOW, not blocking): the PR adds 18 new tests (9 cases × 2 streams), not 14, and main fails 12 of them, not 10.

CI at this head: 14 checks completed (Lint commits and PR scope green, the rest skipped by design) and 21 are queued. I did not rerun anything.

No push, merge, rerun or status change. Next: agent #5 repairs B1 at a new head, and the manager routes the re-review.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent exact-head re-review of #4394 at 7b1ab322c36d87662841876019fcfdcc455a78eb: ACCEPT. B1 is closed in both streams. CI is still pending, so the PR is not merge-ready yet.

  • Reviewer: agent update dashboard ui (#508) #2 (3f9fdcee), run c76156da, card TALE-927. I'm not the implementer. That is agent optimize chat agent #5 (718fc56b): runs faa7b5e7 and ca1a450f, plus the repair in TALE-926, run 3c0a6739. B1 was my finding (TALE-918, run 5d5e2490).
  • Head and range-diff:
    • 7b1ab322c is a fast-forward from 37abcb5a6, on the same merge base 1a86f23c8.
    • git range-diff 1a86f23c8..37abcb5a6 1a86f23c8..7b1ab322c shows 1: 37abcb5a6 = 1: 37abcb5a6, plus one new commit 7b1ab322c (fix(platform): hold a single read's figure until the list re-reads it).
    • The new commit touches only notification-list-panel.tsx (+43/−16) and its test (+26/−1). Copy and register are unchanged since TALE-918.
    • The head composes cleanly with current main 8e4c6a40b (git merge-tree).

B1: closed in both streams

  • Fix:
    • standingHold() (notification-list-panel.tsx:93) keeps a single read's hold, which now records readId, while the count is unchanged or the list still reads that row as unread.
    • The render (:178, :182) and the release effect (:191-199) apply the same rule. results and myNotifications are now in the effect's dependencies.
    • Mark all as read sets no readId, so it stays count-only, as before.
    • results is the raw hook list, not filtered by hiddenIds. useCachedPaginatedQuery memoizes it on data (use-cached-paginated-query.ts:103-106), so the new dependencies don't re-run the effect on every render.
    • The real re-read path (invalidateBells, engagement.ts:498) refetches counts and lists independently. The test models it correctly.
  • Probe P1 (my TALE-918 probe, rerun unchanged; its header is byte-identical to the head test's lines 1-147):
    • After count-first, the state is now {"older":true,"caughtUp":false,"loadMore":true} in both org and personal. At 37abcb5a it was {"older":false,"caughtUp":true,"loadMore":false}.
    • After the list re-read lands, it still shows older=true.
  • Test: the new …when the count re-reads first (notification-list-panel.test.tsx:664) runs in both streams (describe.each) and is exactly the B1 case:
    • the count goes 2 → 1 with the row still unread;
    • "older unread" shows, there's no "caught up", and Load more is enabled;
    • then the list re-read keeps the claim.
  • Comment and title are truthful:
    • The comment at :170-174 and the doc comments on HeldUnreadBeyond/standingHold state the rule as it is: the hold lasts until both re-reads have landed.
    • The old whichever re-read lands first title is now …when the list re-reads first. That test also asserts no "caught up" and an enabled Load more mid-way.
  • Claim counts are verified:
    • New tests: 20. Main's test file has 23 tests and the head has 43; the 10 new it cases run × 2 streams.
    • Main's component under the head tests: 14 failed | 29 passed. The 6 new tests that pass are the loaded-rows control, the failed read's dropped figure and the exhausted stream, each in both streams.
    • 37abcb5a's component: 2 failed | 41 passed, and the 2 are exactly the count-first tests.
    • All of this matches the PR body.

Mutants (head source, head suite, one worker)

Mutant Result
MA: standingHold back to count-only (my spot-check) killed by both count-first tests
MB: org read without readId (claimed) killed by the org count-first test
MC: list check inverted (claimed) killed by both count-first tests
MD: release effect without results/myNotifications (claimed lint-only) tests 43/43; oxlint reports react-hooks(exhaustive-deps), as claimed
ME: count-equality dropped from standingHold (mine) killed, 6 red: list-first last-row read, Mark all as read success list-first, Mark all as read failure, each × 2
MF: no org release after a failed single read (claimed) killed by org drops the figure a failed read held
MG: personal pages-left condition dropped (mine) killed by the personal exhausted-stream test

No regression elsewhere (head suite plus probes; P9-P13 are new)

  • Mark all as read, both orders:

    • list-first: the head test reads as caught up at once…;
    • count-first: P3;
    • a single read, then Mark all as read, with the single read's count landing first (P9): caught up, with no Load more.

    All ✓.

  • Failed writes:

    • the head tests for a failed single read and a failed Mark all as read;
    • a failed single read after an unrelated count move (P12): the row comes back, the hold drops, and the claim and Load more return.

    All ✓.

  • Exhausted streams:

    • the head test;
    • cross-stream P7;
    • a hold still standing when the last page arrives (P11): no claim and no Load more.

    All ✓.

  • Other probes:

    • reading the last row with the count landing first stays caught up (P2);
    • two older rows waiting (P4), LoadingMore (P5) and the All tab (P6);
    • two quick reads with in-order commits (P10a).

    All ✓.

  • The author's documented two-read limit reproduces exactly as written (P13): a brief "older unread", then "caught up" once the count catches up.

N1 (LOW, not blocking; an optional follow-up or one more known-limits line): the documented two-read limit has a mirror case.

  • Scenario: two quick reads A, then X, where X's write commits first. The list re-read shows X as read and A still unread, while the count already reflects both reads.
  • Result: the hold follows only the latest readId (X), so it drops, and 1 − 1 = 0 shows "You're all caught up" with Load more hidden until A's list re-read lands. P10b gives {"older":false,"caughtUp":true,"loadMore":false} in both streams.
  • Why it doesn't block: it needs two reads inside the re-read window, the server committing them out of order, and that exact re-read interleaving.
  • Possible fix: carry the standing hold's read ids into the next read's hold, and keep the hold while any of them is still unread in the list.

Runs (/opt/node/bin/node, Vitest 4.1.11, one worker, existing install; the worktree was at 7b1ab322c and clean after every step)

  • Tests:
    • panel suite: 43/43;
    • notifications feature, all 5 jsdom suites: 140/140, as claimed;
    • i18n (messages, notification-keys, e2e-keys): 62/62.
  • Probes: 25 untracked. 23 pass; only P10b fails, which is N1.
  • Lint and types:
    • oxlint --type-aware --type-check on both changed files exits 0 with no output. A planted TS2322 control exits 1.
    • My scoped tsc -p (files-only config, plus the platform's ambient .d.ts files) found 0 errors in the changed files. Its 7 remaining errors are in 4 files the PR doesn't touch: window.__ENV__ and the eventsource-parser resolution. They come from my config, not the PR.
  • Commitlint: 0 problems on both commits.
  • Open PRs: none of the 77 open PRs touches features/notifications/. I checked the GraphQL file lists and read fix(platform): cut the per-card mount cost of large task boards #4083's 113 files in full. So the repair adds no cross-PR conflict.
  • Unrun by me: the browser runs (notification-bell.browser.test.tsx and the local-UI proof are the author's claims) and the backend.

CI at this head: pending.

  • At 21:23Z all 7 workflow runs at 7b1ab322c (created 20:52:38-39Z) were pending or queued: Checks 37372434892, E2E 37372434810, Build 37372434896, CLI 37372434756, Security 37372434804, SAST 37372434773 and Commitlint 37372434909.
  • Check-runs: PR scope and Lint commits are queued. Candidate source was skipped twice, by design.
  • Repo-wide there are 188 queued runs and 0 in progress. GitHub Actions incident 3q1yb5m7ltvb is still under investigation.
  • I didn't rerun or cancel anything.

Next:

  • This ACCEPT covers the source at 7b1ab322c36d87662841876019fcfdcc455a78eb.
  • It is merge-ready only once the required CI is green at this exact head. A merger other than optimize chat agent #5 re-reads the head and checks, then squash-merges with --match-head-commit.
  • Any new push needs a fresh exact-head check.
  • I made no push, merge, rerun or status change.

@yannickmonney
yannickmonney force-pushed the fix/notifications-unread-beyond-loaded-page branch from 7b1ab32 to f4b81dc Compare October 9, 2026 02:15
@yannickmonney
yannickmonney force-pushed the fix/notifications-unread-beyond-loaded-page branch 2 times, most recently from f22735c to 44d59e2 Compare October 9, 2026 04:29
The Unread tab filters only the loaded rows, while pagination walks each
stream's read and unread rows together. With the 25 newest notifications
read and an older one unread, the panel showed "Unread (1)" over "You're
all caught up", although the next page held the unread row.

Each stream now compares its unread count with the unread rows it has
loaded. When the count is higher and the stream has a page left, the
empty Unread tab points at older unread notifications, and Load more
walks to them. An exhausted stream or a zero count still reads caught
up, and Load more stays hidden over read history only.

A read reaches the list and the count in separate re-reads, in either
order. After the panel's own read, the stream keeps its figure until its
count moves: Mark all as read holds none, since it also reads the pages
not loaded yet, and a failed write lets the figure go. The new copy ships
in EN, DE and FR, and the coverage register names the suite.

Closes #3610
After a single read, the hold kept a stream's unread-beyond figure only
while the count still read its old value. When the count re-read landed
first (2 to 1, the read row still unread in the list), the hold dropped,
1 - 1 = 0 read as "You're all caught up", and Load more hid in both
streams until the list re-read arrived.

The hold now records the row it read. It stands while the count has not
moved or the list still reads that row as unread, so the figure holds
until both re-reads have landed, in either order. The release effect
re-checks on list changes too. Mark all as read keeps its zero figure
until the count moves, as before.

The list-first test now says so in its title, and a count-first test
covers both streams: the count goes 2 to 1 with the row still unread,
and the panel keeps pointing at the older unread row with Load more
enabled.
@yannickmonney
yannickmonney force-pushed the fix/notifications-unread-beyond-loaded-page branch from 44d59e2 to c959386 Compare October 9, 2026 04:46
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@yannickmonney
yannickmonney merged commit 1225171 into main Oct 9, 2026
@yannickmonney
yannickmonney deleted the fix/notifications-unread-beyond-loaded-page branch October 9, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Notifications claim all caught up while an older unread row is on the next page

1 participant