Skip to content

feat: add PromQL chart view#99

Merged
nitisht merged 3 commits into
parseablehq:mainfrom
pratik50:feat/charView
May 29, 2026
Merged

feat: add PromQL chart view#99
nitisht merged 3 commits into
parseablehq:mainfrom
pratik50:feat/charView

Conversation

@pratik50
Copy link
Copy Markdown
Contributor

@pratik50 pratik50 commented May 29, 2026

###Change

  • added feature of chart View feature in Promql

Summary by CodeRabbit

  • New Features

    • Interactive chart view for query results alongside the table; toggle chart/table and navigate a chart cursor/inspector.
  • Tests

    • Added unit tests for chart data extraction, aggregation, formatting, timestamp handling, and step resolution.
  • Chores

    • Updated multiple dependencies to newer versions.
  • UI

    • Range-query step default/help set to "auto"; status bar label now shows "QUERY"; improved key-hint grid rendering.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d61b1a2-efcd-479a-8449-e0074deacf1e

📥 Commits

Reviewing files that changed from the base of the PR and between c5b79a1 and 609d48e.

📒 Files selected for processing (1)
  • pkg/ui/chrome.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/ui/chrome.go

📝 Walkthrough

Walkthrough

Adds interactive charting to the PromQL UI: introduces mode-aware fetching and step resolution, persists raw timestamps, extends PromqlModel with chart state and cursor/hover, wires keyboard chart/table toggles and cursor navigation, renders time-series via ntcharts, and supplies unit tests and dependency upgrades.

Changes

PromQL Chart Visualization

Layer / File(s) Summary
Dependency updates
go.mod
Bumps charmbracelet packages and related indirect modules, adds bubblezone, upgrades bubble-table, sahilm/fuzzy, mattn/go-runewidth, and several golang.org/x/* packages.
Imports, constants, and model fields
pkg/model/promql.go
Adds ntcharts/math imports, new timestamp constants and regex helpers, extends PromqlModel and PromqlFetchData with chart fields and chartRows, and enables chart mode by default.
PromQL mode, step resolution, and fetch tasks
pkg/model/promql.go
Implements execution-mode helpers, normalizePromqlStep/ResolvePromqlStep, a mode-based fetch task (range/instant/both), and centralized PromQL HTTP fetching with resolved steps.
Data persistence and fetch handling
pkg/model/promql.go
Constructor/Init use mode-based fetches; successful/failed fetches update both table and chart rows, reset chart cursor/hover/readiness, resize triggers chart rebuild, and _timestamp_full is populated. Timestamp formatting/parsing now uses local time and chart parser.
Keyboard & control wiring
pkg/model/promql.go
Query run normalization, space-cycling of modes, Ctrl+R/Alt+Enter use mode-based fetching, t toggles chart/table when allowed, and cursor navigation (left/right or [/]) moves chart cursor and rebuilds chart.
Rendering, pane chrome, and footer key grid
pkg/model/promql.go, pkg/ui/chrome.go
Adds renderPromqlResultsPane, conditionally routes results pane to chart or table, shows computed chart time-range in title, introduces rangeMode for sidebar, and switches footer rendering to exported ui.KeyGrid.
Chart extraction, aggregation, and rendering
pkg/model/promql.go
Extracts series grouped by metric label set, aggregates/averages values per timestamp bucket, computes axis scaling and tick spacing, builds ntcharts line-model, draws series segments and x-axis labels, and renders a cursor inspector for single-series inspection.
Unit tests for chart helpers
pkg/model/promql_test.go
Adds tests for series grouping, series point preservation/order, color uniqueness, compact value formatting, 12-hour time formatting, local timezone timestamp formatting, and ResolvePromqlStep.
CLI and small UI updates
cmd/promql.go, pkg/model/query.go, pkg/ui/chrome.go
--step default changed to auto and routed through ResolvePromqlStep; bottom-bar label changed from MODE to QUERY; ui.KeyGrid exported helper added.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through timestamps, fields, and keys,
Stitched charts from flux and query breeze,
A cursor nibble, a legend bright,
PromQL now paints the data's light. 🎨📈

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add PromQL chart view' directly and accurately describes the main change in the pull request—adding interactive chart functionality to the PromQL TUI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/ui/chrome.go`:
- Around line 192-193: KeyGrid currently forwards inputs to buildKeyGrid without
validating cols which can cause a divide-by-zero panic; change KeyGrid to guard
cols (e.g., if cols <= 0 then set cols = 1 or return an empty string) before
calling buildKeyGrid, and optionally validate availW similarly (clamp to a
non-negative value) so buildKeyGrid never receives a zero/negative column count;
update KeyGrid to perform this check and then call buildKeyGrid(keys, cols,
availW).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 481f880d-58d8-4936-8863-e67ff4c1854d

📥 Commits

Reviewing files that changed from the base of the PR and between 9fdefed and c5b79a1.

📒 Files selected for processing (5)
  • cmd/promql.go
  • pkg/model/promql.go
  • pkg/model/promql_test.go
  • pkg/model/query.go
  • pkg/ui/chrome.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/model/query.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/model/promql.go

Comment thread pkg/ui/chrome.go
@nitisht nitisht merged commit 11074ca into parseablehq:main May 29, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants