tui: fix execute-threshold display overflow and sidebar bar wrap (#90)
When users configure execute_threshold_tokens instead of
execute_threshold_percentage, the resolver in event-resolvers.ts derives
a percentage via (tokens / contextLimit * 100), which produces long
floats like 14.099783080260304 for non-round token budgets. The TUI
sidebar and /ctx-status header rendered that raw, causing it to wrap
onto a second line and crowd the breakdown bar.
Add a shared `formatThresholdPercent` helper under
`packages/plugin/src/shared/` that:
- leaves integer-equivalent percentages alone (`65` → `65`)
- rounds derived percentages to one decimal (`14.099...` → `14.1`)
- returns the number without the trailing `%` so callers can compose
"47.5% / 65%" style strings consistently
Wire it through all six display sites:
- sidebar-content.tsx context-summary header
- tui/index.tsx /ctx-status header
- tui/index.tsx "Auto-execute at TTL or ≥X%" row
- tui/index.tsx "Execute threshold X%" row
- pi-plugin status-dialog "Execute threshold X%" line (via
`@magic-context/core/shared/format-threshold`)
Also drop the sidebar's hardcoded `barWidth` from 36 to 24. The
@opencode-ai/plugin/tui slot API does not expose the rendered sidebar
width to plugins, and 36 chars overflowed real OpenCode sidebar layouts,
wrapping the breakdown bar onto a second line (the L-shaped fragment in
the user's screenshot. 24 chars is the safe floor that fits every
realistic configuration we've observed; when the slot API eventually
surfaces a real width, this becomes like
Pi's status dialog already does.
Plugin: 1480 tests pass. Pi: 347 tests pass. CLI: 138 tests pass.
Typecheck, lint, build all clean.
Closes #90.
EOF
) U
ualtinok committed
39bed1dc89ec5273eae2ca429558f90a8e3f9fb1
Parent: bd364a4