-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3519
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 |
|---|---|---|
|
|
@@ -113,7 +113,7 @@ async function promptSelect<T = string>(options: SelectPromptOptions<T>): Promis | |
| return; | ||
| } | ||
| const n = parseInt(trimmed, 10); | ||
| if (!isNaN(n) && n >= 1 && n <= choices.length) { | ||
| if (!Number.isNaN(n) && n >= 1 && n <= choices.length) { | ||
|
Comment on lines
115
to
+116
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 | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)prompts\.(ts|test\.ts)$|(^|/)prompts\.ts$' || true
echo "== prompts outline =="
if [ -f packages/ui/src/prompts.ts ]; then
ast-grep outline packages/ui/src/prompts.ts || true
echo "== relevant lines =="
nl -ba packages/ui/src/prompts.ts | sed -n '90,135p'
fi
echo "== tests around prompts =="
if [ -f packages/ui/src/prompts.test.ts ]; then
nl -ba packages/ui/src/prompts.test.ts | sed -n '1,220p'
fi
echo "== behavioral probe for JS parseInt Number Number.isInteger =="
node - <<'JS'
const vals = ["1", " 1 ", "1abc", "1.5", "-01", "abc", "1e2", "01abc", "1.abc", ""];
for (const trimmed of vals.map(s => s.trim())) {
const parseIntVal = parseInt(trimmed, 10);
const numberVal = Number(trimmed);
console.log(JSON.stringify({
input: trimmed,
parseInt: parseIntVal,
Number: numberVal,
Number_isInteger: Number.isInteger(numberVal)
}));
}
JSRepository: Karanjot786/TermUI Length of output: 1799 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== relevant lines: packages/ui/src/prompts.ts =="
awk 'NR>=91 && NR<=130 {printf "%5d\t%s\n", NR, $0}' packages/ui/src/prompts.ts
echo "== prompts tests first 240 lines =="
if [ -f packages/ui/src/prompts.test.ts ]; then
awk '{printf "%5d\t%s\n", NR, $0}' packages/ui/src/prompts.test.ts | sed -n '1,240p'
fi
echo "== behavioral probe for JS parseInt Number Number.isInteger =="
node - <<'JS'
const vals = ["1", " 1 ", "1abc", "1.5", "-01", "abc", "1e2", "01abc", "1.abc", ""];
for (const trimmed of vals.map(s => s.trim())) {
const parseIntVal = parseInt(trimmed, 10);
const numberVal = Number(trimmed);
console.log(JSON.stringify({input: trimmed, parseInt: parseIntVal, Number: numberVal, Number_isInteger: Number.isInteger(numberVal)}));
}
JSRepository: Karanjot786/TermUI Length of output: 5429 Make the choice parser validate the full input.
🤖 Prompt for AI Agents |
||
| rl.close(); | ||
| resolve(choices[n - 1].value); | ||
| return; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ export function collectDeps(content: string): string[] { | |||||
| const deps = new Set<string>(); | ||||||
| let m: RegExpExecArray | null; | ||||||
| while ((m = re.exec(content)) !== null) deps.add(m[1]!); | ||||||
| return [...deps].sort(); | ||||||
| return [...deps].sort((a, b) => a - b); | ||||||
|
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
rg -n -C 3 'const deps = new Set<string>|sort\(\(a, b\) => a - b\)' scripts/build-registry.ts
rg -n -C 8 'collects unique sorted' scripts/build-registry.test.tsRepository: Karanjot786/TermUI Length of output: 1266 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'TypeScript compiler availability:\n'
(tsc --version 2>&1) || true
printf '\nbuild-registry relevant lines:\n'
sed -n '30,55p' scripts/build-registry.ts | cat -n
printf '\nDependency parsing context:\n'
rg -n -C 2 'collectDeps|toSlug|buildRegistry|registry' scripts/build-registry.ts
printf '\nTypeScript type-check probe for subtraction of strings:\n'
tmp="$(mktemp -d)"
cat > "$tmp/minus.ts" <<'TS'
const deps = new Set<string>();
const sorted = [...deps].sort((a: string, b: string) => a - b);
export { sorted };
TS
if command -v tsc >/dev/null 2>&1; then
tsc --strict --noEmit "$tmp/minus.ts" 2>&1
else
node - <<'JS'
const deps = new Set(['b', 'a']);
const sorted = [...deps].sort((a, b) => a - b);
console.log('runtime sorted:', JSON.stringify(sorted));
JS
fiRepository: Karanjot786/TermUI Length of output: 4344 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Runtime sub-sort probe:\n'
node - <<'JS'
const samples = [
['b', 'a'],
['`@termuijs/widgets`', '`@termuijs/core`'],
['z', 'aa'],
];
for (const deps of samples) {
const sortedSub = [...deps].sort((a, b) => a - b);
const sortedCompare = [...deps].sort((a, b) => a.localeCompare(b));
console.log(JSON.stringify({ input: deps, subSorted: sortedSub, localeCompare: sortedCompare }));
}
JS
printf '\nPackage TypeScript declaration check:\n'
sed -n '1,120p' package.json | json_pp 2>/dev/null || sed -n '1,120p' package.jsonRepository: Karanjot786/TermUI Length of output: 1794 Use a string comparator for dependency sorting.
- return [...deps].sort((a, b) => a - b);
+ return [...deps].sort((a, b) => a.localeCompare(b));📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||
| } | ||||||
|
|
||||||
| export function toSlug(name: string): string { | ||||||
|
|
||||||
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 the epsilon before scaling.
Number.EPSILONis too small aftervalue * 100for some boundary values. For example,0.145 * 100becomes14.499999999999998; addingNumber.EPSILONstill rounds to14instead of15.Move the epsilon before multiplication, or scale it to the percentage value. Add a boundary test for
value = 0.145.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents