Repository navigation
refactor: read notification approval row state through one selector - #31070
Conversation
An approval row in the notifications feed is live, retired, or decided with a failed DELETE, and that is spread over two per-row marks in the notifications slice. The slice, the feed and the detail panel each read the marks directly, in three spellings, so a new reader could check one mark and miss the other. Add rowPhase(notifications, ts), which reads both marks at once, and route every reader through it: liveApprovalRows, the unread guard, the fetch merge, the decide settle, decideApprovalRow's ended check, the feed and the detail panel. The marks keep their storage and every writer; the existing tests read and seed that shape and pass unmodified. Behaviour is unchanged. Closes #20618
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Every non-writer read of the two marks now goes through [DESIGN-REVIEWED] e36f5ed Description read[DESCRIPTION-READ] 0c807d884dc1f984a5d98c8015d988b1f939cf95e63e0c29a6007fbd69da7550 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. This refactor changes how the feed and the detail panel read approval-row state. It adds or changes no labels, controls, copy or rendered states, so the missing blind read leaves no gap to fill. [UX-REVIEWED] e36f5ed Description read[DESCRIPTION-READ] d39f884be6def98c86f1c9c7938d91617987797ebe89cd6b6dee69a82e78f5b6 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Pure consolidation: every reader of What this change shipsInventory (5 items) — 5 justifiedIntent: let every approval surface ask one place whether a notification row can still be decided, so the surfaces cannot disagree. This is an ADDITION (refactor, closes #20618).
[FIRST-PRINCIPLES-REVIEWED] e36f5ed Description read[DESCRIPTION-READ] cd3953cd2e6b9807ba017753f42a67f5116e85c91dea40109928a3202a414749 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Problem / Motivation
Goal: The notifications feed, the detail panel and the approval frame handlers all learn whether an approval row can still be decided from one shared answer, so they cannot disagree.
An approval row in the notifications feed is in one of three places: it can still be decided, it is retired (a decide was refused, or failed after its request ended), or its decision landed and only the clean-up DELETE failed. That answer is spread over two per-row marks in the notifications slice,
retiredApprovalsanddismissFailed. The slice,NotificationFeedandNotificationDetailPaneleach read the marks directly, in three different spellings (Object.hasOwn,?.[ts],=== 'decided'). A reader that checks one mark and forgets the other treats a settled row as live, or a live row as settled.Why it matters
Any new surface that shows approval rows (the chat cards and other approval surfaces #16481 planned) would have to copy that two-mark check by hand, and one missed half shows Approve/Reject on a row that can no longer be decided, or drops a live row when a frame ends an older request under the same id.
Not a goal
retiredApprovals,approvalDecisionsanddismissFaileddirectly, and the issue requires them to pass unmodified.row.ackedinto the phase: it is the read flag every notification carries, read by every badge and banner, not approval state.approvalDecisions(a decision in flight) behind the selector: only the reducers that write it read it.What changed (motivation → approach → change)
Every place that asks "can this approval row still be decided?" now asks one function instead of two maps.
website/src/store/notificationsSlice.tsgainsrowPhase(notifications, ts). It reads both marks at once and returns one record:phase(live,retiredordecided),endedFailure(the reason a retired row quotes, ornull) anddismissFailed(a DELETE after a landed decision failed). An idle row and a row with a decision in flight are bothlive: nothing outside the reducers tells them apart. Every reader goes through it:liveApprovalRows(used by the approval frame handlers and the chat page)phase === 'live'phase !== 'live'approvalDecisionSettledanddecideApprovalRow's ended checkphase,endedFailurecomponents/notifications/NotificationFeed.tsxrows and focus rescuephase,endedFailure,dismissFailedcomponents/notifications/NotificationDetailPanel.tsxphase,endedFailure,dismissFailedThe marks keep their storage and every writer; the private
isSettledApprovalRowhelper and the feed'shasRetiredhelpers are gone because nothing needs them. The kind check that lets a cron note with a failed DELETE keep its read toggle stays in the feed and the panel, exactly as before. The panel selectsrowPhasewithshallowEqual, and the feed selects the marks through the slice'sapprovalMarkswithshallowEqual, so neither re-renders more often than on main and a mark added torowPhaselater reaches the feed without touching it.Backwards compatibility
Compatible: no state shape, action, existing export or rendered output changes;
rowPhase,approvalMarksandApprovalRowPhaseare new exports.Removes nothing: only private helpers inside the slice and the feed are deleted, and each of their callers now reads
rowPhase.Tests
website/src/store/notificationsSlice.rowPhase.test.ts(new): a table over every phase (no mark, as in state rehydrated without the maps; a mark on another row only; refused; failed after the request ended, with and without a reason; decided with a failed DELETE; retired with a failed DELETE), plus a row with a decision in flight stayinglive.src/test/notificationsSlice.test.ts,src/test/NotificationFeed.retiredApproval.test.tsx,src/test/NotificationDetailPanel.approvalRefusal.test.tsx,src/store/notificationsSlice.refetchIdentity.test.ts, the otherNotificationFeed.*andNotificationDetailPanel.*specs,UseWebSocketCoverage.test.tsxand theNotificationsPage.*andnotificationSheet.*specs.--sequence.shuffle(seeds 1001-1010).Manual verification
N/A — unit coverage sufficient: behaviour is unchanged, and the slice, feed and panel specs that pin each phase's rendering pass without edits.
Screenshots / video
Why no screenshot: internal refactor of how the feed and the detail panel read approval state; every rendered state is unchanged and pinned by the existing specs.
Related Issues
Closes #20618
Sibling sweep
N/A — refactor, no defect fixed.
Pattern harvest
N/A — refactor, no defect fixed.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.