mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: handle null/undefined token values in ContextCondenseRow to prevent UI crash (#6916)
* fix: handle null/undefined token values in ContextCondenseRow to prevent UI crash - Added null/undefined checks for prevContextTokens, newContextTokens, and cost - Default to 0 when values are null or undefined - Added comprehensive test coverage for edge cases - Fixes #6914 * Delete webview-ui/src/components/chat/__tests__/ContextCondenseRow.spec.tsx --------- Co-authored-by: Roo Code <roomote@roocode.com> Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
This commit is contained in:
parent
a5b143bb44
commit
b2fdb9ac57
1 changed files with 9 additions and 2 deletions
|
|
@ -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 (
|
||||
<div className="mb-2">
|
||||
<div
|
||||
|
|
@ -33,9 +38,11 @@ export const ContextCondenseRow = ({ cost, prevContextTokens, newContextTokens,
|
|||
<span className="codicon codicon-compress text-blue-400" />
|
||||
<span className="font-bold text-vscode-foreground">{t("chat:contextCondense.title")}</span>
|
||||
<span className="text-vscode-descriptionForeground text-sm">
|
||||
{prevContextTokens.toLocaleString()} → {newContextTokens.toLocaleString()} {t("tokens")}
|
||||
{prevTokens.toLocaleString()} → {newTokens.toLocaleString()} {t("tokens")}
|
||||
</span>
|
||||
<VSCodeBadge className={cost > 0 ? "opacity-100" : "opacity-0"}>${cost.toFixed(2)}</VSCodeBadge>
|
||||
<VSCodeBadge className={displayCost > 0 ? "opacity-100" : "opacity-0"}>
|
||||
${displayCost.toFixed(2)}
|
||||
</VSCodeBadge>
|
||||
</div>
|
||||
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue