-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3643
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -182,7 +182,7 @@ function _pathsEqual(a: number[], b: number[]): boolean { | |||||||||
|
|
||||||||||
| function _valuesEqual(a: string[], b: string[]): boolean { | ||||||||||
| if (a.length !== b.length) return false; | ||||||||||
| const sortedA = [...a].sort(); | ||||||||||
| const sortedA = [...a].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 | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
if rg -nF 'sort((a, b) => a - b)' packages/ui/src/TreeSelect.ts; then
echo "TreeSelect still subtracts string operands directly."
exit 1
fi
sed -n '183,190p' packages/ui/src/TreeSelect.tsRepository: Karanjot786/TermUI Length of output: 263 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== TreeSelect relevant lines =="
nl -ba packages/ui/src/TreeSelect.ts | sed -n '140,205p'
echo
echo "== TypeScript configuration / strict mode =="
nl -ba tsconfig.json 2>/dev/null | sed -n '1,220p' || true
rg -n '"strict"|"strict:' tsconfig*.json package.json 2>/dev/null || true
echo
echo "== TypeScript compiler availability and type probe =="
node - <<'JS'
const { execSync } = require('node:child_process');
try {
console.log("tsc_version", execSync('tsc --version', { encoding: 'utf8' }).trim());
} catch (e) {
console.log("tsc unavailable");
}
JSRepository: Karanjot786/TermUI Length of output: 228 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== TreeSelect relevant lines =="
awk '{printf "%6d\t%s\n", NR, $0}' packages/ui/src/TreeSelect.ts | sed -n '140,205p'
echo
echo "== TypeScript configuration / strict mode =="
for f in tsconfig.json packages/tsconfig.json; do
if [ -f "$f" ]; then
echo "--- $f ---"
awk '{printf "%6d\t%s\n", NR, $0}' "$f" | sed -n '1,220p'
fi
done
grep -RIn '"strict"|"strict:' tsconfig*.json package.json .github 2>/dev/null || true
echo
echo "== TypeScript compiler availability and type probe =="
if command -v tsc >/dev/null 2>&1; then
tsc --version
mkdir -p /tmp/ts-probe
cat >/tmp/ts-probe/check.ts <<'TS'
const valuesEqual = (a: string[], b: string[]) => {
const sortedA = [...a].sort((a, b) => a - b);
const sortedB = [...b].sort();
return JSON.stringify(sortedA) === JSON.stringify(sortedB);
};
TS
tsc --noEmit --strict /tmp/ts-probe/check.ts 2>&1 || true
else
echo "tsc unavailable"
fi
echo
echo "== Runtime probe for numeric vs lexicographic sort equality =="
node - <<'JS'
const inputs = [['2', '10'], ['10', '2']];
function current(a, b) {
const sortedA = [...a].sort((a, b) => a - b);
const sortedB = [...b].sort();
return JSON.stringify(sortedA) === JSON.stringify(sortedB);
}
function numericBoth(a, b) {
const compare = (left, right) => Number(left) - Number(right);
const sortedA = [...a].sort(compare);
const sortedB = [...b].sort(compare);
return JSON.stringify(sortedA) === JSON.stringify(sortedB);
}
console.log('current_equal', current(...inputs));
console.log('numeric_both_equal', numericBoth(...inputs));
JSON.stringify([...['2', '10']].sort((a, b) => a - b))
JSRepository: Karanjot786/TermUI Length of output: 2936 Use one typed numeric comparator for both arrays.
Proposed fix- const sortedA = [...a].sort((a, b) => a - b);
- const sortedB = [...b].sort();
+ const numericCompare = (left: string, right: string) => Number(left) - Number(right);
+ const sortedA = [...a].sort(numericCompare);
+ const sortedB = [...b].sort(numericCompare);📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: CI / 0_build-and-test.txt[error] 185-185: TypeScript error TS2362: The left-hand side of an arithmetic operation must be of type any, number, bigint, or an enum type during the tsup declaration build. [error] 185-185: TypeScript error TS2363: The right-hand side of an arithmetic operation must be of type any, number, bigint, or an enum type. The 'tsup' build failed with exit code 1. 🪛 GitHub Actions: CI / build-and-test[error] 185-185: TypeScript errors TS2362 and TS2363: arithmetic operation operands must be any, number, bigint, or an enum type. DTS build failed during 'tsup' and the build script exited with code 1. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||
| const sortedB = [...b].sort(); | ||||||||||
| for (let i = 0; i < sortedA.length; i++) { | ||||||||||
| if (sortedA[i] !== sortedB[i]) return false; | ||||||||||
|
|
||||||||||
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
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 156
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 1568
Add
Number.EPSILONbefore scaling.Add
Number.EPSILONbefore multiplying by100so values like0.145round to15%instead of14%. Add a regression test for this boundary case.🤖 Prompt for AI Agents