fix: resolve 4 bugs in termui - #3477
Conversation
📝 WalkthroughWalkthroughThe changes manage the weather refresh interval, log rejected form promises, and replace global ChangesReliability and validation fixes
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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.5)packages/ui/src/Form.tsFile contains syntax errors that prevent linting: Line 142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. 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. Comment |
There was a problem hiding this comment.
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/ui/src/Form.ts`:
- Around line 141-142: Move the rejection handling into the submit() method’s
awaited Promise.all flow, using try/catch or try/finally to reset _isValidating
and call markDirty() on rejection; remove the standalone trailing .catch
expression after protected _renderSelf(...).
🪄 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: 9a89c0be-632d-4be2-9ac7-d1d5ca41bd9d
📒 Files selected for processing (3)
examples/weather/src/index.tsxpackages/ui/src/Form.tspackages/ui/src/prompts.ts
|
|
||
| .catch(err => console.error("Promise.all failed:", err)); No newline at end of file |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
npx biome check packages/ui/src/Form.tsRepository: Karanjot786/TermUI
Length of output: 2385
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '60,155p' packages/ui/src/Form.ts
printf '\n--- syntax check ---\n'
node --check packages/ui/src/Form.ts 2>&1 || trueRepository: Karanjot786/TermUI
Length of output: 3623
Move the rejection handler inside submit().
The .catch(err => console.error(...)) after protected _renderSelf(...) is a standalone method call, not part of the awaited Promise.all. This makes Form.ts invalid TypeScript. Attach rejection handling to the Promise.all await with try/catch or try/finally, reset _isValidating, call markDirty(), and remove the trailing expression.
🧰 Tools
🪛 Biome (2.5.5)
[error] 142-142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.
(parse)
🪛 GitHub Actions: CI / 0_build-and-test.txt
[error] 142-142: UI build failed during 'bun run build' (tsup/esbuild): unexpected '.' at '.catch(err => console.error("Promise.all failed:", err));'. TypeScript also reports malformed syntax, including missing ')' and ';'.
🪛 GitHub Actions: CI / build-and-test
[error] 142-142: The @termuijs/ui build (tsup/esbuild) failed with a syntax error: Unexpected "." at .catch(err => console.error("Promise.all failed:", err));. TypeScript also reports declaration/statement and missing try/) errors.
🤖 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/ui/src/Form.ts` around lines 141 - 142, Move the rejection handling
into the submit() method’s awaited Promise.all flow, using try/catch or
try/finally to reset _isValidating and call markDirty() on rejection; remove the
standalone trailing .catch expression after protected _renderSelf(...).
Source: Linters/SAST tools
Description
This PR fixes real bugs found in the codebase:
x === trueis equivalent tox(andx === falseto!x), and shorter to read.isNaNwithNumber.isNaN: the global version coerces its argument, soisNaN('1')returns false whileNumber.isNaNis strict.Promise.all: an unhandled rejection in any input promise previously crashed silently.Type of Change
How Has This Been Tested?
Checklist
Related Issue
Ref: #3476
Summary by CodeRabbit