Fix: Token count UI doesn't re-render if it's open. (#4822)

This commit is contained in:
David Katz
2025-09-26 14:02:29 -04:00
committed by GitHub
parent 832cb0497c
commit 74517615c5
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -20,5 +20,5 @@ export interface Alert {
compactButtonDisabled?: boolean;
onCompact?: () => void;
compactIcon?: React.ReactNode;
autoCompactThreshold?: number; // Add this for showing the auto-compact threshold
autoCompactThreshold?: number;
}
@@ -1,5 +1,6 @@
import { useRef, useEffect, useCallback, useState } from 'react';
import { FaCircle } from 'react-icons/fa';
import { isEqual } from 'lodash';
import { cn } from '../../utils';
import { Alert, AlertType } from '../alerts';
import { AlertBox } from '../alerts';
@@ -104,10 +105,10 @@ export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) {
return;
}
// Find new or changed alerts
// Find new or changed alerts using deep comparison
const changedAlerts = alerts.filter((alert, index) => {
const prevAlert = previousAlertsRef.current[index];
return !prevAlert || prevAlert.type !== alert.type || prevAlert.message !== alert.message;
return !prevAlert || !isEqual(prevAlert, alert);
});
previousAlertsRef.current = alerts;