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 examples/chat-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function parseBlocks(text: string): Block[] {
}

// ── Handle Paragraphs ────────────────────────
if (line.trim() === '') {
if (line.trim().length === 0) {
blocks.push({
type: 'paragraph',
text: '',
Expand Down
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/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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate TreeSelect.ts =="
fd -a 'TreeSelect\.ts$' . || true

echo "== inspect file outline =="
TREE="$(fd 'TreeSelect\.ts$' . | head -n1 || true)"
if [ -n "${TREE:-}" ]; then
  echo "TREE=$TREE"
  wc -l "$TREE"
  ast-grep outline "$TREE" --match '_valuesEqual' --view expanded || true
  echo "== relevant lines =="
  sed -n '160,200p' "$TREE" | nl -ba -v160
fi

echo "== package type script / tsconfig =="
if [ -f tsconfig.json ]; then echo "root tsconfig"; cat tsconfig.json; fi
fd -a 'tsconfig.*json$' . | while read -r f; do
  echo "-- $f --"
  sed -n '1,160p' "$f"
done

echo "== package deps mentioning typescript =="
rg -n '"typescript"|"type": "module"|strict|noImplicitAny|compilerOptions' package.json pnpm-lock.yaml package-lock.json yarn.lock . --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' | head -n 200 || true

Repository: Karanjot786/TermUI

Length of output: 490


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== behavioral probe: comparator effects for ["2","10"] =="
node - <<'JS'
const cases = {
  naiveA: ["2","10"].sort((a,b) => a - b),
  naiveB: ["2","10"].sort(),
  numeric: ["2","10"].sort((a,b) => Number(a)-Number(b)),
};
for (const [k,v] of Object.entries(cases)) console.log(`${k}: ${JSON.stringify(v)}`);

function sortedEqual(a, b) {
  const sortedA = [...a].sort((a, b) => a - b);
  const sortedB = [...b].sort();
  return sortedA.toString() === sortedB.toString();
}
console.log('sortedEqual(["2","10"],["2","10"]):', sortedEqual(["2","10"],["2","10"]));
JS

Repository: Karanjot786/TermUI

Length of output: 310


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read-only type compatibility probe for Node 18-only without installing deps.
node - <<'JS'
// This JavaScript probe cannot exercise TypeScript strict mode.
// We document the expression only because it was requested in the original comment.
console.log('Node cannot demonstrate TypeScript strict-mode typing for string subtraction without the tsc toolchain');
JS

Repository: Karanjot786/TermUI

Length of output: 259


🏁 Script executed:

#!/bin/bash
set -euo pipefail

TREE=$(fd 'TreeSelect\.ts$' . | head -n1 || true)
echo "TREE=$TREE"
echo "== relevant lines =="
awk 'NR>=160 && NR<=191 { printf "%4d\t%s\n", NR, $0 }' "$TREE"

echo "== tsconfig files =="
fd 'tsconfig.*json$' . | sort | while IFS= read -r f; do
  echo "-- $f --"
  sed -n '1,180p' "$f"
done

echo "== typecheck availability =="
command -v tsc || true
command -v npx || true
if [ -x "$(command -v npx || true 2>/dev/null)" ]; then
  npx --no-install tsc --version || true
fi

Repository: Karanjot786/TermUI

Length of output: 17646


Use one typed comparator for both arrays.

a - b rejects string operands in TypeScript strict mode, and mixing numeric and lexicographic sorting makes _valuesEqual return false for equivalent input values like ["2", "10"]. Apply the same typed comparator to both sortedA and sortedB.

Proposed fix
-    const sortedA = [...a].sort((a, b) => a - b);
-    const sortedB = [...b].sort();
+    const compareValues = (left: string, right: string) =>
+        Number(left) - Number(right);
+    const sortedA = [...a].sort(compareValues);
+    const sortedB = [...b].sort(compareValues);
🧰 Tools
🪛 GitHub Actions: CI / 0_build-and-test.txt

[error] 185-185: TypeScript DTS build failed: the left-hand side of an arithmetic operation must be any, number, bigint, or an enum type (TS2362), and the right-hand side must meet the same requirement (TS2363). Failed command: bun run build (tsup).

🪛 GitHub Actions: CI / build-and-test

[error] 185-185: TypeScript DTS build failed: TS2362 and TS2363 indicate that the operands of an arithmetic operation at columns 43 and 47 are not typed as any, number, bigint, or an enum. The @termuijs/ui build command (tsup) exited with code 1.

🤖 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 sorting
logic used by _valuesEqual so sortedA and sortedB both use the same comparator
compatible with the arrays’ value type. Ensure equivalent string inputs such as
["2", "10"] receive identical ordering and avoid numeric subtraction that
violates TypeScript strict typing.

Source: Coding guidelines

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