-
Notifications
You must be signed in to change notification settings - Fork 230
fix: resolve 4 bugs in termui #3595
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: #!/bin/bash
set -euo pipefail
echo "== file excerpt =="
if [ -f examples/pomodoro-timer/src/index.tsx ]; then
nl -ba examples/pomodoro-timer/src/index.tsx | sed -n '140,205p'
else
echo "missing examples/pomodoro-timer/src/index.tsx"
fi
echo
echo "== JS Node probe for exact value and proposed forms =="
node - <<'JS'
const value = 0.145;
const beforeRound = value * 100 + Number.EPSILON;
const proposedRound = (value + Number.EPSILON) * 100;
console.log(JSON.stringify({
value: value,
valueTimes100: value * 100,
eps: Number.EPSILON,
beforeRoundString: beforeRound.toString(),
beforeRoundValue: beforeRound,
beforeRound: Math.round(beforeRound),
proposedRoundString: proposedRound.toString(),
proposedRound: Math.round(proposedRound),
exactThresholdBelowBy: Number.isFinite((100 * value) - 14.5) ? (100 * value) - 14.5 : 'not finite',
beforeRoundBelowThresholdBy: beforeRound - 14.5,
proposedRoundAboveThresholdBy: proposedRound - 14.5,
}, null, 2));
JSRepository: Karanjot786/TermUI Length of output: 215 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== file exists and line count =="
if [ -f examples/pomodoro-timer/src/index.tsx ]; then
wc -l examples/pomodoro-timer/src/index.tsx
else
echo "missing examples/pomodoro-timer/src/index.tsx"
exit 0
fi
echo
echo "== file excerpt using sed =="
sed -n '140,205p' examples/pomodoro-timer/src/index.tsx
echo
echo "== JS Node probe for exact value and proposed forms =="
node - <<'JS'
const value = 0.145;
const beforeRound = value * 100 + Number.EPSILON;
const proposedRound = (value + Number.EPSILON) * 100;
console.log(JSON.stringify({
value: value,
valueTimes100: value * 100,
eps: Number.EPSILON,
beforeRoundString: beforeRound.toString(),
beforeRoundValue: beforeRound,
beforeRound: Math.round(beforeRound),
proposedRoundString: proposedRound.toString(),
proposedRound: Math.round(proposedRound),
exactThresholdBelowBy: Number.isFinite((100 * value) - 14.5) ? (100 * value) - 14.5 : 'not finite',
beforeRoundBelowThresholdBy: beforeRound - 14.5,
proposedRoundAboveThresholdBy: proposedRound - 14.5,
}, null, 2));
JSRepository: Karanjot786/TermUI Length of output: 3166 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== search render/setValue usages in pomodoro example =="
rg -n "setValue|get value|label|0\.145|14\.5|GradientProgressBar|_value" examples/pomodoro-timer/src -S || true
echo
echo "== probe percentage rounding edge cases for multiply-then-add vs add-then-multiply =="
node - <<'JS'
function roundScale(value) { return Math.round(value * 100 + Number.EPSILON); }
function roundProposed(value) { return Math.round((value + Number.EPSILON) * 100); }
const xs = [0.145, 0.285, 0.425, 0.565, 0.705, 0.845, 0.985];
for (const x of xs) {
console.log(`${x}: multiplyThenAdd=${roundScale(x)} addThenMultiply=${roundProposed(x)} diff=${roundScale(x)-roundProposed(x)}`);
}
JSRepository: Karanjot786/TermUI Length of output: 2499 Scale Line 185 adds an absolute epsilon after Proposed fix- 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 | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 2818
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 2505
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 3263
Negate
event.ctrlinstead of asserting it non-null.event.ctrl !is a non-null assertion and does not test for the Control key. Use!event.ctrlso plainccan open the modal and Ctrl+C can keep using the quit path.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines