diff --git a/webview-ui/src/components/chat/ContextCondenseRow.tsx b/webview-ui/src/components/chat/ContextCondenseRow.tsx index 9664b03e00..c2fdba802d 100644 --- a/webview-ui/src/components/chat/ContextCondenseRow.tsx +++ b/webview-ui/src/components/chat/ContextCondenseRow.tsx @@ -11,6 +11,11 @@ export const ContextCondenseRow = ({ cost, prevContextTokens, newContextTokens, const { t } = useTranslation() const [isExpanded, setIsExpanded] = useState(false) + // Handle null/undefined token values to prevent crashes + const prevTokens = prevContextTokens ?? 0 + const newTokens = newContextTokens ?? 0 + const displayCost = cost ?? 0 + return (
{t("chat:contextCondense.title")} - {prevContextTokens.toLocaleString()} → {newContextTokens.toLocaleString()} {t("tokens")} + {prevTokens.toLocaleString()} → {newTokens.toLocaleString()} {t("tokens")} - 0 ? "opacity-100" : "opacity-0"}>${cost.toFixed(2)} + 0 ? "opacity-100" : "opacity-0"}> + ${displayCost.toFixed(2)} +