14 Commits
Author SHA1 Message Date
Aleks Petrov 6fd5cf15be fix(render): SegmentMeter track uses hollow glyph so bargauge fill is legible without color
Filled and track cells both used the solid ■ glyph, encoding the fill
fraction in color alone. With ANSI stripped (--once piped to a non-TTY,
NO_COLOR, frames pasted into an issue) every bar collapsed to a uniform
full-width bar. Render the track with □ instead, matching the function's
documented output. Also fixes the gauge widget.

Fixes #1
2026-07-17 00:25:09 +02:00
Aleks Petrov 6c1a9fd06f feat(widget): overlay mode for multi-series timeseries
Multi-series charts previously always stacked — the stacked flag was
parsed but never honored. Now stacked: false (the default) overlays on
a shared y-scale via render.BrailleMulti: first series as filled area,
later ones as lines on top, one color per series. This matches
Grafana's default timeseries rendering, so imported dashboards look
right too. Solid (--ascii) mode keeps stacking: no block overlay
primitive exists.

examples/pilot.yaml grows a full-width 'time / issue' row overlaying
avg PR time-to-merge (area) with avg execution duration (line), both
1h windows. exec durations are session-scoped upstream (hydration
asked in pilot#4134), so that series starts sparse.
2026-07-09 19:03:32 +02:00
Aleks Petrov e2c65d426e chore: rename project grot -> grom
Grafana's mascot and AI helper are both named Grot
(grafana.com/grot) — a name collision flagged on the r/grafana
launch thread. grom (Polish: thunder) keeps the short Slavic name
without squatting on Grafana's brand.

Renames the Go module, cmd dir, binary, brew cask, docs, examples,
and dev docs. Old repo URL redirects; module path is new as of
v0.2.0.
2026-07-09 18:21:43 +02:00
Aleks Petrov 9ffca6b683 test(render): guard the border-legend width invariant under truncation
Sweeps PanelInfo with a styled legend across panel widths 6–80 and asserts
every line stays exactly w cells. An over-wide or escape-mangled top border
wraps in the terminal and cascade-breaks the whole frame below it — the
resize corruption fixed in the previous CSI truncation commit. Fails on the
pre-fix TruncateVisual; raw ANSI input because lipgloss strips color off-TTY.
2026-07-07 19:58:00 +02:00
Aleks Petrov 78de3b283a fix(widget): visual-width math and order-independent thresholds
- gauge scale line, bargauge value column, and timeseries y-gutter sized
  labels with len(); FormatValue can emit µs (2 bytes, 1 cell), skewing the
  layout by a cell. Use lipgloss.Width.
- thresholdColor picked the last matching step, assuming ascending order —
  Grafana exports steps sorted, hand-written YAML may not be. Resolve the
  highest matching threshold regardless of slice order.
- drop the dead 'var _ = lipgloss.Width' import keeper.
2026-07-07 19:51:12 +02:00
Aleks Petrov bd3cab4dd8 fix(render): terminate CSI at its final byte and reset styles after truncation
TruncateVisual ended escape mode at the first byte in 0x40–0x7e, but the CSI
introducer '[' (0x5b) is itself in that range — real SGR sequences dropped out
of escape mode immediately and their parameter bytes counted as visible text.
Masked in tests because lipgloss strips color off-TTY; now covered with raw
ANSI input.

Also re-emit a reset when truncation cuts a styled string before its closing
reset, so the ellipsis and following text don't inherit the open style.
2026-07-07 19:51:12 +02:00
Aleks Petrov 48168660f5 fix(render): NaN-as-gap timeseries + richer example dashboard
The live dashboard's charts collapsed into solid blocks jammed against the right
edge, unlike the demo gallery's airy full-width braille. Two causes:

- prom.go QueryRange dropped NaN samples, and scaleToDots/resampleCols
  right-align when points < columns — so a sparse series (p95: ~60/90 buckets
  NaN) lost its time axis and got shoved right as a filled block. Now QueryRange
  keeps NaN positionally; the braille scalers render NaN as a gap (height 0) and
  ignore it in min/max; Series.Last() and TimeSeries.collect() skip NaN. Sparse
  ranges now render at their true timestamps with gaps, and stacked multi-series
  stay index-aligned. Regression tests in render + prom.

- examples/pilot.yaml was thin and used sparse query shapes. Rebuilt to mirror
  the demo: 24-col gridPos layout (4 stats / gauge + bar gauge / two charts),
  tokens-by-direction as a bar gauge, and always-defined cumulative/rate charts.

go test -race and golangci-lint clean; demo gallery unchanged.
2026-07-07 16:11:16 +02:00
Aleks Petrov 54750935a2 feat(grafana): import Grafana dashboard JSON with gridPos layout
Phase 5 of the v0.1 MVP — reproduce a Grafana dashboard in the terminal.

- internal/grafana: Import/Convert map a Grafana export (bare or {"dashboard":{}}
  wrapped) to a normalized config.Dashboard + warnings. stat/gauge/bargauge/
  timeseries map 1:1; fieldConfig defaults (unit/decimals/min/max/thresholds),
  stacking, reduceOptions, and targets (expr/legendFormat/instant) carry over;
  time.from now-<dur> -> range, refresh -> refresh. Row panels drop but promote
  their children; unsupported types become a placeholder in their grid slot with
  a warning.
- config: TypePlaceholder (query-less) + exported Dashboard.Normalize so the
  importer runs the loader's validation/defaults.
- widget: Placeholder panel ("unsupported: <type>").
- app/grid: GridLayout now honors 24-col gridPos (scale to termW, group by
  Grafana row) when present, else auto-flows; composeGrid is Y-grouped, X-sorted,
  and gap-aware so tiled dashboards reproduce faithfully.
- cli: run --grafana-json <file>; new `grot import <file> [--check]`.

Verified: `run --grafana-json pilot-dashboard.json --once` @ :9093 reproduces the
Grafana 4x4 layout with correct titles/units/thresholds/charts; synthetic fixture
covers gauge/bargauge/row-promotion/placeholder. Golden tests (real + synthetic +
wrapped + parseNowRange) + gridPos layout test; go test -race and lint clean.
2026-07-07 15:51:33 +02:00
Aleks Petrov fbcb245d59 feat(app): interactive Bubble Tea dashboard — grid, focus, zoom, polling
Phase 4 of the v0.1 MVP. Consolidates layout/fetch/render into internal/app and
adds the interactive TUI; cmd/grot/run.go is now thin CLI wiring.

- grid.go: Rect + GridLayout (auto-flow, absolute cells, reflow breakpoints
  <80/80-139/>=140) + focusMove (overlap-gated geometric hjkl).
- fetch.go: FetchWidget/useRange/FetchAll moved out of run.go.
- render.go: header, grid compositor, StaticFrame, and safeRender (never renders
  a widget below its MinSize).
- model.go: Bubble Tea Model + RunTUI. tick -> batched per-widget fetch Cmds with
  an in-flight guard so slow queries never block Update or stack; keys for hjkl
  focus, Enter zoom, +/- range presets, r refresh, t theme, q quit; WindowSizeMsg
  reflow; vertical scroll; widget-local errors keep the grid intact.
- run.go: default launches the TUI; --once renders one static frame.

Fix: an aggressive resize could lay a widget out below its chrome, underflowing
width math to a negative strings.Repeat count and panicking in TruncateVisual.
TruncateVisual/Center/PadOrTruncate now clamp non-positive widths, and safeRender
gates widget sizes — "live resize never breaks the grid".

Verified: full interactive TUI against live Prometheus (real PTY) renders all
widgets and handles all keys without panic; 12 model tests + grid/step tests;
go test -race and golangci-lint clean.
2026-07-07 15:36:54 +02:00
Aleks Petrov 4cfb29e515 feat(datasource): Prometheus queries, YAML config, and query_range braille pipeline
Phase 2 + Phase 3 of the v0.1 MVP.

Phase 2 — instant queries + native config:
- internal/datasource: Datasource interface at the consumer boundary
  (QueryInstant/QueryRange) with Instant/Range request types.
- internal/datasource/prom: client_golang-backed impl; {{label}} legend
  expansion; NaN samples dropped.
- internal/config: canonical Dashboard/WidgetSpec model + strict YAML loader
  (KnownFields, validation, defaults).
- internal/app: BuildWidget spec→widget factory.
- cmd/grot run: --config/--prom/--theme/--watch; per-widget ctx timeout so one
  slow/failing query never breaks the grid.

Phase 3 — query_range + braille timeseries:
- internal/app/step: StepFor(range, chartWidth) — chartWidth×2 dots → step
  rounded up a clean ladder, 10s floor; sample count never exceeds the dot
  budget (table + invariant tests).
- cmd/grot run: layout planned once per tick so fetch (step sizing) and draw
  share widths; timeseries routed through QueryRange; --ascii block fallback.
- examples/pilot.yaml: p95 execution + stacked tokens-by-model timeseries.

Known gap: range NaN points are dropped rather than
kept as positional gaps, which collapses the time axis for sparse series and
would misalign stacked multi-series. To be addressed before stacked ships.
2026-07-07 15:09:48 +02:00
Aleks Petrov 0c118ff95f feat: btop-faithful widgets — braille bands, segmented meters, quiet chrome
Matched against a real btop screenshot:
- TimeSeries: braille default again (btop's own texture); single hue per
  series; multi-series → BrailleStacked with shared 0..max-total scale
  and corrected y-labels; Solid flag = block fallback
- SegmentMeter: btop disks-style ■■■□□ segmented bars for Gauge + BarGauge
- Stat trend: dim braille band (mem-panel texture), number reads first
- Titles: lowercase, case preserved (quiet chrome)
- Demo: realistic plateau+spike data, shorter chart rows
2026-07-07 13:43:38 +02:00
Aleks Petrov 0705f86ee2 feat: solid block charts by default — braille is opt-in
Braille renders as sparse dot-matrix in common terminal fonts,
making filled areas read as noise. Metric-by-metric rework:

- TimeSeries: solid block area w/ vertical gradient (single series),
  stacked solid area w/ per-series colors (multi) — Braille flag opt-in
- render: BlockArea (gradient rows), BlockStacked (shared scale,
  topmost-series cell coloring), resampleCols
- Stat trend: subdued dim blocks under the value (number reads first)
- Gauge: fills in the CURRENT value's threshold color, not a rainbow
  sweep (red left edge read as 'partly failing')
2026-07-07 13:28:50 +02:00
Aleks Petrov 2c28017019 feat: btop-style rendering — braille area charts, vertical gradients, border legends
- render/braille.go: BrailleArea (filled, gradient rows), BrailleLine,
  BrailleMulti (multi-series, shared y-scale, area + line overlay)
- render/gradient.go: hex lerp, Gradient/GradientStyles, Dim
- render/meter.go: GradientMeter — gauge sweeps threshold colors
- PanelInfo: legend + live values embedded in top border ┤ ● p95 6.9m ├
- Stat: braille history area fills the panel under the value
- TimeSeries: chart fills all rows, legend moved to border
2026-07-07 13:18:44 +02:00
Aleks Petrov 6141ff1f2a feat: scaffold grot — render primitives, themes, widgets, demo gallery
Phase 1 of the btop-style Prometheus/Grafana TUI:
- pkg/tui/render: exact-cell panel borders, ANSI-aware pad/truncate,
  block sparklines + multi-row area charts, gradient meters (ported
  from Pilot's dashboard, generalized to take theme styles)
- pkg/tui/theme: pilot, tokyo-night, catppuccin-mocha palettes
- pkg/tui/widget: Stat, Gauge, BarGauge, TimeSeries with threshold
  coloring, Grafana-style units, error/no-data states
- cmd/grot: cobra CLI with 'demo' gallery command
- Makefile, golangci config, MIT license
2026-07-07 13:10:01 +02:00