fix: resolve 4 bugs in termui - #3421
Conversation
📝 WalkthroughWalkthroughThe changes improve whitespace parsing, enforce decimal tab-key parsing, track and clear the weather refresh interval, and log rejected ChangesParsing and runtime reliability updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: Fix the validation flow in Form by attaching the
rejection handler directly to the Promise.all call or wrapping await
Promise.all(validationPromises in try/catch; on rejection, reset _isValidating,
call markDirty(), and return, while preserving the successful validation path.
🪄 Autofix (Beta)
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: d93507f8-762a-423f-aebf-023a45ac6b47
📒 Files selected for processing (4)
examples/chat-app/src/index.tsxexamples/showcase/src/index.tsxexamples/weather/src/index.tsxpackages/ui/src/Form.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
Attach the rejection handler to Promise.all.
Line 142 starts with .catch(...) as a standalone expression. This is invalid TypeScript syntax, so packages/ui/src/Form.ts cannot compile. Wrap the await Promise.all(validationPromises) call in try/catch or attach .catch directly to that expression. When validation rejects, reset _isValidating and call markDirty() before returning.
Suggested structure
-const results = await Promise.all(validationPromises);
+try {
+ const results = await Promise.all(validationPromises);
+ // Keep the existing result-processing logic inside this block.
+} catch (err) {
+ console.error('Promise.all failed:', err);
+ this._isValidating = false;
+ this.markDirty();
+ return;
+}
...
-.catch(err => console.error("Promise.all failed:", err));🧰 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: Build failed during 'tsup' because of an unexpected '.' at the start of the '.catch(err => console.error("Promise.all failed:", err));' statement.
🪛 GitHub Actions: CI / build-and-test
[error] 142-142: Build failed in the tsup step: Unexpected '.' at the start of the catch call. Command 'bun run build' exited with code 1.
🤖 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, Fix the validation flow in
Form by attaching the rejection handler directly to the Promise.all call or
wrapping await Promise.all(validationPromises in try/catch; on rejection, reset
_isValidating, call markDirty(), and return, while preserving the successful
validation path.
Source: Linters/SAST tools
Description
This PR fixes real bugs found in the codebase:
parseInt: without10, strings like'0x1F'or'08'parse in unintended bases.Promise.all: an unhandled rejection in any input promise previously crashed silently.trim()to''misses whitespace-only input;.trim().length === 0is explicit.Type of Change
How Has This Been Tested?
Checklist
Related Issue
Ref: #3420
Summary by CodeRabbit