Skip to content

StatPanel: Preserve dashboard click ownership after drill-down close - #256

Merged
harjotgill merged 2 commits into
coderabbit_micro_frontendfrom
codex/grafana-stat-click-owner
Sep 17, 2026
Merged

harjotgill merged 2 commits into
coderabbit_micro_frontendfrom
codex/grafana-stat-click-owner

Conversation

@harjotgill

@harjotgill harjotgill commented Sep 17, 2026 •

Copy link
Copy Markdown

Problem and change

After a successful Quality Metrics drill-down open and close, subsequent severity clicks can stop opening the drawer while the page remains responsive. The stat panel captured metadata.eventListener from the globally selected MFE dashboard during render. If a parent stat renders while the child owns that selection, it retains the child's no-op listener even after close restores the parent UID.

Bind stat events to the panel's dashboard-local Redux store, matching the existing table and time-series listener pattern. This changes no global ownership or host drawer behavior and preserves Grafana data-link handling. Both Acceptance Rate by Severity and Acceptance Rate by Category use this stat panel.

Follow-up to #255; the stale global listener implementation originated in #208 (0444287e69), not #255. The live observation was after #255's first open/result/close worked. This PR addresses the separately reproduced reopen defect, not an unverified claim about every renderer-freeze path.

Regression and validation

  • Before the fix, real StatPanel → VizRepeater → BigValue DOM clicks reproduce the failure: first Critical click reaches the parent; parent rendering while the child is selected then closing/removing the child leaves later Critical and Minor clicks routed to the child listener (expected parent count 3, actual 1).
  • Tests retain real widgets, MFE reducers, dashboard-local providers, and createMfe.updateFnApp close-owner update. They unmount the child while retaining the parent DOM and cover both severity and category payloads. Query frames and unrelated store initialization are fixtures; the host Drawer and live backend are not exercised here.
  • Five focused suites pass, 33 tests, including ordinary non-MFE data-link menu behavior (menu opens without emitting a host event). Scoped ESLint, Prettier, and git diff --check pass.
  • Production frontend webpack build passes, with only the existing asset/entrypoint-size warnings. CI must still verify the Linux image and startup/database health.
  • Repository-wide yarn typecheck reports 122 diagnostics in 95 unchanged files; there are no changed-file diagnostics. The repository-wide check is not claimed green or baseline-proven.

Rollout and remaining verification

Grafana frontend only; no API, query, flag, IAM, ingestion, or AGENTS changes. No merge or deployment is authorized by this PR. After normal review/CI and an explicitly authorized deployment, verify severity and category open → load rows → close → reopen repeatedly on the exact published base/image/revision. A mono release alone does not rebuild Grafana source; the upstream production publishing workflow also dispatches downstream deployments and needs appropriate authorization.

Agent handoff

  • Request: diagnose the observed post-close reopen failure and prepare a bounded regression-backed fix.
  • Base: coderabbit_micro_frontend at 51330cfea63c496026e150453534cf534000c8b9.
  • Scope: stat-panel callback ownership and regression coverage only. No new ownership framework or mono host changes.
  • Next: complete normal review and CI, then use the separately authorized normal merge path. A new production workflow dispatch still requires separate user authorization and authenticated verification. Production reopen behavior remains unverified for this patch.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Stat panel click handling when dashboards are embedded or switched.
    • Preserved the expected menu behavior for standard data-link clicks.
    • Ensured click events are routed to the correct dashboard context after child dashboards are closed.
    • Maintained existing Stat panel value click actions while improving event coordination across dashboard views.
  • Tests

    • Added coverage for Stat panel interactions across standalone and embedded dashboard scenarios.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 7d7279f9-c3c4-4998-b22d-3a38c6490eb5

📥 Commits

Reviewing files that changed from the base of the PR and between 51330cf and fadecf6.

📒 Files selected for processing (2)
  • public/app/plugins/panel/stat/StatPanel.test.tsx
  • public/app/plugins/panel/stat/StatPanel.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • coderabbitai/bitbucket (manual)

Included review availability: Your plan provides up to 100 included reviews per hour; 81 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Build
🔇 Additional comments (2)
public/app/plugins/panel/stat/StatPanel.tsx (1)

2-2: LGTM!

Also applies to: 18-42, 58-58, 71-71

public/app/plugins/panel/stat/StatPanel.test.tsx (1)

1-160: LGTM!


📝 Walkthrough

Walkthrough

StatPanel now gets its event listener from the dashboard-local Redux store. DashboardStatValue dispatches stat click data and forwards the existing BigValue handler. Integration tests cover native data-link menus and parent click ownership after child dashboard removal for severity and category payloads.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to fadec

This change moves Stat panel click handling to use the panel's own dashboard-local data instead of a shared global source, which is intended to stop a leftover panel from reacting to clicks after a related drill-down view is closed. Based on the available evidence, the core click-forwarding logic (including the native link menu) appears preserved, and no confirmed user-facing regression was established. There is a narrow, unverified possibility that stat values without any configured links could now render with button-like styling even though they still do nothing when clicked; this was not confirmed as an actual defect from the available evidence and does not block merge, but it may be worth a quick visual check after deployment.

🚥 Pre-merge checks | ✅ 4
✅ 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 clearly and concisely describes the main change: preserving dashboard click ownership after a drill-down closes in StatPanel.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

A rabbit hops where stat clicks start,
Local listeners guard each chart.
Child dashboards fade away,
Parent handlers work and stay.
Menus bloom on links just right,
Reopened drawers greet the night.

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

@harjotgill
harjotgill merged commit 0f71fea into coderabbit_micro_frontend Sep 17, 2026
4 checks passed
@harjotgill
harjotgill deleted the codex/grafana-stat-click-owner branch September 17, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant