Commit 2055893fbc41

Vincent Demeester <vincent@sbr.pm>
2026-02-06 23:38:07
fix(custom-footer): handle NaN in context usage display
Fixed division by zero when usage.limit is 0 or undefined, which caused NaN to appear in footer. Now returns null to hide context info when data is invalid.
1 parent 7aea508
Changed files (1)
dots
pi
agent
dots/pi/agent/extensions/custom-footer.ts
@@ -224,12 +224,9 @@ function getThinkingInfo(pi: any): { emoji: string; level: string } | null {
 function getContextInfo(ctx: any, autoCompact: boolean): string | null {
 	try {
 		const usage = ctx.getContextUsage?.();
-		if (!usage) return null;
-		
-		const percent = usage.limit > 0 
-			? ((usage.tokens / usage.limit) * 100).toFixed(1)
-			: "0";
+		if (!usage || !usage.limit || usage.limit === 0) return null;
 		
+		const percent = ((usage.tokens / usage.limit) * 100).toFixed(1);
 		const compactStatus = autoCompact ? " (auto)" : "";
 		
 		return `${percent}%/${formatNumber(usage.limit)}${compactStatus}`;