Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ai-streaming/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AIStreamingApp extends Widget {
this.addChild(this._toolCall);
this.addChild(this._streamingText);

setInterval(() => {
clearInterval(window.__interval); window.__interval = setInterval(() => {
this._streamingText.tick();
}, 50);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class DevServer {

this._killChild();

await exitedPromise.catch(() => {});
await exitedPromise.catch( => console.error());

Copy link
Copy Markdown

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:

#!/bin/bash
set -euo pipefail

if rg -n '\.catch\(\s*=>' packages/dev-server/src/server.ts; then
  echo "Malformed catch callback found"
  exit 1
fi

rg -n 'exitedPromise\.catch\(' packages/dev-server/src/server.ts

Repository: Karanjot786/TermUI

Length of output: 251


Fix the invalid catch callback before merge.

Line 383 uses catch( => ...), which is invalid TypeScript and prevents packages/dev-server/src/server.ts from parsing. Pass the rejection to console.error:

Proposed fix
-            await exitedPromise.catch( => console.error());
+            await exitedPromise.catch((error) => console.error(error));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await exitedPromise.catch( => console.error());
await exitedPromise.catch((error) => console.error(error));
🧰 Tools
🪛 Biome (2.5.6)

[error] 383-383: Expected a parenthesis '(' but instead found '=>'.

(parse)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dev-server/src/server.ts` at line 383, Fix the invalid rejection
handler in the exitedPromise await flow by declaring the caught error parameter
and passing it to console.error. Preserve the existing behavior of logging
promise rejections.

Source: Linters/SAST tools


if (this._running && this._entryFile) {
this._spawnChild();
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/Switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Switch extends Widget {
if (width <= 0) return;

const attrs = styleToCellAttrs(this.style);
const knobPos = Math.round(this._animProgress * 2);
const knobPos = Math.round(this._animProgress * 2 + Number.EPSILON);
const transitioning = this._animProgress > 0 && this._animProgress < 1;

let trackChars: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/TreeSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Copy Markdown

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:

#!/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.ts

Repository: 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
fi

Repository: 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"; }
done

Repository: Karanjot786/TermUI

Length of output: 2463


Use one type-safe comparator for both sorted value arrays.

_valuesEqual compares string[], and a - b is a TypeScript error under packages/ui/tsconfig.typecheck.json. It also produces non-numeric comparison values, while sortedB uses lexicographic sorting, so reordered numeric-like strings such as ['10', '2'] and ['2', '10'] may be reported as changed. Sort both arrays with the same comparator and add a test for re-ordered multi selections.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/TreeSelect.ts` at line 185, The _valuesEqual comparison in
TreeSelect.ts uses a numeric comparator on string arrays and sorts the two
arrays inconsistently. Replace the sortedA comparator with a type-safe string
comparator and apply that same comparator to sortedB, preserving equality for
reordered multi-selections; add coverage for reordered values such as “10” and
“2”.

Source: Coding guidelines

const sortedB = [...b].sort();
for (let i = 0; i < sortedA.length; i++) {
if (sortedA[i] !== sortedB[i]) return false;
Expand Down
Loading