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/widget-gallery/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class WidgetGalleryApp extends Widget {
}

// Tab switching: 1-6
const num = parseInt(event.key);
const num = parseInt(event.key, 10);
if (num >= 1 && num <= 6) {
this._switchTab(num - 1);
return true;
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ export class Form extends Widget {
}
}
}

.catch(err => console.error("Promise.all failed:", err));
Comment on lines +141 to +142

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

Attach the rejection handler to Promise.all correctly.

Line 142 starts a standalone .catch expression. Biome reports this as a parse error, so packages/ui/src/Form.ts cannot compile.

Use try/catch around the await Promise.all(validationPromises) at Line 83. In the rejection path, reset _isValidating and call markDirty() before returning or rethrowing. Do not continue with results after Promise.all rejects.

🧰 Tools
🪛 Biome (2.5.6)

[error] 142-142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

(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/ui/src/Form.ts` around lines 141 - 142, Fix the validation flow
around await Promise.all(validationPromises) by removing the standalone .catch
expression and wrapping the await in try/catch. In the rejection handler, reset
_isValidating and call markDirty(), then return or rethrow without processing
results; preserve normal result handling only after Promise.all resolves.

Source: Linters/SAST tools

2 changes: 1 addition & 1 deletion packages/ui/src/MultiSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MultiSelect extends Widget {
}

get selectedOptions(): MultiSelectOption[] {
return [...this._checked].sort().map(i => this._options[i]);
return [...this._checked].sort((a, b) => a - b).map(i => this._options[i]);
}
selectNext(): void { if (this._options.length === 0) return; let n = this._cursorIndex + 1; while (n < this._options.length && this._options[n].disabled) n++; if (n < this._options.length) { this._cursorIndex = n; this.markDirty(); } }
selectPrev(): void { if (this._options.length === 0) return; let n = this._cursorIndex - 1; while (n >= 0 && this._options[n].disabled) n--; if (n >= 0) { this._cursorIndex = n; this.markDirty(); } }
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);
const sortedB = [...b].sort();
Comment on lines +185 to 186

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:

#!/usr/bin/env bash
set -euo pipefail

npx --no-install tsc --noEmit --pretty false

Repository: Karanjot786/TermUI

Length of output: 5708


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)TreeSelect\.(ts|test\.ts)$|(^|/)tsconfig.*\.json$|package\.json$' || true

echo "== TreeSelect outline =="
ast-grep outline packages/ui/src/TreeSelect.ts || true

echo "== relevant TreeSelect code =="
cat -n packages/ui/src/TreeSelect.ts | sed -n '140,210p'

echo "== test relevant code =="
cat -n packages/ui/src/TreeSelect.test.ts | sed -n '1,120p'

echo "== package tsconfig =="
for f in tsconfig.json packages/tsconfig.json; do
  [ -f "$f" ] && { echo "-- $f"; cat -n "$f"; }
done

echo "== build typecheck with project config =="
npx --no-install tsc --showConfig --build --dry 2>&1 | head -50 || true
npx --no-install tsc -b --noEmit 2>&1 | head -200 || true

Repository: Karanjot786/TermUI

Length of output: 11804


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== root/package configs =="
for f in package.json packages/ui/package.json packages/ui/tsconfig.json packages/ui/tsconfig.typecheck.json tsconfig.base.json; do
  [ -f "$f" ] && { echo "-- $f"; cat -n "$f"; }
done

echo "== TypeScript invocation with project =="
npx --no-install tsc -p packages/ui/tsconfig.typecheck.json --noEmit 2>&1

echo "== local JS sort/comparator behavior =="
node2 - <<'JS'
for (const pairs of [
  [['2', '10'], ['10', '2']],
  [['s', 'a'], ['a', 's']],
  [['one', 'two'], ['two', 'one']],
]) {
  const a = [...pairs[0]].sort((a, b) => a - b);
  const b = [...pairs[0]].sort();
  console.log(pairs[0].join(','), 'cmpA=', a.join(','), 'sort=', b.join(','));
}
JS

Repository: Karanjot786/TermUI

Length of output: 5927


Fix the value-equality comparator.

a and b are string values in _valuesEqual, so subtracting them fails the packages/ui TypeScript strict check. If the values are meant to be strings, use the same lexicographic sort for both arrays; if numeric values are required, make the value type/comparator consistent and add tests for numeric and nonnumeric inputs.

🤖 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` around lines 185 - 186, Update the
_valuesEqual comparator so its two value arrays use a type-consistent
comparison: since a and b are string values, sort both with the same
lexicographic comparator and remove numeric subtraction. Preserve
order-independent equality and ensure the implementation passes the packages/ui
strict TypeScript check.

Source: Coding guidelines

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