1.6 KiB
1.6 KiB
F-074 — Implementer evidence: Audit shows real-time logs from application services
Problem
The admin audit page (/audit) fetched audit log entries once on mount. New entries from application services only appeared after a page refresh.
Changes
project/apps/admin/src/app/(dashboard)/audit/page.tsx:
- Added
useRefimport for stable reference to current items without triggering re-renders - Added
itemsRef(useRef) to keep track of current items for deduplication - Added
newCountstate to track number of new entries since last view - Added
pollingActivestate to track whether polling is active - Added
useEffectthat keepsitemsRefin sync withitemsstate - Added polling
useEffect(5-second interval) that fetches latest entries and prepends new ones:- Polls only when
page === 0and no filter is active - Uses
itemsRef(notitems) to avoid re-running the effect when items change - Deduplicates by
idto avoid showing duplicates - Prepends new entries to list (slice to PAGE_SIZE)
- Increments
newCountfor each new entry
- Polls only when
- Header now shows:
- "● En vivo" (green pulse dot) when polling is active on page 0
- "+N nuevas" badge when new entries have arrived (click to dismiss)
- Polling stops automatically when navigating to page > 0 or when filter is active
Verification
npx tsc --noEmitadmin — exit 0 ✅npx eslinton changed file — exit 0 ✅./scripts/verify.sh— exit 0 ✅
Files touched
project/apps/admin/src/app/(dashboard)/audit/page.tsx (modified)
work/artifacts/F-074/implementer.md (this file)