fix: resolve 4 bugs in termui - #3722
Conversation
📝 WalkthroughWalkthroughThe PR clears stale streaming timers, makes tab-key parsing explicitly base 10, and logs rejected promises in the dev server and UI form. The dev-server rejection handler has invalid syntax. ChangesStreaming timer lifecycle
Numeric tab parsing
Promise rejection logging
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.6)packages/dev-server/src/server.tsFile contains syntax errors that prevent linting: Line 383: Expected a parenthesis '(' but instead found '=>'. 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/dev-server/src/server.ts`:
- Line 383: Fix the malformed rejection handler in
packages/dev-server/src/server.ts lines 383-383 by making the catch callback
accept the rejected error and log it. In packages/ui/src/Form.ts lines 141-142,
attach a rejection handler to the Promise.all expression or handle it with
try/catch, logging the failure error. Update the relevant promise-handling code
in both sites so the TypeScript parses correctly.
🪄 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: cb2b99be-ef75-427b-a770-e7f0e99bae62
📒 Files selected for processing (4)
examples/ai-streaming/src/index.tsxexamples/showcase/src/index.tsxpackages/dev-server/src/server.tspackages/ui/src/Form.ts
| this._killChild(); | ||
|
|
||
| await exitedPromise.catch(() => {}); | ||
| await exitedPromise.catch( => console.error()); |
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/dev-server/src/server.ts packages/ui/src/Form.tsRepository: Karanjot786/TermUI
Length of output: 2385
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- server.ts context ---\n'
nl -ba packages/dev-server/src/server.ts | sed -n '370,390p'
printf '\n--- Form.ts context ---\n'
nl -ba packages/ui/src/Form.ts | sed -n '125,150p'
printf '\n--- syntax/statistic checks ---\n'
node - <<'JS'
const { readFileSync } = require('node:fs');
const { resolveConfigSync } = require('/root/.npm/_npx/79069e5e14faec0b/node_modules/@biomejs/biome');
const files = [
'packages/dev-server/src/server.ts',
'packages/ui/src/Form.ts',
];
for (const file of files) {
const src = readFileSync(file, 'utf8');
console.log(`FILE ${file}`);
console.log(`contains catch(( =>`: /(catch)\s*\(\s*=>/.test(src));
console.log(`contains Promise.all and .catch nearby:`);
const lines = src.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('Promise.all') || line.trim().startsWith('.catch')) {
console.log(`${i + 1}: ${line}`);
}
}
try {
const _ = resolveConfigSync(__dirname, {});
console.log('biome config: success');
} catch (err) {
console.log('biome config: ' + String(err.message || err));
}
try {
// eslint is not available, so only use the parser package if present; otherwise print unavailable.
const { parserOptions, parseSync } = resolveConfigSync(__dirname, {vcs: {enabled: false}});
console.log(`parse ${file}: ${parseSync(file, src, {}).diagnostic?.message ?? 'ok'}`);
} catch (err) {
const msg = String(err && err.message || err);
console.log(`parse ${file}: ${msg}`);
}
}
JSRepository: Karanjot786/TermUI
Length of output: 247
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- server.ts context ---'
nl -ba packages/dev-server/src/server.ts | sed -n '370,390p'
printf '%s\n' ''
printf '%s\n' '--- Form.ts context ---'
nl -ba packages/ui/src/Form.ts | sed -n '125,150p'
printf '%s\n' ''
printf '%s\n' '--- syntax/statistic checks ---'
node - <<'JS'
const { readFileSync } = require('node:fs');
const files = [
'packages/dev-server/src/server.ts',
'packages/ui/src/Form.ts',
];
for (const file of files) {
const src = readFileSync(file, 'utf8');
console.log(`FILE ${file}`);
console.log(`contains malformed catch callback: ${/\b(catch)\s*\(\s*=>/.test(src)}`);
console.log(`lines with Promise.all or .catch:`);
const lines = src.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('Promise.all') || line.trim().startsWith('.catch')) {
console.log(`${i + 1}: ${line}`);
}
}
}
JSRepository: Karanjot786/TermUI
Length of output: 222
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- server.ts context ---'
awk 'NR==370,NR==390 {printf "%6d\t%s\n", NR, $0}' packages/dev-server/src/server.ts
printf '%s\n' ''
printf '%s\n' '--- Form.ts context ---'
awk 'NR==125,NR==150 {printf "%6d\t%s\n", NR, $0}' packages/ui/src/Form.tsRepository: Karanjot786/TermUI
Length of output: 2188
Fix the malformed Promise rejection handlers before merging.
These changes make the TypeScript files unparsable.
packages/dev-server/src/server.ts#L383: changecatch( => console.error())tocatch((error) => console.error(error))or equivalent.packages/ui/src/Form.ts#L142: attach.catch((err) => console.error("Promise.all failed:", err))to thePromise.all(...)expression it rejects, or move it intotry/catch.
🧰 Tools
🪛 Biome (2.5.6)
[error] 383-383: Expected a parenthesis '(' but instead found '=>'.
(parse)
📍 Affects 2 files
packages/dev-server/src/server.ts#L383-L383(this comment)packages/ui/src/Form.ts#L141-L142
🤖 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 rejection
handler in packages/dev-server/src/server.ts lines 383-383 by making the catch
callback accept the rejected error and log it. In packages/ui/src/Form.ts lines
141-142, attach a rejection handler to the Promise.all expression or handle it
with try/catch, logging the failure error. Update the relevant promise-handling
code in both sites so the TypeScript parses correctly.
Source: Linters/SAST tools
Description
This PR fixes real bugs found in the codebase:
Promise.all: an unhandled rejection in any input promise previously crashed silently.parseInt: without10, strings like'0x1F'or'08'parse in unintended bases.Type of Change
How Has This Been Tested?
Checklist
Related Issue
Ref: #3721
Summary by CodeRabbit