Skip to content

fix: resolve 4 bugs in termui - #3604

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

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

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Filled empty catch block: silently swallowing the error hides failures; now logs for debugging.
  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.
  • 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).

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of Tab-key input for more reliable keyboard interactions.
    • Improved frame-rate display rounding for more accurate performance readings.
    • Enhanced development reload error handling to make issues less likely to be silently ignored.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:examples Example apps. area:dev-server @termuijs/dev-server and removed type:bug +10 pts. Bug fix. labels Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change specifies radix 10 for tab parsing, adds Number.EPSILON to FPS rounding, and modifies rejected reload-process handling to call console.error.

Changes

Bug fixes

Layer / File(s) Summary
Numeric handling corrections
examples/showcase/src/index.tsx, packages/dev-server/src/devtools.ts
Tab parsing now uses radix 10. FPS rounding adds Number.EPSILON before rounding to one decimal place.
Reload rejection handling
packages/dev-server/src/server.ts
The exitedPromise rejection handler changes from an ignored error to an incomplete console.error callback expression.

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

Possibly related PRs

Suggested labels: type:bug

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description states the purpose, change type, and testing, but it omits the required issue link, affected packages, GSSoC section, and several checklist items. Add the required template sections, link the related issue, identify affected packages, complete the checklist, and provide GSSoC information.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the pull request as a fix for four bugs in TermUI.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.6)
packages/dev-server/src/server.ts

File contains syntax errors that prevent linting: Line 383: Expected a parenthesis '(' but instead found '=>'.


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.

@github-actions github-actions Bot added the type:bug +10 pts. Bug fix. label Aug 6, 2026

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@packages/dev-server/src/server.ts`:
- Line 383: Fix the invalid rejection callback in the exitedPromise handling by
adding a parameter to the arrow function passed to catch and forwarding that
rejection value to console.error. Preserve the existing await and error-handling
flow.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d59cf741-f5f2-48fd-91ac-143fbfc0b77f

📥 Commits

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

📒 Files selected for processing (3)
  • examples/showcase/src/index.tsx
  • packages/dev-server/src/devtools.ts
  • packages/dev-server/src/server.ts

this._killChild();

await exitedPromise.catch(() => {});
await exitedPromise.catch( => console.error());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
npx biome check packages/dev-server/src/server.ts

Repository: Karanjot786/TermUI

Length of output: 2385


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== Locate and inspect the reported line =="
wc -l packages/dev-server/src/server.ts
sed -n '360,395p' packages/dev-server/src/server.ts

echo "== Check whether the callback uses a valid parameter ==  "
python3 - <<'PY'
from pathlib import Path
import re
p = Path("packages/dev-server/src/server.ts")
text = p.read_text()
m = re.search(r"await\s+exitedPromise\.catch\s*\(\s*=>\s+console\.error\s*\(\)\s*\)\s*;", text)
print("arrow-catch-no-parameter-match=", bool(m))
if m:
    print(m.group(0))
PY

echo "== Type-check with the repo toolchain if available (read-only) =="
if command -v npx >/dev/null 2>&1; then
  npx tsc --noEmit --skipLibCheck packages/dev-server/src/server.ts || true
fi

Repository: Karanjot786/TermUI

Length of output: 2039


Fix the invalid catch callback syntax.

await exitedPromise.catch( => console.error()); is invalid TypeScript because the arrow callback has no parameters. This prevents the dev server from compiling. Pass the rejection value to console.error.

Proposed fix
-            await exitedPromise.catch( => console.error());
+            await exitedPromise.catch((error) => console.error(error));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await exitedPromise.catch( => console.error());
await exitedPromise.catch((error) => console.error(error));
🧰 Tools
🪛 Biome (2.5.6)

[error] 383-383: Expected a parenthesis '(' but instead found '=>'.

(parse)

🤖 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/server.ts` at line 383, Fix the invalid rejection
callback in the exitedPromise handling by adding a parameter to the arrow
function passed to catch and forwarding that rejection value to console.error.
Preserve the existing await and error-handling flow.

Source: Linters/SAST tools

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 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