Skip to content
Open
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/pomodoro-timer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class GradientProgressBar extends Widget {

const attrs = styleToCellAttrs(this._style);

const label = this._showLabel ? ` ${Math.round(this._value * 100)}%` : '';
const label = this._showLabel ? ` ${Math.round(this._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

Move Number.EPSILON before percentage scaling in both renderers.

Adding epsilon after multiplication by 100 can leave the floating-point error unchanged. Apply the fix at the normalized-value scale.

  • examples/pomodoro-timer/src/index.tsx#L185-L185: use Math.round((this._value + Number.EPSILON) * 100).
  • examples/todo-app/src/index.ts#L107-L107: use Math.round((value + Number.EPSILON) * 100).
📍 Affects 2 files
  • examples/pomodoro-timer/src/index.tsx#L185-L185 (this comment)
  • examples/todo-app/src/index.ts#L107-L107
🤖 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/pomodoro-timer/src/index.tsx` at line 185, Move Number.EPSILON
before percentage scaling in both renderers: update the percentage calculation
in examples/pomodoro-timer/src/index.tsx at lines 185-185 and the corresponding
calculation in examples/todo-app/src/index.ts at lines 107-107 to round (value +
Number.EPSILON) after adding epsilon to the normalized value, preserving the
existing conditional label behavior.

const barWidth = Math.max(0, width - label.length);
const filled = this._value <= 0 ? 0 : Math.round(barWidth * this._value);
const empty = barWidth - filled;
Expand Down
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);
const percentStr = ` ${pct}% `;
const showPct = barWidth >= percentStr.length;
const labelStart = showPct ? Math.floor((barWidth - percentStr.length) / 2) : -1;
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(...) is a standalone expression. It is not attached to the Promise.all call at Line 83. This causes the parse error reported by Biome and blocks compilation.

Attach the handler to the Promise.all expression or use try/catch. On rejection, reset _isValidating, call markDirty(), and return before submitting unvalidated values.

Proposed fix
-        const results = await Promise.all(validationPromises);
+        const results = await Promise.all(validationPromises).catch((err) => {
+            console.error("Promise.all failed:", err);
+            this._isValidating = false;
+            this.markDirty();
+            return undefined;
+        });
+        if (results === undefined) return;
...
-.catch(err => console.error("Promise.all failed:", err));
📝 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
.catch(err => console.error("Promise.all failed:", err));
const results = await Promise.all(validationPromises).catch((err) => {
console.error("Promise.all failed:", err);
this._isValidating = false;
this.markDirty();
return undefined;
});
if (results === undefined) return;
🧰 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: esbuild failed to parse TypeScript/JS: Unexpected "." at src/Form.ts:142:0. Code shown: .catch(err => console.error("Promise.all failed:", err));


[error] 142-142: TypeScript DTS build failed with syntax errors at src/Form.ts(142,1): TS1128 Declaration or statement expected.


[error] 142-142: TypeScript DTS build failed at src/Form.ts(142,2): TS1005 'try' expected.


[error] 142-142: TypeScript DTS build failed at src/Form.ts(142,12): TS1005 ')' expected.


[error] 142-142: TypeScript DTS build failed at src/Form.ts(142,56): TS1005 ';' expected.


[error] 142-142: TypeScript DTS build failed at src/Form.ts(142,52): TS2304 Cannot find name 'err'.

🪛 GitHub Actions: CI / build-and-test

[error] 142-142: esbuild build failed in package @termuijs/ui with error: Unexpected "." at src/Form.ts:142:0. Offending code shown: .catch(err => console.error("Promise.all failed:", err));


[error] 142-142: TypeScript DTS build failed with TS1128: Declaration or statement expected (src/Form.ts:142:1).


[error] 142-142: TypeScript DTS build failed with TS1005: 'try' expected (src/Form.ts:142:2).


[error] 142-142: TypeScript DTS build failed with TS1005: ')' expected (src/Form.ts:142:12).


[error] 142-142: TypeScript DTS build failed with TS1005: ';' expected (src/Form.ts:142:56).


[error] 142-142: TypeScript DTS build failed with TS2304: Cannot find name 'err' (src/Form.ts:142:52).

🤖 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 the Promise.all call so its rejection handler is syntactically attached,
or replace it with try/catch. On rejection, reset _isValidating, call
markDirty(), and return before submitting unvalidated values.

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
Loading