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.

At Line 142, .catch(...) starts a standalone statement. This causes the parse error reported by Biome and prevents the package from building.

Wrap the Promise.all call at Line 83 in try/catch. When validation rejects, log the error, set _isValidating to false, call markDirty(), and return or rethrow. Do not continue to iterate over results after the aggregation fails.

🧰 Tools
🪛 Biome (2.5.6)

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

(parse)

🪛 GitHub Actions: CI / 0_build-and-test.txt

[error] 142-142: Build failed during tsup/esbuild and TypeScript declaration generation. Unexpected '.' at the start of '.catch(err => console.error("Promise.all failed:", err));', causing syntax errors including missing try, closing parenthesis, and semicolon. Command failed with exit code 1.

🪛 GitHub Actions: CI / build-and-test

[error] 142-142: Build failed during the tsup/esbuild build. Unexpected '.' at the standalone '.catch(err => console.error("Promise.all failed:", err));'. TypeScript also reports declaration/statement, ')' and ';' syntax errors, and cannot find name 'err'.

🤖 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 Promise.all so its rejection is handled with a surrounding try/catch
rather than a standalone .catch statement. On rejection, log the error, set
_isValidating to false, call markDirty(), and return or rethrow; ensure
execution does not continue iterating over results after aggregation fails.

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);

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

Use one numeric comparator for both string arrays.

a and b are strings, so a - b causes a TypeScript compile error. sortedB also remains lexicographic, which makes equal numeric values compare unequal in different insertion orders.

If tree values are decimal strings, parse both operands with radix 10 and reuse the comparator:

Proposed fix
 function _valuesEqual(a: string[], b: string[]): boolean {
     if (a.length !== b.length) return false;
-    const sortedA = [...a].sort((a, b) => a - b);
-    const sortedB = [...b].sort();
+    const compareNumeric = (left: string, right: string) =>
+        parseInt(left, 10) - parseInt(right, 10);
+    const sortedA = [...a].sort(compareNumeric);
+    const sortedB = [...b].sort(compareNumeric);

As per coding guidelines, TypeScript files must use strict mode.

#!/bin/bash
set -euo pipefail

config="$(fd -a -t f 'tsconfig.*\.json$' | head -n 1)"
test -n "$config"
npx tsc --noEmit --pretty false -p "$config"
🤖 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, Update the sorting logic in
TreeSelect to use a shared numeric comparator for both string arrays, parsing
each operand as a base-10 integer before comparison. Apply the same comparator
to sortedA and sortedB so decimal-string values compare consistently regardless
of insertion order, while keeping TypeScript strict-mode compilation valid.

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