Skip to content

fix(web): coalesce task list reloads after deletes - #22259

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/web-tasks-bulk-delete-reloads
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/web-tasks-bulk-delete-reloads

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22258.

On the web Tasks page, 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 (select all, then Delete) therefore sent N list reads at once:

  • The backend serves 12 list reads per minute per account (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.
  • The reads raced, and whichever answered last was applied, even one issued before a later delete. Deleted tasks then came back on screen until the next reload. Two single deletes in quick succession can hit the same race.

fetchItems now 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: bulkDelete still sends one DELETE per task, although the backend has POST /v1/action-items/batch-delete.

Product invariants affected

none

How it was verified

  • Read the delete → invalidation → reload path in web/app/src/lib/api.ts, web/app/src/lib/cache.ts and the hook, plus the list limit in backend/utils/rate_limit_config.py.
  • I wrote both regression tests to fail without the fix. I checked this by tracing the code, not by running them. On current main, the bulk-delete test makes 16 list reads, four of them 429, and ends with the error and four deleted tasks still listed. The second test shows the deleted task b again once the first reload answers.
  • Both tests run in Omi's CI (web-app-checks, i.e. bun run check) with ci:full. I did not run them locally.
  • git diff --check is 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

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]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 18, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed bug (bulk task delete fires N parallel list reloads, triggers 429s and resurrects deleted rows via race, fixes #22258); scoped hook fix + regression tests, CI green, CLEAN.

@kodjima33
kodjima33 merged commit a629cf3 into BasedHardware:main Oct 19, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web Tasks: bulk delete reloads the task list once per deleted task (429 error, deleted tasks reappear)

3 participants