From 576efa47f92edda25e51b9f80cab56717dae528f Mon Sep 17 00:00:00 2001 From: Yuri Mandrikov Date: Wed, 21 Jan 2026 17:27:41 +0400 Subject: [PATCH 1/2] fix(commands-plugin): ensure currentCommand is updated correctly on change Applied a hacky workaround because Grafana does us a disservice with its automatic deep merging of old and new panel state. This "helpful" feature has no opt-out and causes stale argument values to persist when switching between commands. The workaround sets currentCommand to undefined first, then applies the actual value in the next frame via requestAnimationFrame, forcing Grafana to treat it as a fresh object rather than merging it with the previous state. A clean solution would require rewriting the plugin's state management. --- .../src/components/CommandSelect.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/enapter-commands-panel/src/components/CommandSelect.tsx b/enapter-commands-panel/src/components/CommandSelect.tsx index 381a1da..b06e4fd 100644 --- a/enapter-commands-panel/src/components/CommandSelect.tsx +++ b/enapter-commands-panel/src/components/CommandSelect.tsx @@ -3,6 +3,8 @@ import { Field, Select, useStyles2 } from '@grafana/ui'; import { usePanel } from './PanelProvider'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { css } from '@emotion/css'; +import { cloneDeep } from 'lodash'; +import { current } from 'immer'; const getStyles = (theme: GrafanaTheme2) => { return { @@ -52,8 +54,14 @@ export const CommandSelect: React.FC = () => { const handleOnChange = async (v: SelectableValue) => { updatePanel((draft) => { - draft.currentCommand = draft.commands[v.value!]; + draft.currentCommand = undefined; }); + + requestAnimationFrame(() => { + updatePanel((draft) => { + draft.currentCommand = cloneDeep(current(draft.commands[v.value!])); + }); + });0 }; return ( From f355ebe886395461fa16e383c35e6e9b28b4f629 Mon Sep 17 00:00:00 2001 From: Yuri Mandrikov Date: Wed, 21 Jan 2026 19:25:39 +0400 Subject: [PATCH 2/2] fix(commands-plugin): remove extraneous character --- enapter-commands-panel/src/components/CommandSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enapter-commands-panel/src/components/CommandSelect.tsx b/enapter-commands-panel/src/components/CommandSelect.tsx index b06e4fd..d2ce2bf 100644 --- a/enapter-commands-panel/src/components/CommandSelect.tsx +++ b/enapter-commands-panel/src/components/CommandSelect.tsx @@ -61,7 +61,7 @@ export const CommandSelect: React.FC = () => { updatePanel((draft) => { draft.currentCommand = cloneDeep(current(draft.commands[v.value!])); }); - });0 + }); }; return (