Skip to content

fix: promql MODE-both bug#109

Merged
nitisht merged 1 commit into
parseablehq:mainfrom
pratik50:fix/promql-bug
Jun 13, 2026
Merged

fix: promql MODE-both bug#109
nitisht merged 1 commit into
parseablehq:mainfrom
pratik50:fix/promql-bug

Conversation

@pratik50

@pratik50 pratik50 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

##FIX

  • changed the shortcut command key to <ctrl + space> for changing the MODE (range, instant, both)
  • fix the bug where on both MODE, data was not loading.

Summary by CodeRabbit

  • New Features

    • Step panel mode can now be toggled using the Ctrl+Space keyboard shortcut instead of the previous Space key.
  • Bug Fixes

    • Fixed time range adjustment logic when switching between different PromQL query modes to properly reset or recompute time values.
    • Improved handling of invalid time windows in range queries by normalizing query parameters.
    • Enhanced "no results" detection to properly recognize missing chart data during rendering.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f384006-69ef-4ed0-a281-913ddfb5d481

📥 Commits

Reviewing files that changed from the base of the PR and between 3a91d79 and a97fede.

📒 Files selected for processing (2)
  • pkg/model/promql.go
  • pkg/model/promql_test.go

📝 Walkthrough

Walkthrough

The PR updates PromQL step panel mode toggling to use Ctrl+Space instead of Space, refines time-range adjustments during mode transitions based on the previous mode, adds range-window normalization for both-mode queries with invalid time orderings, and improves no-results rendering to account for missing chart rows.

Changes

PromQL Mode and Range Handling

Layer / File(s) Summary
Test imports
pkg/model/promql_test.go
Extended test imports to include strings and config packages required by new test cases.
Ctrl+Space mode toggle key binding
pkg/model/promql.go, pkg/model/promql_test.go
Added isPromqlModeToggleKey helper to detect Ctrl+Space key events, updated step-panel legend to show the new shortcut, and added test confirming the key binding triggers on Ctrl+Space and not on plain Space.
Mode switching with prevMode-based time range adjustment
pkg/model/promql.go, pkg/model/promql_test.go
Step-panel mode cycling now branches on the previous mode when adjusting time range—resetting end when switching from both and recalculating start from selected duration when switching from instant. Test verifies instant-to-both conversion preserves the end time while shifting start correctly.
Range window normalization for both mode
pkg/model/promql.go, pkg/model/promql_test.go
Added normalizePromqlRangeWindow helper that parses and corrects invalid time-window orderings by extending from end-time plus 1 hour, integrated into both-mode range-query fetching, and tested for correct RFC3339 string correction of invalid ranges.
Results rendering with chart mode and no-results condition
pkg/model/promql.go, pkg/model/promql_test.go
Refined no-results condition to treat missing chartRows in chart mode as no-results alongside empty dataRows. Tests verify chart rows render when instant rows are empty and that both instant and chart data are preserved after fetch in both mode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • parseablehq/pb#98: Both PRs modify PromQL step/panel mode UI behavior in pkg/model/promql.go around instant-mode handling and keyboard shortcuts.
  • parseablehq/pb#99: Both PRs modify PromQL's mode/range handling in pkg/model/promql.go, particularly range-window normalization and both-mode execution paths.

Suggested reviewers

  • nitisht

Poem

🐰 A toggle key, so crisp and clean,
Ctrl+Space now rules the PromQL scene,
Modes shift smoothly, time ranges align,
Windows normalize, no more crossing the line,
Charts and tables together shall dance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 'fix: promql MODE-both bug' directly addresses the main objective of fixing a bug in PromQL MODE-both functionality, which is the core change in the changeset.
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.

@pratik50 pratik50 self-assigned this Jun 11, 2026
@nitisht nitisht merged commit e9d8b1e into parseablehq:main Jun 13, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 13, 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