From 811d9dec1e5f78aea01e89f6d5d7e8f8abc9a69c Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Wed, 5 Aug 2026 17:58:48 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/pomodoro-timer/src/index.tsx | 2 +- examples/rss-reader/src/index.tsx | 2 +- examples/showcase/src/index.tsx | 2 +- examples/weather/src/index.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pomodoro-timer/src/index.tsx b/examples/pomodoro-timer/src/index.tsx index cad749f32..6444f948d 100644 --- a/examples/pomodoro-timer/src/index.tsx +++ b/examples/pomodoro-timer/src/index.tsx @@ -182,7 +182,7 @@ class GradientProgressBar extends Widget { const attrs = styleToCellAttrs(this._style); - const label = this._showLabel ? ` ${Math.round(this._value * 100)}%` : ''; + const label = this._showLabel ? ` ${Math.round(this._value * 100 + Number.EPSILON)}%` : ''; const barWidth = Math.max(0, width - label.length); const filled = this._value <= 0 ? 0 : Math.round(barWidth * this._value); const empty = barWidth - filled; diff --git a/examples/rss-reader/src/index.tsx b/examples/rss-reader/src/index.tsx index 2b269cb81..5ff542b3f 100644 --- a/examples/rss-reader/src/index.tsx +++ b/examples/rss-reader/src/index.tsx @@ -27,7 +27,7 @@ function decodeEntities(value: string): string { return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity: string) => { if (entity.startsWith('#x')) { - const codePoint = Number.parseInt(entity.slice(2), 16); + const codePoint = Number.parseInt(entity.slice(2, 10), 16); return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match; } diff --git a/examples/showcase/src/index.tsx b/examples/showcase/src/index.tsx index 444be6698..47a52a3e3 100644 --- a/examples/showcase/src/index.tsx +++ b/examples/showcase/src/index.tsx @@ -128,7 +128,7 @@ class ShowcaseApp extends Widget { if (event.key === 'q' || (event.ctrl && event.key === 'c')) return false; // Tab switching: 1-5 - const num = parseInt(event.key); + const num = parseInt(event.key, 10); if (num >= 1 && num <= 5) { this.switchTab(num - 1); return true; diff --git a/examples/weather/src/index.tsx b/examples/weather/src/index.tsx index dce3c7425..2dcf862ec 100644 --- a/examples/weather/src/index.tsx +++ b/examples/weather/src/index.tsx @@ -201,7 +201,7 @@ async function fetchWeather() { } } -setInterval(fetchWeather, 5000); +clearInterval(window.__interval); window.__interval = setInterval(fetchWeather, 5000); fetchWeather(); // Gauge does not expose a public setColor() method, so dynamic color