fix(mobile-inbox): ignore stale fetches after tab switch (core#2766 / CR2 #11478) #2828
Reference in New Issue
Block a user
Delete Branch "fix/2766-mobile-inbox-stale-action"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #2793, which fixed the wrong-action race in MobileInbox by deriving the primary action from
r.kind. This PR closes the remaining stale-render path:/requests/pendingfetch with an incrementingloadSeqRefsequence token.itemsimmediately when the activekindchanges so the user never sees approval cards under the Tasks tab while the new list is loading.setItemsorsetLoading(false).Verification (per reviewer request):
MobileInbox.test.tsx:89because main does not clear stale rows immediately.npx vitest run src/components/mobile/__tests__/MobileInbox.test.tsx).Prior PR that closed #2766: #2793 (commit
a043af6c). #2793 fixed the wrong-action race; it did not guard against stale fetches resolving after a tab switch, which is what this change addresses.Closes core#2766 / CR2 #11478
🤖 Generated with Claude Code
APPROVED on head
ae540192.Verified CI on the matching head: Canvas (Next.js) job 496019 is a real run, not a no-op, with checkout/setup/npm ci/build/tests-with-coverage all executed successfully;
CI / all-requiredjob 496023 is green.The fix is scoped and correct.
loadSeqRefincrements per load, clears rows immediately on the new tab load, and guards then/catch/finally so superseded responses cannot set stale items or loading state. The current fetch is not discarded because it owns the latest sequence. This composes with the existing #2793 row.kind action derivation; that code is unchanged, so stale rendering is prevented while action selection still comes from the row itself.The regression test exercises the delayed old approval fetch resolving after a Tasks switch and verifies the approval row is not rendered under Tasks before the task fetch completes. No security, performance, or readability concerns.
APPROVED on head
ae5401920a.Verified the live head is mergeable and the diff is scoped to MobileInbox.tsx plus MobileInbox.test.tsx. Canvas CI was a real successful run on this head (run 363416, job 496019, 06:12:15-06:16:02Z) and ran npm ci, build, and vitest coverage rather than a no-op.
The MobileInbox fix clears stale rows immediately on kind changes and uses loadSeqRef to ignore superseded fetch completions. The existing action derivation remains row-kind based (r.kind === approval => approved, otherwise done), so it does not disturb the #2793 action-by-kind behavior. The regression test now asserts the stale approval row is gone after switching to Tasks before the task fetch resolves.
Submitting approval review #11601.