Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ai-streaming/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AIStreamingApp extends Widget {
this.addChild(this._toolCall);
this.addChild(this._streamingText);

setInterval(() => {
clearInterval(window.__interval); window.__interval = setInterval(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

node -e 'test -z "$(node -p "typeof window")"'
rg -n -C 3 'window\.__interval|declare global|interface Window|unmount|destroy|dispose|onUnmount|onDestroy' . || true

Repository: Karanjot786/TermUI

Length of output: 522


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== package files =="
fd -a '(^package\.json$|tsconfig.*\.json$|vite\.config\..*)' . | sed 's#^\./##'

echo
echo "== window.__interval and teardown declarations =="
rg -n -C 4 'window\.__interval|declare global|interface Window|unmount|destroy|dispose|onUnmount|onDestroy|Node' . || true

echo
echo "== target file outline =="
ast-grep outline examples/ai-streaming/src/index.tsx || true

echo
echo "== relevant source =="
sed -n '1,120p' examples/ai-streaming/src/index.tsx

echo
echo "== tsconfig files content around strict =="
while IFS= read -r f; do
  echo "--- $f ---"
  sed -n '1,220p' "$f"
done < <(fd -a 'tsconfig.*\.json$' .)

echo
echo "== runtime check for global window in node =="
node -e 'console.log(JSON.stringify(typeof window))'

Repository: Karanjot786/TermUI

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== target file =="
sed -n '1,180p' examples/ai-streaming/src/index.tsx

echo
echo "== all window.__interval occurrences =="
rg -n -C 3 'window\.__interval' examples/ai-streaming || true

echo
echo "== focused teardown mentions in terminal UI core packages =="
rg -n -C 3 '\b(unmount|destroy|dispose|_interval|interval)\b' packages examples \
  --glob '!packages/store/src/store.ts\|!packages/data/src/hooks.ts\|**/node_modules/**' \
  --glob '!**/test*' --max-count 80 || true

Repository: Karanjot786/TermUI

Length of output: 50377


Use a per-instance, typed interval handle and clear it on teardown.

window may be absent in TermUI entrypoints, and window.__interval makes the tick timer shared across AIStreamingApp construction. The constructor also never clears the interval, so unmounting the app can leave a stale callback referencing _streamingText. Store the handle in a private field, set it after the children are mounted, and clear it in unmount()/cleanup.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/ai-streaming/src/index.tsx` at line 43, Update AIStreamingApp to
replace the shared window.__interval timer with a private, appropriately typed
per-instance interval handle. Initialize it after the children are mounted, and
clear the interval during unmount/cleanup while removing the stale window
dependency and ensuring callbacks cannot remain active after teardown.

Source: Coding guidelines

this._streamingText.tick();
}, 50);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server/src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class DevTools {
renderTimeMs: timeMs,
widgetCount,
lastRenderAt: now,
fps: Math.round(fps * 10) / 10,
fps: Math.round(fps * 10 + Number.EPSILON) / 10,
memoryMB: Math.round((process.memoryUsage?.().heapUsed ?? 0) / 1024 / 1024 * 10) / 10,
};
}
Expand Down
Loading