feat(frame): add collapse control and gauge rows

Merged
IC
1d ago
+971-19

Adds the two additions approved in cortexkit/common-auth#12, now against the frame's new home, for the 0.2.0 release.

What changes

  1. collapsible on SidebarFrame (optional). Default behaviour is unchanged: without the prop the header toggles only when the panel has accounts. collapsible={true} lets a panel without accounts (for example Magic Context or AFT) collapse to its header plus collapsedSections; collapsible={false} keeps any panel expanded.
  2. SidebarGaugeRow and SidebarGaugeRowProps (exported): a used/left gauge for a value that has no quota windows.
    • Props: label: string, used?: number, value?: string, warnAt?: number, errorAt?: number.
    • It draws with the frame's own barSegments and usageTone, so the same fill gives the same characters, width and tones as a quota row; thresholds default to the frame's appearance.
    • used is clamped to 0–100; a missing or non-finite value shows no reading with no bar.
    • At narrow widths it cuts the optional right-hand text first, then cuts or removes the bar, then cuts the label, so the percentage stays in view.

README (example and Exports), ARCHITECTURE.md and STRUCTURE.md are updated.

Tests

  • New golden frames, as asked: accountless-gauges-long-status-{expanded,collapsed}-{16,36,37,38,42} (.txt and .spans), including the 38-column frame with gauge rows and a long status line. That is 20 added files; all 32 existing golden frames are byte-identical (git diff --name-status main...HEAD -- test/frame/goldens/ shows only A).
  • Parity and behaviour tests for the one-row collapse of a panel without accounts and for the width rules; reactivity tests for theme, appearance, value and threshold changes on the gauge, and bar parity with a quota row.
  • The floor checks found one real issue on the way: on OpenTUI 0.4.5 and 0.5.11 an empty bar segment that later fills kept a zero width. The gauge's segments now carry explicit display widths; the quota renderer is unchanged.
  • scripts/gate.sh: GATE_OK (30 pass, 0 fail on the current runtime and on both floors). bun run typecheck and bun run lint pass. Imports stay within @opentui/core, @opentui/solid and solid-js.

The version stays at 0.1.0; the 0.2.0 release is yours.


Summary by cubic

Adds an optional collapsible prop to SidebarFrame and a new SidebarGaugeRow component. Without collapsible, the frame behaves as before: the header toggles only when the panel has accounts. With collapsible={true}, an accountless panel can collapse to its header (plus collapsedSections); collapsible={false} keeps any panel expanded.

New Features

  • SidebarGaugeRow renders a used/left percentage with the same bar segments and usage tones as quota rows; used is clamped to 0–100 and a missing or non-finite value shows "no reading" with no bar.
  • At narrow widths, the optional right-hand value is trimmed first, then the bar, then the label, so the percentage stays visible.

Bug Fixes

  • Fixed an OpenTUI 0.4.5/0.5.11 issue where an empty bar segment that later filled kept zero width; gauge segments now carry explicit display widths, and the quota renderer is unchanged.