Skip to content

fix: resolve 4 bugs in termui - #3552

Open
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-66123
Open

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

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Simplified empty-string validation: comparing trim() to '' misses whitespace-only input; .trim().length === 0 is explicit.
  • Added Number.EPSILON to Math.round: prevents floating-point drift (e.g. 1.005 * 100 rounding to 100 instead of 101).
  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.
  • Added Number.EPSILON to Math.round: prevents floating-point drift (e.g. 1.005 * 100 rounding to 100 instead of 101).

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: #3551

Summary by CodeRabbit

  • Bug Fixes
    • Improved FPS display accuracy in DevTools by preventing minor floating-point rounding errors.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:dev-server @termuijs/dev-server labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The FPS calculation in DevTools.recordRender now adds Number.EPSILON before rounding to one decimal place.

Changes

FPS rounding correction

Layer / File(s) Summary
Update FPS rounding
packages/dev-server/src/devtools.ts
DevTools.recordRender adds Number.EPSILON before rounding the FPS value to one decimal place.

Estimated code review effort: 1 (Trivial) | ~2 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 covers the bug-fix intent but omits required package, GSSoC, and template sections, and uses Ref: #3551 instead of `Closes `#3551. Complete all required template sections, specify the affected package, use Closes #3551``, and complete the checklist and GSSoC profile fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format and identifies the pull request as a four-bug TermUI fix.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/dev-server/src/devtools.ts (1)

81-81: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for FPS rounding.

packages/dev-server/src/devtools.test.ts:308-313 verifies hover-state clearing, but it does not verify PerfMetrics.fps. Add a deterministic test that controls Date.now() or uses fake timers, calls recordRender, selects the perf tab, and asserts the one-decimal FPS output. Include a floating-point boundary case targeted by Number.EPSILON.

🤖 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 `@packages/dev-server/src/devtools.ts` at line 81, Add a deterministic
regression test in the devtools test suite covering the FPS calculation in
recordRender: control Date.now() or use fake timers, record renders, select the
perf tab, and assert PerfMetrics.fps is rounded to one decimal place. Include a
floating-point boundary value that exercises the Number.EPSILON adjustment while
preserving the existing hover-state coverage.
🤖 Prompt for all review comments with 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.

Nitpick comments:
In `@packages/dev-server/src/devtools.ts`:
- Line 81: Add a deterministic regression test in the devtools test suite
covering the FPS calculation in recordRender: control Date.now() or use fake
timers, record renders, select the perf tab, and assert PerfMetrics.fps is
rounded to one decimal place. Include a floating-point boundary value that
exercises the Number.EPSILON adjustment while preserving the existing
hover-state coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c617dad1-1f46-4c94-a104-51f45817d6e6

📥 Commits

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

📒 Files selected for processing (1)
  • packages/dev-server/src/devtools.ts

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

Labels

area:dev-server @termuijs/dev-server type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant