-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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)}%` : ''; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: node <<'NODE'
const value = 29 / 200;
const current = Math.round(value * 100 + Number.EPSILON);
const corrected = Math.round((value + Number.EPSILON) * 100);
if (current !== 14 || corrected !== 15) {
throw new Error(JSON.stringify({ value, current, corrected }));
}
NODERepository: Karanjot786/TermUI Length of output: 156 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the relevant implementation around setValue and the label rendering.
file="examples/pomodoro-timer/src/index.tsx"
if [ -f "$file" ]; then
wc -l "$file"
sed -n '1,230p' "$file" | nl -ba
else
echo "File not found: $file"
fi
# Read-only behavioral probe for the edge cases that can appear from clamped [0,1] values.
node <<'NODE'
function current(value, showLabel = true) {
return showLabel ? Math.round(value * 100 + Number.EPSILON) : '';
}
function corrected(value, showLabel = true) {
return showLabel ? Math.round((value + Number.EPSILON) * 100) : '';
}
const cases = [
29 / 200,
1 / 200,
28 / 200,
30 / 200,
50 / 200,
];
for (const value of cases) {
const exact = value * 100;
const displayCurrent = current(value);
const displayCorr = corrected(value);
const mathExactRound = Math.round(exact);
console.log(JSON.stringify({ value, exact, current: displayCurrent, corrected: displayCorr, mathExactRound }));
}
NODERepository: Karanjot786/TermUI Length of output: 238 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="examples/pomodoro-timer/src/index.tsx"
printf '--- line count ---\n'
wc -l "$file"
printf '\n--- lines 140-210 ---\n'
sed -n '140,210p' "$file"
printf '\n--- setValue and progress symbol occurrences ---\n'
grep -nE 'setValue|_value|showLabel|Number.EPSILON|Math.round' "$file" || trueRepository: Karanjot786/TermUI Length of output: 247 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="examples/pomodoro-timer/src/index.tsx"
printf '%s\n' '--- line count ---'
wc -l "$file"
printf '%s\n' ''
printf '%s\n' '--- lines 140-210 ---'
sed -n '140,210p' "$file"
printf '%s\n' ''
printf '%s\n' '--- setValue and progress symbol occurrences ---'
grep -nE 'setValue|_value|showLabel|Number.EPSILON|Math.round' "$file" || true
printf '%s\n' ''
printf '%s\n' '--- behavioral probe ---'
node <<'NODE'
function current(value, showLabel = true) {
return showLabel ? Math.round(value * 100 + Number.EPSILON) : '';
}
function corrected(value, showLabel = true) {
return showLabel ? Math.round((value + Number.EPSILON) * 100) : '';
}
const cases = [
29 / 200,
1 / 200,
28 / 200,
30 / 200,
50 / 200,
];
for (const value of cases) {
const exact = value * 100;
const displayCurrent = current(value);
const displayCorr = corrected(value);
const mathExactRound = Math.round(exact);
console.log(JSON.stringify({ value, exact, current: displayCurrent, corrected: displayCorr, mathExactRound }));
}
NODERepository: Karanjot786/TermUI Length of output: 4790 Fix the progress percentage rounding.
- const label = this._showLabel ? ` ${Math.round(this._value * 100 + Number.EPSILON)}%` : '';
+ const label = this._showLabel ? ` ${Math.round((this._value + Number.EPSILON) * 100)}%` : '';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| const barWidth = Math.max(0, width - label.length); | ||||||
| const filled = this._value <= 0 ? 0 : Math.round(barWidth * this._value); | ||||||
| const empty = barWidth - filled; | ||||||
|
|
||||||
There was a problem hiding this comment.
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:
Repository: Karanjot786/TermUI
Length of output: 209
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 1956
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 739
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 156
Use boolean negation for the clear-form shortcut.
event.ctrl !becomes the postfix non-null assertionevent.ctrl!, so the condition requires Ctrl. Plaincnever opens the modal, while Ctrl+C exits earlier. Replace it with!event.ctrl.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines