Repository navigation
Conversation
Every successful task delete invalidates the action-items cache, and useActionItems answered each invalidation with its own full GET /v1/action-items?limit=500. Bulk-deleting N tasks fired N list reads at once. The backend serves 12 of those per minute per account, so past that the Tasks page showed "API error: 429 Too Many Requests" although every delete had succeeded. The reads also raced: whichever answered last was applied, even one issued before a later delete, so deleted tasks came back on screen until the next reload. Reloads now run one at a time. A reload requested while one is in flight shares it and queues a single follow-up read, and the in-flight answer is not applied because it can predate the newer delete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
The production change here is correct and nicely scoped, and the regression tests are real — approving.
web/app/src/hooks/useActionItems.ts — fetchItems now serializes list reads behind fetchInFlightRef with a single queued follow-up (refetchQueuedRef), and loadItems discards a stale in-flight answer when a newer reload was requested. That is the right shape: bulk-deleting N tasks now costs at most 2 list reads (the shared in-flight one + one queued) instead of N, and the last-write-wins race that resurrected deleted tasks is gone. Initial-load, error handling, and the keep-list-visible behavior are unchanged.
web/app/src/hooks/tests/useActionItems.test.tsx — the two new tests reproduce the failure modes faithfully: the 429 storm (15 deletes against the real 12/min action_items:list bucket in backend/utils/rate_limit_config.py) and the stale-answer resurrection. The beforeEach switch from vi.clearAllMocks() to vi.resetAllMocks() is correct — the new tests install mockImplementations that must not leak across tests. I ran the suite on this head (3/3 pass) and against the pre-fix hook (both new tests fail exactly as the PR describes: 429 error surfaced, deleted task resurrected), so the coverage is confirmed empirically rather than by trace.
Performance: bulk delete of N tasks goes from N concurrent GET /v1/action-items?limit=500 to at most 2 sequential reads — comfortably inside the 12/min per-account bucket.
Blast radius: only the Tasks page reload path; other consumers of the hook see the same data, just without the duplicate reads.
USER IMPACT: after deleting several tasks at once, the list now settles correctly in one update — no "429 Too Many Requests" error and no deleted tasks briefly reappearing.
Non-blocking, for a follow-up: the queued follow-up read adds one extra read's latency when a burst of invalidations lands (fine here); and bulkDelete still sends one DELETE per task — since POST /v1/action-items/batch-delete exists, switching to it would remove the write-side fan-out too.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
What changed and why
Fixes #22258.
On the web Tasks page, every successful task delete invalidates the action-items cache, and
useActionItemsanswered each invalidation with its own fullGET /v1/action-items?limit=500. Bulk-deleting N tasks (select all, then Delete) therefore sent N list reads at once:action_items:list). Past that the reads came back 429, and the page showed "API error: 429 Too Many Requests" although every delete had succeeded. The bucket is per account, so the user's other clients also got 429 on their task list for the rest of that minute.fetchItemsnow runs one read at a time. A reload requested while one is in flight shares it and queues one follow-up read. The in-flight answer is not applied, because it can predate the newer delete. The initial load, error handling, and keeping the list visible during a refetch are unchanged.Out of scope:
bulkDeletestill sends one DELETE per task, although the backend hasPOST /v1/action-items/batch-delete.Product invariants affected
none
How it was verified
web/app/src/lib/api.ts,web/app/src/lib/cache.tsand the hook, plus the list limit inbackend/utils/rate_limit_config.py.bagain once the first reload answers.web-app-checks, i.e.bun run check) withci:full. I did not run them locally.git diff --checkis clean.Tests
In
web/app/src/hooks/__tests__/useActionItems.test.tsx:coalesces the reloads a bulk delete triggers instead of one per deleted task: deletes 15 tasks against a fake list endpoint that returns 429 after 12 reads. It expects 3 reads in total, an empty list and no error.does not bring back a task deleted while an earlier reload was in flight: the first delete's reload answers after the second delete. It expects the second task to stay gone.UI evidence
UI-Evidence: none -- behaviour-only hook change with no layout or visual change; the hook tests above cover it
Failure class (fixes)
Failure-Class: FC-read-in-flight-across-delete-resurrects-row
🤖 Generated with Claude Code