From 34b0b3db5909dbdbfc844a9c4ae6fcad4897346d Mon Sep 17 00:00:00 2001 From: abhay-codes07 Date: Wed, 22 Jul 2026 16:56:55 +0530 Subject: [PATCH] fix(web): keep highlights card active index in range on refresh The Daily Brief refreshes on its own every few hours, replacing the items array, and the paging controls also let the user sit on a later index. When a refresh returns fewer highlights than before, activeIndex was left pointing past the end of the new list, so currentItem became undefined and the card rendered the "Add some documents" empty state even though highlights existed, with no pagination shown to recover from it. Clamp activeIndex back into range whenever items changes, alongside the existing reply/expansion reset. Also drops a now-unnecessary useExhaustiveDependencies suppression, since the effect body now reads items.length so items is a real dependency. --- apps/web/components/highlights-card.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/components/highlights-card.tsx b/apps/web/components/highlights-card.tsx index 38257d2e..ff3b4e36 100644 --- a/apps/web/components/highlights-card.tsx +++ b/apps/web/components/highlights-card.tsx @@ -92,8 +92,12 @@ export function HighlightsCard({ if (isReplyOpen) replyInputRef.current?.focus() }, [isReplyOpen]) - // biome-ignore lint/correctness/useExhaustiveDependencies: intentionally re-run when items changes useEffect(() => { + // The Daily Brief refreshes on its own every few hours, so items can be + // replaced with a shorter list while the user is on a later page. Pull the + // active index back into range, otherwise currentItem is undefined and the + // card falls through to the empty state even though highlights exist. + setActiveIndex((i) => Math.min(i, Math.max(items.length - 1, 0))) setIsReplyOpen(false) setReplyText("") setIsExpanded(false)