Skip to content

fix: resolve 4 bugs in termui - #3677

Closed
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-40005
Closed

fix: resolve 4 bugs in termui#3677
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-40005

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Prevented interval leak: repeated mounts now clear the previous interval before scheduling a new one.
  • Simplified empty-string validation: comparing trim() to '' misses whitespace-only input; .trim().length === 0 is explicit.
  • Replaced global isNaN with Number.isNaN: the global version coerces its argument, so isNaN('1') returns false while Number.isNaN is strict.
  • Removed redundant boolean comparison: x === true is equivalent to x (and x === false to !x), and shorter to read.

Type of Change

  • Bug fix (non-breaking change fixing an issue)

How Has This Been Tested?

  • Local manual testing

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Related Issue

Ref: #3676

Summary by CodeRabbit

  • Bug Fixes
    • Prevented overlapping streaming timers during AI example updates.
    • Improved handling of invalid negative-number calculations.
    • Ensured rendering is rescheduled whenever the application has pending visual updates.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:examples Example apps. area:core @termuijs/core labels Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ad432ea-a565-4e4e-b60f-376ccbce09b7

📥 Commits

Reviewing files that changed from the base of the PR and between 6c7584e and d446ffe.

📒 Files selected for processing (3)
  • examples/ai-streaming/src/index.tsx
  • examples/calculator/src/index.tsx
  • packages/core/src/app/App.ts

📝 Walkthrough

Walkthrough

The changes apply three isolated fixes: clear existing AI streaming timers, use Number.isNaN for calculator validation, and reschedule rendering for any truthy root-widget dirty state.

Changes

Streaming timer handling

Layer / File(s) Summary
Clear the existing streaming interval
examples/ai-streaming/src/index.tsx
The constructor clears the existing interval before creating a new 50 ms interval.

Calculator numeric validation

Layer / File(s) Summary
Use explicit NaN detection
examples/calculator/src/index.tsx
The negative-number check converts the token to a number before calling Number.isNaN.

Render rescheduling

Layer / File(s) Summary
Accept truthy dirty state
packages/core/src/app/App.ts
The post-render check reschedules rendering when _rootWidget.isDirty is truthy.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fixes and testing, but it omits required package, GSSoC, and template checklist details. Add the affected package(s), use the required checklist fields, provide the GSSoC section, and link the issue with the required Closes # format.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies a bug-fix pull request and summarizes its four related fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core @termuijs/core area:examples Example apps. type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant