feat: configurable numeric precision (per-widget, type-aware, optional global)#456
feat: configurable numeric precision (per-widget, type-aware, optional global)#456zachthedev wants to merge 1 commit into
Conversation
|
@zachthedev i prefer this be a widget specific config, not global. |
What about widget specific with a global override? If a user didn't want to manually configure every one. |
What widgets would it impact? Anything displaying a number? It'll touch more widgets but if it makes sense I'm fine with it if it's done cleanly and doesn't modify existing default behavior. |
Yeah anything displaying a number. I marked this as a draft and will mess around with a few ideas. |
Add a per-widget `numberFormat` ({ style: precise|compact|whole, decimals })
and an optional per-kind global (Settings.numberFormat), resolved by
resolveNumberFormat(kind, item, settings) with a set global winning over the
per-widget value (matching overrideForegroundColor / globalBold). Every numeric
formatter routes through renderMagnitude with a type-appropriate baseline, so
default output is unchanged: tokens/speed/percent stay 1 decimal, cost 2,
memory G1/M0/K0.
Styles: precise keeps trailing zeros (1.0M, today's default); compact trims
them (1M, 1.1M); whole drops decimals (1M).
Threaded through every numeric widget (tokens, context length/window/bar,
compaction reclaimed, cache read/write/hit, free memory, session cost, speeds,
context %, usage sliders, block/weekly timers). TUI: ColorMenu (n) cycles a
widget's style, Global Overrides has a per-type submenu, and decimals is set in
settings.json. Optional schema fields, so no settings migration.
Co-Authored-By: Claude <noreply@anthropic.com>
6e15df7 to
cce85dd
Compare
Closes #455
Replaces the rejected "always trim
.0" approach (per the discussion here) withconfigurable decimal precision for numeric widgets. Default output is unchanged.
Model
numberFormat: { style?, decimals? }(top-levelWidgetItemfield,alongside
dim/bold):style:precise(keep trailing zeros, today's1.0M) |compact(trimthem:
1M,1.1M) |whole(no decimals:1M).decimals: max places beforestyleapplies.Settings.numberFormat(token,speed,percent,memory,cost). A kind set there wins over the per-widget value, sameprecedence as
overrideForegroundColor/globalBold.decimals: token/speed/percent default 1, cost 2, memory G:1 / M:0 / K:0.
resolveNumberFormat(kind, item, settings)is the single choke point; thepure formatters (
formatTokens,formatSpeed,formatPercent,formatCost,memory) take the resolved format. Optional fields, so no settings migration.
Scope
Every numeric widget: tokens in/out/cached/total, context length/window/bar,
compaction reclaimed, cache read/write/hit, free memory, session cost,
input/output/total speed, context %/usable, the usage sliders (session, weekly,
weekly opus/sonnet, extra-usage), and the block/weekly timers.
TUI
(n)cycles the highlighted widget's style (default -> compact ->whole); reset / clear-all also clear it.
(n)opens a per-type submenu to cycle each kind's style.decimalsis set per-widget / per-kind insettings.json(the power-useraxis); the TUI exposes the style.
Tests
bun run lintclean;bun testgreen (1577). Default output is unchanged(every existing widget/formatter assertion still passes); added coverage for the
format primitives, resolver precedence, and the TUI style cycle.