fix(history): add an error state and cancel out-of-order loads on the History page
WHY THIS MATTERS
Two UX/correctness bugs. When the fetch failed the catch cleared the list, so a
backend outage rendered the "No history yet" empty state - telling the user they
have no history when the truth is the request failed. And rapid filter changes
raced: because responses can arrive out of order, a slow earlier request could
land after a faster later one and overwrite it with stale rows, and a "Load
more" issued mid-filter-change appended a page from the old filter (wrong rows
and duplicate React key={e.id} warnings).
WHAT IS AN OUT-OF-ORDER RESPONSE RACE
The browser does not guarantee that fetches resolve in the order they were
started. If you fire request A (filter=all) then request B (filter=chat), B may
resolve first and A second, leaving the UI showing "all" results under a "chat"
filter. The standard fix is an AbortController: each new load aborts the
previous in-flight request, and the handler ignores any response whose signal
was aborted so a superseded request can neither overwrite fresher state nor
surface a false error.
HOW IT WORKS
- getAuditHistory (mikeApi) gains an optional AbortSignal, threaded into the
underlying fetch via RequestInit.
- HistoryTable keeps the live controller in a ref. Each load() aborts the
previous controller, starts a new one, and passes its signal down. Responses
are dropped when controller.signal.aborted; the aborted-request rejection
(AbortError) is swallowed rather than treated as an error. The effect's
cleanup aborts on unmount.
- A dedicated error state renders "Couldn't load your history - Try again"
(with a retry button) instead of the misleading empty state; the genuine
empty state only shows when there was no error.
- Nit (F12): drops a leaked private-fork "(Clue custom)" comment from
HistorySkeuoIcon.
Frontend tsc is clean and the existing suite passes; the History page has no
pre-existing component test to extend.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Repository | open-legal-products/mike |
|---|---|
| Author | Amal <mamalanand3@gmail.com> |
| Authored | |
| Committed | |
| Parents | 97478819 |
| Stats | 3 files changed , +65 , -21 |
| Part of | Add workspace audit history |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-3cba69ae.md
from inside the repo you want the change in.