-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3659
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 | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
config="$(fd -H -t f '^tsconfig.*\.json$' packages | head -n 1)"
test -n "$config"
npx tsc --noEmit --project "$config"
rg -n -C 4 '_valuesEqual|sort\(' packages/ui/src/TreeSelect.ts
rg -n -C 3 "value: 's'|value: 'a'|selectedValues" packages/ui/src/TreeSelect.test.tsRepository: Karanjot786/TermUI Length of output: 8776 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Files:"
fd -t f 'TreeSelect\.(ts|test\.ts)$|^tsconfig.*\.json$' .
echo
echo "TreeSelect section:"
sed -n '170,195p' packages/ui/src/TreeSelect.ts
echo
echo "TreeSelect test relevant section:"
rg -n -C 4 "_valuesEqual|valuesEqual|value: '(s|a)'|selectedValues|valuesEqual|compare" packages/ui/src packages -g '*.ts' || true
echo
echo "TS configs with relevant compiler options:"
for f in $(fd -t f '^tsconfig.*\.json$' packages'); do
echo "--- $f ---"
sed -n '1,220p' "$f"
done
echo
echo "TypeScript availability and TS error for string subtraction:"
if command -v npx >/dev/null 2>&1 && command -v tsc >/dev/null 2>&1; then
(cd packages/ui && npx tsc --noEmit -p tsconfig.json 2>&1 | rg 'TreeSelect|_valuesEqual|Operator "-" cannot be applied|TS2362|TS2363|TS2769' || true)
node -e "console.log('10' - '2', 's' - 'a')" 2>&1 || true
else
echo "tsc not globally available"
node -e "console.log('10' - '2', 's' - 'a')" 2>&1 || true
fiRepository: Karanjot786/TermUI Length of output: 50374 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "UI tsconfig files:"
for f in packages/ui/tsconfig.json packages/ui/tsconfig.typecheck.json; do
if [ -f "$f" ]; then
echo "--- $f ---"
sed -n '1,220p' "$f"
fi
done
echo
echo "Base tsconfig files:"
for f in packages/tsconfig.base.json tsconfig.base.json; do
if [ -f "$f" ]; then
echo "--- $f ---"
sed -n '1,220p' "$f"
fi
done
echo
echo "Relevant tsconfig snippets with compiler options:"
python3 - <<'PY'
import json, pathlib
for path in [pathlib.Path('packages/ui/tsconfig.json'), pathlib.Path('packages/ui/tsconfig.typecheck.json'), pathlib.Path('tsconfig.base.json')]:
if path.exists():
data = json.loads(path.read_text())
print(f'--- {path} ---')
print(json.dumps({k:v for k,v in data.items() if k in {'compilerOptions', 'extends'}} or data.get('compilerOptions'), indent=2))
PY
echo
echo "Read-only static check of _valuesEqual comparator semantics and TS string subtraction shape:"
python3 - <<'PY'
from pathlib import Path
import re
p = Path('packages/ui/src/TreeSelect.ts')
s = p.read_text()
m = re.search(r'function _valuesEqual\(a: string\[\], b: string\[\]\): boolean \{(?P<body>.*?)\n\}', s, re.S)
print('has _valuesEqual:', bool(m))
if m:
body = m.group('body')
print('lines:')
print('\n'.join(f'{i:4d}: {line}' for i,line in enumerate(s.splitlines()[183:189], 183)))
print('sortedA uses subtraction:', bool(re.search(r'\.sort\(\(a, b\)\s*=>\s*a\s*-\s*b\)', body)))
print('sortedB uses comparison:', bool(re.search(r'\.sort\(\)\s*;', body)))
print('imports NodeFS (for later TS type verification context):')
print('node:fs' in s[:500])
PY
node - <<'JS'
function valuesEqualRuntime(a, b) {
if (a.length !== b.length) return false;
const sortedA = [...a].sort((a, b) => a - b);
const sortedB = [...b].sort();
return sortedA.every((v, i) => v === sortedB[i]);
}
console.log(JSON.stringify({
['10','2'] vs ['2','10']: valuesEqualRuntime(['10','2'], ['2','10']),
['a','s'] vs ['s','a']: valuesEqualRuntime(['a','s'], ['s','a']),
sortedNumericStrings: JSON.stringify([...['10','2']].sort((a,b) => a - b)),
sortedLexicographic: JSON.stringify([...['10','2']].sort())
}));
JS
echo
echo "Check whether package script config allows typecheck without full install:"
for f in package.json packages/ui/package.json; do
[ -f "$f" ] && { echo "--- $f ---"; sed -n '1,220p' "$f"; }
doneRepository: Karanjot786/TermUI Length of output: 2463 Use one type-safe comparator for both sorted value arrays.
🤖 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 | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 251
Fix the invalid
catchcallback before merge.Line 383 uses
catch( => ...), which is invalid TypeScript and preventspackages/dev-server/src/server.tsfrom parsing. Pass the rejection toconsole.error:Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Biome (2.5.6)
[error] 383-383: Expected a parenthesis '(' but instead found '=>'.
(parse)
🤖 Prompt for AI Agents
Source: Linters/SAST tools