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(() => {
this._streamingText.tick();
}, 50);
Comment on lines +43 to 45

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

rg -n -C 5 '\bunmount\s*\(' --glob '*.ts' --glob '*.tsx' .
rg -n -C 5 '__interval|setInterval\(|clearInterval\(' --glob '*.ts' --glob '*.tsx' .

Repository: Karanjot786/TermUI

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate file list =="
fd -a 'index\.tsx$|BaseWidget|Widget|render\.ts$' . | sed 's#^\./##' | head -200

echo
echo "== examples/ai-streaming/src/index.tsx outline and contents =="
if [ -f examples/ai-streaming/src/index.tsx ]; then
  wc -l examples/ai-streaming/src/index.tsx
  ast-grep outline examples/ai-streaming/src/index.tsx || true
  cat -n examples/ai-streaming/src/index.tsx
fi

echo
echo "== Widget base unmount definition =="
rg -n -C 8 'class .*Widget|unmount\(\)|super\.unmount\(\)' packages/widgets --glob '*.ts' --glob '*.tsx' | head -300

Repository: Karanjot786/TermUI

Length of output: 26187


Clear the streaming timer when AIStreamingApp is unmounted.

The constructor keeps the handle in window.__interval, so only a later instance can clear it. If AIStreamingApp is destroyed without another app replacing it, the 50 ms timer keeps calling this._streamingText.tick() and retains the unmounted app. Store the handle on the instance and clear it from an overridden unmount() before calling super.unmount().

🤖 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` around lines 43 - 45, Update the
AIStreamingApp constructor’s interval setup to store the timer handle on the
instance instead of window.__interval, and clear any existing timer there.
Override AIStreamingApp.unmount() to clear the instance timer before calling
super.unmount(), preventing tick() from running after destruction.

}
Expand Down
2 changes: 1 addition & 1 deletion examples/calculator/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function safeEval(expr: string): string {
if (tokens.length === 0) return '0';

// Handle initial negative number
if (tokens[0] === '-' && tokens.length > 1 && !isNaN(Number(tokens[1]))) {
if (tokens[0] === '-' && tokens.length > 1 && !Number.isNaN(Number(tokens[1]))) {
tokens.splice(0, 2, '-' + tokens[1]);
}

Expand Down
Loading