-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,7 +380,7 @@ export class DevServer { | |
|
|
||
| this._killChild(); | ||
|
|
||
| await exitedPromise.catch(() => {}); | ||
| await exitedPromise.catch( => console.error()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
npx biome check packages/dev-server/src/server.tsRepository: Karanjot786/TermUI Length of output: 2385 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Relevant server.ts line context:\n'
sed -n '370,390p' packages/dev-server/src/server.ts | nl -ba -v370
printf '\nParse probe for the exact callback form with Node TypeScript parser if available:\n'
node --version
node --input-type=module - <<'JS'
for (const src of [
'await exitedPromise.catch( => console.error());',
'await Promise.resolve().catch((err) => console.error("Child process exit failed:", err));',
]) {
try {
new Function(src);
console.log('runtime syntax ok:', src);
} catch (error) {
console.log(`${error.name}: ${error.message.split('\n')[0]}`);
console.log(src);
}
}
JS
printf '\nTypeScript syntax check if local typescript is available:\n'
if command -v npx >/dev/null 2>&1; then
npx -y typescript@latest -v
cat > /tmp/check_syntax.ts <<'TS'
const exitedPromise = Promise.reject(new Error("x"));
await exitedPromise.catch( => console.error());
await exitedPromise.catch((err) => {
console.error('Child process exit failed:', err);
});
TS
npx -y typescript@latest --noEmit --strict /tmp/check_syntax.ts || true
else
echo "npx unavailable"
fiRepository: Karanjot786/TermUI Length of output: 229 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Relevant server.ts line context:\n'
sed -n '370,390p' packages/dev-server/src/server.ts | awk '{printf "%04d\t%s\n", NR+369, $0}'
printf '\nExact current line:\n'
sed -n '383p' packages/dev-server/src/server.ts | awk '{printf "\t%s\n", $0}'
printf '\nNode syntax probe for the callback form:\n'
node --version || true
node --input-type=module - <<'JS'
for (const label of ['bad', 'good']) {
const src = label === 'bad'
? 'await exitedPromise.catch( => console.error());'
: 'await Promise.resolve().catch((err) => console.error("Child process exit failed:", err));';
try {
new Function(src);
console.log(label, 'passes JavaScript syntax check:', src);
} catch (error) {
console.log(label + '-syntax-error');
console.log(error.name + ': ' + error.message.split('\n')[0]);
console.log(src);
}
}
JSRepository: Karanjot786/TermUI Length of output: 1544 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Server.ts top-level await context:\n'
sed -n '350,390p' packages/dev-server/src/server.ts | awk '{printf "%04d\t%s\n", NR+349, $0}'
printf '\nNode syntax probe wrapped in an async function to isolate callback syntax:\n'
node --input-type=module - <<'JS'
function probe(label, body) {
return { label, body, passes: (() => {
try {
new Function(body);
return true;
} catch (error) {
return false;
}
})() };
}
for (const { label, body } of [
probe('empty-arg-callback', 'return async function() { const exitedPromise = Promise.resolve(0); await exitedPromise.catch( => console.error()); };'),
probe('typed-arg-callback', 'return async function() { const exitedPromise = Promise.resolve(0); await exitedPromise.catch((err) => console.error("Child process exit failed:", err)); };'),
]).results) {
console.log(label + ': ' + (passes ? 'passes' : 'fails JavaScript syntax')) + body;
}
JSRepository: Karanjot786/TermUI Length of output: 2556 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Node syntax probe for callback parameter syntax in async Promise.catch context:\n'
node --input-type=module - <<'JS'
async function run() {
const entries = [
{ label: bad-argless-callback, body:
'const exitedPromise = Promise.resolve(0);
await exitedPromise.catch( => console.error());'
},
{ label: typed-err-callback, body:
'const exitedPromise = Promise.resolve(0);
await exitedPromise.catch((err) => console.error("Child process exit failed:", err));'
},
];
for (const entry of entries) {
try {
new Function(entry.body);
console.log(entry.label + ": JavaScript syntax ok");
} catch (error) {
console.log(entry.label + ": JavaScript syntax fail");
console.log(error.name + ": " + error.message.split("\n")[0]);
console.log(entry.body);
}
}
}
run().catch(console.error);
JSRepository: Karanjot786/TermUI Length of output: 1057 🏁 Script executed: #!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
cat > "$tmpdir/probe.js" <<'JS'
async function run() {
const entries = [
{ label: "argless-arrow-catch", body: "const exitedPromise = Promise.resolve(0);\nawait exitedPromise.catch( => console.error());" },
{ label: "typed-err-arrow-catch", body: "const exitedPromise = Promise.resolve(0);\nawait exitedPromise.catch((err) => console.error(\"Child process exit failed:\", err));" },
];
for (const entry of entries) {
try {
new Function(entry.body);
console.log(entry.label + ": JavaScript syntax ok");
} catch (error) {
console.log(entry.label + ": JavaScript syntax fail");
console.log(error.name + ": " + error.message.split("\n")[0]);
console.log(entry.body);
}
}
}
run().catch(console.error);
JS
node "$tmpdir/probe.js"
printf '\nExact current line byte-level check for shorthand arrow token:\n'
sed -n '383p' packages/dev-server/src/server.ts | od -c | head -n 20Repository: Karanjot786/TermUI Length of output: 745 🏁 Script executed: #!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
cat > "$tmpdir/probe.js" <<'JS'
function run() {
const entries = [
{ label: "argless-arrow-catch", body: "const exitedPromise = Promise.resolve(0);\nawait exitedPromise.catch( => console.error());" },
{ label: "typed-err-arrow-catch", body: "const exitedPromise = Promise.resolve(0);\nawait exitedPromise.catch((err) => console.error(\"Child process exit failed:\", err));" },
];
for (const entry of entries) {
try {
new Function(entry.body);
console.log(entry.label + ": JavaScript syntax ok");
} catch (error) {
console.log(entry.label + ": JavaScript syntax fail");
console.log(error.name + ": " + error.message.split("\n")[0]);
console.log(entry.body);
}
}
}
run();
JS
node "$tmpdir/probe.js"
printf '\nLine 383 character stream:\n'
sed -n '383p' packages/dev-server/src/server.ts | tr '\n' '\0' | sed 's/./[&]/g' | tr '?' ' 'Repository: Karanjot786/TermUI Length of output: 848 Replace the invalid
Use a valid rejection handler: await exitedPromise.catch((err) => {
console.error('Child process exit failed:', err);
});🧰 Tools🪛 Biome (2.5.6)[error] 383-383: Expected a parenthesis '(' but instead found '=>'. (parse) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| if (this._running && this._entryFile) { | ||
| this._spawnChild(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,3 +138,5 @@ export class Form extends Widget { | |
| } | ||
| } | ||
| } | ||
|
|
||
| .catch(err => console.error("Promise.all failed:", err)); | ||
|
Comment on lines
+141
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
npx biome check packages/ui/src/Form.tsRepository: Karanjot786/TermUI Length of output: 631 Remove the detached
🧰 Tools🪛 Biome (2.5.6)[error] 142-142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. (parse) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Apply
Number.EPSILONbefore scaling the progress value.Number.EPSILONis added afterthis._value * 100, where the adjustment can be lost. For example,0.145 * 100can evaluate to14.499999999999998, and the current expression still rounds to14instead of15.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents