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/todo-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CustomMultiProgress extends (MultiProgressClass as any) {
const value = Math.max(0, Math.min(1, item.value));
const filled = Math.round(barWidth * value);

const pct = Math.round(value * 100);
const pct = Math.round(value * 100 + Number.EPSILON);

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:

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

node <<'NODE'
const current = Math.round(0.285 * 100 + Number.EPSILON);
const corrected = Math.round((0.285 + Number.EPSILON) * 100);

if (current !== 28 || corrected !== 29) {
    throw new Error(`current=${current}, corrected=${corrected}`);
}
NODE

Repository: Karanjot786/TermUI

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

node <<'NODE'
const value = 0.285;
const currentPct = Math.round(value * 100 + Number.EPSILON);
const correctedPct = Math.round((value + Number.EPSILON) * 100);

console.log('currentPct=', currentPct);
console.log('correctedPct=', correctedPct);
console.log('EPSILON=', Number.EPSILON);
console.log('value*100=', value * 100);
console.log('current expression near integer boundary=', currentPct + 0.0000000000000001 - (value *100 + Number.EPSILON));
NODE

Repository: Karanjot786/TermUI

Length of output: 312


Apply epsilon before scaling.

Line 107 adds Number.EPSILON after multiplying by 100. Number.EPSILON is too small at this magnitude to correct every half-percent boundary, so values like 0.285 can round to 28 instead of 29. Add epsilon before scaling.

🤖 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 `@examples/todo-app/src/index.ts` at line 107, Update the percentage
calculation at the pct assignment to add Number.EPSILON to value before
multiplying by 100, then round the scaled result. Preserve the existing
percentage conversion while ensuring half-percent boundaries such as 0.285 round
correctly.

const percentStr = ` ${pct}% `;
const showPct = barWidth >= percentStr.length;
const labelStart = showPct ? Math.floor((barWidth - percentStr.length) / 2) : -1;
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 malformed catch callback before merge.

Line 383 is invalid TypeScript because the arrow function has no parameter list. Pass the rejection value to console.error so the reload error remains visible.

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 malformed catch
callback in the exitedPromise handling by declaring its rejection parameter and
passing that value to console.error, preserving visibility of reload errors.

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:

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

if rg -n 'sort\(\(a, b\) => a - b\)' packages/ui/src/TreeSelect.ts; then
    echo "Invalid string-subtraction comparator remains." >&2
    exit 1
fi

Repository: Karanjot786/TermUI

Length of output: 257


🏁 Script executed:

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

printf '--- TreeSelect relevant lines ---\n'
sed -n '160,195p' packages/ui/src/TreeSelect.ts

printf '\n--- TreeSelect test string values ---\n'
sed -n '1,120p' packages/ui/src/TreeSelect.test.ts

printf '\n--- TypeScript compiler/type presence ---\n'
if [ -f package.json ]; then cat package.json | sed -n '1,220p'; fi
node - <<'JS'
const fs = require('node:fs');
for (const name of ['package.json','tsconfig.json','packages/ui/tsconfig.json','packages/tsconfig.json']) {
  if (fs.existsSync(name)) console.log(name, fs.readFileSync(name,'utf8'));
}
JS

Repository: Karanjot786/TermUI

Length of output: 247


🏁 Script executed:

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

printf '%s\n' '--- TreeSelect relevant lines ---'
sed -n '160,195p' packages/ui/src/TreeSelect.ts

printf '%s\n' ''
printf '%s\n' '--- TreeSelect test string values ---'
sed -n '1,120p' packages/ui/src/TreeSelect.test.ts

printf '%s\n' ''
printf '%s\n' '--- TreeSelect type/status definitions ---'
sed -n '1,120p' packages/ui/src/TreeSelect.ts

printf '%s\n' ''
printf '%s\n' '--- TypeScript compiler/type presence ---'
node - <<'JS'
const fs = require('node:fs');
const paths = ['package.json','tsconfig.json','packages/ui/tsconfig.json','packages/tsconfig.json'];
for (const name of paths) {
  if (fs.existsSync(name)) {
    console.log(`--- ${name} ---`);
    console.log(fs.readFileSync(name, 'utf8'));
  }
}
JS

printf '%s\n' '--- Search TreeSelect equality comparator context ---'
rg -n 'selectedHasAll|sortedA|sortedB|Set|selected' packages/ui/src/TreeSelect.ts

Repository: Karanjot786/TermUI

Length of output: 11434


🏁 Script executed:

#!/usr/bin/env bash
set -u
# Use read-only checks and print only the relevant lines under each section.
printf '%s\n' '--- _valuesEqual implementation ---'
sed -n '174,192p' packages/ui/src/TreeSelect.ts

printf '%s\n' '--- _valuesEqual callers ---'
rg -n '_valuesEqual|selectedValues|toggleSelection' packages/ui/src/TreeSelect.ts

printf '%s\n' '--- behavioral probe for current comparator ---'
node - <<'JS'
function sortedComparison(a, b) {
  const sortedA = [...a].sort((a, b) => a - b);
  const sortedB = [...b].sort();
  return sortedA.map((v, i) => ({ sortedA: v, sortedB: sortedB[i], equalAt: v === sortedB[i] }));
}
console.log(JSON.stringify({
  subtractionValuesForStrings: ['s', 'a', 'l'].map((a, i) => ({ a, b: i < 2 ? ['s','a','l'][i + 1] : undefined, sub: a - (i < 2 ? ['s','a','l'][i + 1] : 'undefined') })),
  stringArrays: ['s','a','b','l'],
  result: sortedComparison(['s','a','b','l'], ['s','a','b','l'])
}, null, 2));
JS

Repository: Karanjot786/TermUI

Length of output: 1733


Use a string-safe equality strategy for both arrays.

Line 185 subtracts string values, which TypeScript strict mode rejects. If the code runs under coercion, nonnumeric values such as 's' and 'a' produce NaN. sortedB also uses default lexicographic sorting, so identical value arrays can have different index order.

Use Set membership comparison because _selected is typed as Set<string>, or apply the same typed comparator to both arrays.

🤖 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 array equality logic
in TreeSelect so it no longer subtracts string values or relies on mixed sorting
behavior. In the comparison around the sortedA/sortedB checks, switch to a
string-safe approach that matches the _selected Set<string> semantics, such as
comparing Set membership directly or applying the same typed string comparator
to both arrays. Ensure both sides are normalized the same way before comparing
so identical string lists cannot differ by index order.

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