-
Notifications
You must be signed in to change notification settings - Fork 232
fix: resolve 4 bugs in termui #3445
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
base: main
Are you sure you want to change the base?
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); | ||
| const sortedB = [...b].sort(); | ||
|
Comment on lines
+185
to
186
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: #!/usr/bin/env bash
set -euo pipefail
npx --no-install tsc --noEmitRepository: Karanjot786/TermUI Length of output: 5708 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
echo "Files:"
git ls-files packages/ui/src | rg 'TreeSelect|package\.json|tsconfig' || true
echo
echo "TreeSelect outline:"
if [ -f packages/ui/src/TreeSelect.ts ]; then
ast-grep outline packages/ui/src/TreeSelect.ts --view compact || true
wc -l packages/ui/src/TreeSelect.ts
sed -n '1,240p' packages/ui/src/TreeSelect.ts
fi
echo
echo "Relevant compiler/config references:"
fd -a 'tsconfig.*|package.json' . | sed 's#^\./##' | rg '(^|/)(tsconfig.*|package\.json)$' | head -c 8000
for f in $(git ls-files | rg '(^|/)tsconfig.*\.json$|(^|/)package\.json$'); do
if rg -n '"strict"|"tsconfigPaths"|"compilerOptions"|"compilerOptions":{"strict"' "$f" >/dev/null; then
echo "--- $f ---"
sed -n '1,160p' "$f"
fi
doneRepository: Karanjot786/TermUI Length of output: 35956 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
echo "Files:"
git ls-files packages/ui/src | rg 'TreeSelect|package\.json|tsconfig' || true
echo
echo "TreeSelect outline:"
if [ -f packages/ui/src/TreeSelect.ts ]; then
ast-grep outline packages/ui/src/TreeSelect.ts --view compact || true
wc -l packages/ui/src/TreeSelect.ts
sed -n '1,260p' packages/ui/src/TreeSelect.ts
fi
echo
echo "Relevant compiler/config references:"
for f in $(git ls-files | rg '(^|/)tsconfig[^/]*\.json$|(^|/)package\.json$'); do
if rg -n '"strict"|"compilerOptions"|"extends"|"include"|"files"' "$f" >/dev/null; then
echo "--- $f ---"
sed -n '1,220p' "$f"
fi
done
echo
echo "Package scripts:"
for f in package.json packages/*/package.json; do
[ -f "$f" ] || continue
if rg -n '"scripts"|"typecheck"|"tsc"' "$f" >/dev/null; then
echo "--- $f ---"
jq -r '.scripts // empty | to_entries[]? | "\(.key)=\(.value)"' "$f"
fi
done
echo
echo "TypeScript availability/version:"
command -v tsc || true
if command -v npx >/dev/null; then
npx --yes --package=typescript@latest tsc --version
fiRepository: Karanjot786/TermUI Length of output: 44939 🌐 Web query:
💡 Result: In TypeScript, using arithmetic operators (such as Citations:
🌐 Web query:
💡 Result: There is no String.prototype.sort method in JavaScript [1][2]. The sort method is a property of Array.prototype (and TypedArray.prototype) [3][4][5]. Regarding the behavior of Array.prototype.sort: 1. Default Sorting: If no comparator function is provided, the sort method converts all array elements into strings and compares their sequences of UTF-16 code unit values [3][4][5]. This often leads to unexpected results when sorting numbers, as "10" will be sorted before "2" [3][6][7]. 2. Handling of undefined values: When sorting an array that contains undefined values, the ECMAScript specification dictates that all undefined elements are moved to the end of the array [8]. The compare function, if provided, is never called with undefined values [8]. 3. localeCompare: The String.prototype.localeCompare method is commonly used within a custom comparator function to handle language-sensitive string sorting [4]. For example: array.sort((a, b) => a.localeCompare(b)); This approach ensures that strings are sorted according to specific locale rules rather than raw UTF-16 code unit values [4]. Citations:
Use one typed comparator for both arrays.
Define one comparator with a typed parameter, and pass it to both Proposed fix- const sortedA = [...a].sort((a, b) => a - b);
- const sortedB = [...b].sort();
+ const compareValues = (left: string, right: string): number =>
+ Number(left) - Number(right);
+ const sortedA = [...a].sort(compareValues);
+ const sortedB = [...b].sort(compareValues);🧰 Tools🪛 GitHub Actions: CI / 0_build-and-test.txt[error] 185-185: TypeScript DTS build failed: TS2362 and TS2363 indicate that the left- and right-hand operands of an arithmetic operation are not typed as any, number, bigint, or an enum. The ' 🪛 GitHub Actions: CI / build-and-test[error] 185-185: TypeScript errors TS2362 and TS2363: arithmetic operands at columns 43 and 47 are not typed as any, number, bigint, or an enum. The tsup DTS build failed, causing 'bun run build' to exit with code 1. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| 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: 247
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 48938
Scale the epsilon before percentage conversion in both renderers.
Adding
Number.EPSILONafter multiplying by100does not reliably fix half-percent boundaries. For example,0.145 * 100 + Number.EPSILONstill rounds to14. Move the epsilon before* 100, or scale it by100, and add a0.145regression test in both locations.📍 Affects 2 files
examples/pomodoro-timer/src/index.tsx#L185-L185(this comment)examples/todo-app/src/index.ts#L107-L107🤖 Prompt for AI Agents