-
Notifications
You must be signed in to change notification settings - Fork 233
fix: resolve 4 bugs in termui #3583
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); | ||||||||||||||||||||||||||
| 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: #!/bin/bash
set -euo pipefail
rg -n -C 5 '_valuesEqual|sort\(' packages/ui/src/TreeSelect.ts
while IFS= read -r tsconfig; do
npx tsc --noEmit --pretty false -p "$tsconfig"
done < <(fd -HI '^tsconfig(\..*)?\.json$' .)Repository: Karanjot786/TermUI Length of output: 947 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'List TS config files:\n'
fd -HI '^tsconfig(\..*)?\.json$' . || true
printf '\nTreeSelect excerpt:\n'
sed -n '160,195p' packages/ui/src/TreeSelect.ts
printf '\nCheck TypeScript availability:\n'
npm exec -- tsc -v || true
printf '\nPackages UI tsconfig references:\n'
find . -path '*packages/ui*' -name 'tsconfig*.json' -print -exec sed -n '1,220p' {} \;
printf '\nRun TypeScript check for packages/ui/src/TreeSelect.ts with available config:\n'
for tsconfig in $(fd -HI '^tsconfig(\..*)?\.json$' .); do
echo "--- $tsconfig ---"
npx tsc --noEmit --pretty false -p "$tsconfig" 2>&1 | awk '/packages\/ui\/src\/TreeSelect\.ts/ || /TS2362/ || /Found [0-9]+ error/'
doneRepository: Karanjot786/TermUI Length of output: 4472 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '--- packages/ui/tsconfig.json ---\n'
cat packages/ui/tsconfig.json
printf '\n--- packages/ui/tsconfig.typecheck.json ---\n'
cat packages/ui/tsconfig.typecheck.json
printf '\n--- packages/ui/src/tsconfig related files ---\n'
fd -HI '^tsconfig(\..*)?\.json$' packages/ui/src || true
printf '\n--- Check all TS config files for TS2362/Node errors involving TreeSelect.ts ---\n'
for tsconfig in $(fd -HI '^tsconfig(\..*)?\.json$' .); do
echo "### $tsconfig"
output="$(npx tsc --noEmit --pretty false -p "$tsconfig" 2>&1 || true)"
if printf '%s\n' "$output" | grep -E 'packages/ui/src/TreeSelect\.ts|TS2362|Found [0-9]+ error' >/dev/null 2>&1; then
printf '%s\n' "$output" | grep -E 'packages/ui/src/TreeSelect\.ts|TS2362|Found [0-9]+ error' -C 2 || true
else
echo "no TreeSelect TS2362 errors reported"
fi
doneRepository: Karanjot786/TermUI Length of output: 247 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- packages/ui/tsconfig.json ---'
cat packages/ui/tsconfig.json
printf '\n--- packages/ui/tsconfig.typecheck.json ---\n'
cat packages/ui/tsconfig.typecheck.json
printf '%s\n' '--- packages/ui/src/tsconfig related files ---'
fd -HI '^tsconfig(\..*)?\.json$' packages/ui/src || true
printf '\n--- Check all TS config files for TS2362/Node errors involving TreeSelect.ts ---\n'
for tsconfig in $(fd -HI '^tsconfig(\..*)?\.json$' .); do
printf '%s\n' "### $tsconfig"
output="$(npx tsc --noEmit --pretty false -p "$tsconfig" 2>&1 || true)"
if printf '%s\n' "$output" | grep -E 'packages/ui/src/TreeSelect\.ts|TS2362|Found [0-9]+ error' >/dev/null 2>&1; then
printf '%s\n' "$output" | grep -E 'packages/ui/src/TreeSelect\.ts|TS2362|Found [0-9]+ error' -C 2 || true
else
printf '%s\n' "no TreeSelect TS2362 errors reported"
fi
doneRepository: Karanjot786/TermUI Length of output: 10719 Use one typed comparator for both sorted arrays.
Proposed fix- const sortedA = [...a].sort((a, b) => a - b);
- const sortedB = [...b].sort();
+ const compareValues = (left: string, right: string): number => {
+ const leftNumber = Number(left);
+ const rightNumber = Number(right);
+ if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {
+ return leftNumber - rightNumber;
+ }
+ return left.localeCompare(right);
+ };
+ const sortedA = [...a].sort(compareValues);
+ const sortedB = [...b].sort(compareValues);📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: CI / 0_build-and-test.txt[error] 185-185: TypeScript errors TS2362 and TS2363: the 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 error TS2362: The left-hand side of an arithmetic operation must be a number-compatible type. [error] 185-185: TypeScript error TS2363: The right-hand side of an arithmetic operation must be a number-compatible type. 🤖 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 | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 245
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 2792
Use prefix negation for
event.ctrl.event.ctrl !is a postfix non-null assertion, so it still only checks whether Control is pressed. Use!event.ctrlto open the confirmation modal on plaincwhile keepingCtrl+Chandled by the quit branch.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines