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

Fix the invalid .catch callback before merge.

Line [383] does not parse because the callback parameter is missing. This blocks the TypeScript build. Pass the rejection value to console.error; otherwise the error remains discarded.

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 catch
callback in the exitedPromise handling by accepting its rejection value and
passing that value to console.error, preserving the existing await and
error-reporting behavior.

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);
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 | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)TreeSelect(\.ts|\.test\.ts|\.tsx)$|packages/ui/src/TreeSelect'

echo "== outline =="
if [ -f packages/ui/src/TreeSelect.ts ]; then
  ast-grep outline packages/ui/src/TreeSelect.ts || true
fi

echo "== relevant lines =="
if [ -f packages/ui/src/TreeSelect.ts ]; then
  sed -n '150,210p' packages/ui/src/TreeSelect.ts | cat -n
fi

echo "== tests with values =="
if [ -f packages/ui/src/TreeSelect.test.ts ]; then
  rg -n -C 3 "TreeSelect|_valuesEqual|values=|setKey|handleKey|sort|s|a|10|2" packages/ui/src/TreeSelect.test.ts || true
fi

echo "== package script availability =="
ls -la packages/ui/package.json 2>/dev/null || true

Repository: Karanjot786/TermUI

Length of output: 6604


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== all _valuesEqual usages =="
rg -n "_valuesEqual|selectedValues|selectedValues.set|selectedValues.has|selectedValues.add" packages/ui/src packages --glob '*.ts' --glob '*.tsx' || true

echo "== source around calls =="
sed -n '1,120p' packages/ui/src/TreeSelect.ts | cat -n

Repository: Karanjot786/TermUI

Length of output: 12579


🏁 Script executed:

#!/bin/bash
set -euo pipefail

node - <<'JS'
function valuesEqualNumeric(a, b) {
  const sortedA = [...a].sort((a, b) => a - b);
  const sortedB = [...b].sort();
  if (sortedA.length !== sortedB.length) return false;
  for (let i = 0; i < sortedA.length; i++) if (sortedA[i] !== sortedB[i]) return false;
  return true;
}
function valuesEqualSameComparator(a, b) {
  const compare = (left, right) => {
    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(compare);
  const sortedB = [...b].sort(compare);
  if (sortedA.length !== sortedB.length) return false;
  for (let i = 0; i < sortedA.length; i++) if (sortedA[i] !== sortedB[i]) return false;
  return true;
}
for (const pairs of [
  [['10','2'], ['2','10']],
  [['a','b'], ['b','a']],
  [['a','10'], ['10','a']]
]) {
  console.log(JSON.stringify({ pairs, current: valuesEqualNumeric(...pairs), sameComparator: valuesEqualSameComparator(...pairs) }));
}
JS

Repository: Karanjot786/TermUI

Length of output: 369


Use one comparator for _valuesEqual.

TreeSelect.test.ts uses non-numeric values ('s', 'a'), but _valuesEqual sorts next with the default locale comparator while still passing a callback to previous. If the values are numeric strings in a different order, such as ['10', '2'] versus ['2', '10'], the arrays compare unequal and causes extra change events. Use the same comparator for both arrays, including a deterministic non-numeric fallback.

🤖 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 _valuesEqual so
sortedA and sortedB both use the same comparator. Preserve numeric ordering for
numeric values and provide a deterministic fallback for non-numeric values,
ensuring equivalent numeric-string arrays in different orders compare equal
without changing the existing equality behavior.

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