Skip to content

fix: resolve 4 bugs in termui - #3560

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

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

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 5, 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.
  • 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.
  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved keyboard handling in the showcase and widget gallery examples so numeric keys are interpreted consistently.
    • Made weather updates more reliable by ensuring only one refresh timer runs at a time.
    • Enhanced reload error reporting so failures are surfaced instead of being hidden.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:examples Example apps. 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

This change updates example keyboard parsing to use radix 10, tracks and replaces the weather refresh interval on window.__interval, and logs rejected child-process exit promises during dev-server reload.

Changes

Example runtime fixes

Layer / File(s) Summary
Input parsing and refresh handling
examples/showcase/src/index.tsx, examples/widget-gallery/src/index.ts, examples/weather/src/index.tsx
ShowcaseApp.handleKey and WidgetGalleryApp.handleKey now call parseInt(..., 10). The weather example clears window.__interval before storing and starting a new 5-second interval.

Dev-server reload logging

Layer / File(s) Summary
Reload error logging
packages/dev-server/src/server.ts
The reload handler now logs errors from the awaited child-process exit promise instead of ignoring them.

Estimated code review effort: 2 (Simple) | ~8 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 fixes and testing but omits required package, GSSoC, and checklist details and does not use the required issue-closing format. Complete all required template sections, identify affected packages, use Closes #3559``, and mark or explain every checklist and GSSoC item.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the change as a bug fix for four TermUI issues and follows the required type format.
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.

@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 malformed catch callback in the exitedPromise handling by
declaring a parameter for the rejection value, then preserve the existing
console.error logging using that value.
🪄 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: 2a139afb-c120-4495-a547-298c057e6cbe

📥 Commits

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

📒 Files selected for processing (4)
  • examples/showcase/src/index.tsx
  • examples/weather/src/index.tsx
  • examples/widget-gallery/src/index.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:

#!/bin/bash
set -euo pipefail

if rg -nP 'exitedPromise\.catch\(\s*=>|catch\(\s*=>' packages/dev-server/src/server.ts; then
  echo "Malformed Promise.catch callback remains" >&2
  exit 1
fi

Repository: Karanjot786/TermUI

Length of output: 261


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'File excerpt:\n'
sed -n '375,388p' packages/dev-server/src/server.ts

printf '\nSyntax check with TypeScript if available:\n'
if command -v tsc >/dev/null 2>&1; then
  tmp="$(mktemp -d)/server.ts"
  sed -n '1,420p' packages/dev-server/src/server.ts > "$tmp"
  if tsc --noEmit --strict --target es2022 --module es2022 "$tmp" 2>&1 | grep -n "383"; then
    echo "ERROR"
  else
    echo "No parse error reported at line 383"
  fi
else
  echo "tsc not found"
fi

Repository: Karanjot786/TermUI

Length of output: 920


Fix the malformed .catch callback.

packages/dev-server/src/server.ts:383 has invalid TypeScript syntax: catch is missing an argument expression, so the source does not compile. Pass the rejection value to the callback.

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 malformed catch
callback in the exitedPromise handling by declaring a parameter for the
rejection value, then preserve the existing console.error logging using that
value.

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