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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

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

if (current !== 14 || corrected !== 15) {
  throw new Error(`Unexpected result: current=${current}, corrected=${corrected}`);
}
NODE

Repository: Karanjot786/TermUI

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Locate changed/mentioned files:"
git ls-files | rg '(examples/pomodoro-timer/src/index\.tsx|examples/todo-app/src/index\.ts)$' || true

echo
echo "Relevant lines:"
sed -n '175,190p' examples/pomodoro-timer/src/index.tsx
echo "---"
sed -n '95,115p' examples/todo-app/src/index.ts

echo
echo "Behavioral probe for representative float boundaries:"
node <<'JS'
const boundaries = [
  0.145,
  0.00005,
  0.0145,
  0.00045,
];
for (const value of boundaries) {
  const current = Math.round(value * 100 + Number.EPSILON);
  const corrected = Math.round((value + Number.EPSILON) * 100);
  console.log(JSON.stringify({ value, current, corrected }));
}
JS

Repository: Karanjot786/TermUI

Length of output: 2017


Apply epsilon before scaling in both renderers.

Number.EPSILON is too small at the scaled value to fix values like 0.145, which currently rounds to 14%; Math.round((value + Number.EPSILON) * 100) rounds it to 15%. Update both percentage renders and add a test for 0.145.

📍 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, Update both percentage
renderers in examples/pomodoro-timer/src/index.tsx:185-185 and
examples/todo-app/src/index.ts:107-107 to add Number.EPSILON to the value before
multiplying by 100, preserving the existing conditional label behavior. Add or
update tests covering 0.145 so it renders as 15% in both renderers.

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

if (this._running && this._entryFile) {
this._spawnChild();
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

Correct both malformed Promise rejection handlers before merging.

Both changes contain invalid TypeScript catch syntax, so the affected files cannot compile.

  • packages/ui/src/Form.ts#L141-L142: attach the handler to Promise.all, rethrow after logging, and reset validation state in finally.
  • packages/dev-server/src/server.ts#L383-L383: use a valid callback such as (err: unknown) => console.error('Child process exit failed:', err).
🧰 Tools
🪛 Biome (2.5.6)

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

(parse)

📍 Affects 2 files
  • packages/ui/src/Form.ts#L141-L142 (this comment)
  • packages/dev-server/src/server.ts#L383-L383
🤖 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 malformed Promise
rejection handlers in both sites: in packages/ui/src/Form.ts lines 141-142,
attach a valid callback to Promise.all that logs the error and rethrows it, then
reset validation state in finally; in packages/dev-server/src/server.ts line
383, replace the invalid handler with a valid (err: unknown) callback that logs
the child-process exit failure.

Source: Linters/SAST tools

Loading