Skip to content

Conversation

@ktx-vaidehi
Copy link
Collaborator

@ktx-vaidehi ktx-vaidehi commented Jul 16, 2025

PR Type

Enhancement


Description

  • Add scope, tabs, panels fields in backend struct

  • UI to select variable scope and choose tabs/panels

  • Logic watches and filters selected tabs/panels

  • Display scope badges and tooltips in settings table


Changes diagram

flowchart LR
  A["Backend: VariableList struct"] --> B["Frontend: AddSettingVariable.vue"]
  B --> C["Scope select (global, tabs, panels)"]
  C -- "if tabs or panels" --> D["Tab/Panel selectors UI"]
  D --> E["Watchers update variableData.tabs/panels"]
  E --> F["Save with scoped tabs/panels"]
  F --> G["VariableSettings.vue displays scope badges"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
mod.rs
Add scope, tabs, panels to VariableList                                   

src/config/src/meta/dashboards/v5/mod.rs

  • Added scope field to VariableList
  • Added tabs and panels arrays for scoping
  • Kept existing serialization behavior
  • +6/-0     
    AddSettingVariable.vue
    Add scoped tabs/panels UI and logic                                           

    web/src/components/dashboards/settings/AddSettingVariable.vue

  • Introduced scope select and options
  • Added tab and panel Q-select sections
  • Defined selectedTabs, selectedPanels, scopeOptions
  • Watchers & updatePanels filter logic
  • Persist variableData.tabs and variableData.panels on save
  • +293/-35
    VariableSettings.vue
    Show variable scope badges in settings                                     

    web/src/components/dashboards/settings/VariableSettings.vue

  • Added "Scope" column in variables list
  • Render badges for global, tabs, panels
  • Tooltips list applied tab/panel names
  • Defined getScopeType, getTabName, getPanelName
  • Adjusted grid-template and added CSS for scope display
  • +94/-2   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Debug log left in code

    There's a residual console.log("props----", props.dashboardVariablesList); that should be removed before merging to avoid noise and potential performance impact.

    console.log("props----", props.dashboardVariablesList);
    // Store dashboard data
    const dashboardData = ref<any>({ tabs: [] });
    Data sync on save

    variableData.tabs and variableData.panels are only set inside the watch on variableData.type. If the type doesn't change before saving, the new selectedTabs/selectedPanels won’t be applied. Consider synchronizing these fields on scope or selection changes or right before save.

    // Set tabs and panels based on the selected scope
    if (variableData.scope === "global") {
      variableData.tabs = [];
      variableData.panels = [];
    } else if (variableData.scope === "tabs") {
      variableData.tabs = [...selectedTabs.value];
      variableData.panels = [];
    } else if (variableData.scope === "panels") {
      variableData.tabs = [...selectedTabs.value];
      variableData.panels = [...selectedPanels.value];
    }
    Hardcoded scope strings

    Scope values ("global", "tabs", "panels") are used as plain strings in multiple places. Consider defining a shared constant or enum for these values to reduce typos and improve maintainability.

    const scopeOptions = computed(() => [
      { label: "Global", value: "global" },
      { label: "Selected Tabs", value: "tabs" },
      { label: "Selected Panels", value: "panels" },
    ]);

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Import and initialize useRoute

    route is used but never defined, leading to runtime errors when accessing
    route.query. Import and initialize useRoute from vue-router at the top of the
    script. Then call const route = useRoute() inside setup before using route.

    web/src/components/dashboards/settings/AddSettingVariable.vue [741-753]

     import {
       defineComponent,
       ref,
       reactive,
       onMounted,
       onActivated,
       watch,
       toRef,
       toRaw,
       type Ref,
       computed,
       nextTick,
     } from "vue";
    +import { useRoute } from "vue-router";
    Suggestion importance[1-10]: 9

    __

    Why: The code uses route.query without defining route, causing a runtime error; importing useRoute and initializing route is essential for the new dashboard-loading logic to work.

    High
    General
    Remove duplicate data assignment

    The second Object.assign(variableData, variable) will overwrite the manually set
    scope, tabs, and panels after the first assign. Remove the redundant assignment and
    handle adjustments only once to preserve scope settings.

    web/src/components/dashboards/settings/AddSettingVariable.vue [982-1024]

     Object.assign(variableData, JSON.parse(JSON.stringify(variable)));
     ...
    -Object.assign(variableData, variable);
    +// removed redundant Object.assign(variableData, variable);
    Suggestion importance[1-10]: 9

    __

    Why: The second Object.assign(variableData, variable) overwrites the manually set scope, tabs, and panels, breaking the intended binding logic, so removing it fixes a critical bug.

    High
    Add value to separator options

    The separator objects (isTab: true) lack a value field, which can cause v-model
    binding errors. Add a value: null (or a unique key) to these entries so the select
    control can render without misbinding.

    web/src/components/dashboards/settings/AddSettingVariable.vue [797-806]

     const groupedPanelsOptions = computed(() => {
       return dashboardData.value.tabs
         .filter((tab: any) => selectedTabs.value.includes(tab.tabId))
         .flatMap((tab: any) => [
    -      { label: tab.name, isTab: true },
    +      { label: tab.name, isTab: true, value: null },
           ...(tab.panels || []).map((panel: any) => ({
             label: panel.title,
             value: panel.id,
           })),
         ]);
     });
    Suggestion importance[1-10]: 4

    __

    Why: Adding a value to the separator items prevents potential binding mismatches in the q-select, but it’s a minor fix that doesn’t block functionality.

    Low
    Remove incorrect event binding

    The @update:model-value="updatePanels" on the tabs select is misleading, since it’s
    meant to refresh panels, not tabs. Remove this event listener and rely on the
    existing watcher on selectedTabs to trigger updatePanels.

    web/src/components/dashboards/settings/AddSettingVariable.vue [583-603]

     <q-select
       hint="Variables will be available only in the selected tabs."
       v-model="selectedTabs"
       :options="tabsOptions"
       label="Select tabs"
       multiple
       stack-label
       outlined
       dense
       emit-value
       map-options
    -  @update:model-value="updatePanels"
       filled
       input-debounce="0"
       behavior="menu"
       use-input
       class="showLabelOnTop"
       popup-no-route-dismiss
       popup-content-style="z-index: 10001"
       data-test="dashboard-variable-tabs-select"
     >
    Suggestion importance[1-10]: 3

    __

    Why: The @update:model-value="updatePanels" on the tabs select is redundant given the existing watcher and can be safely removed to avoid confusion.

    Low

    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch 2 times, most recently from 5c8b39a to 737b5a7 Compare August 5, 2025 09:20
    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch from 737b5a7 to adc1ebe Compare August 8, 2025 06:33
    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch 2 times, most recently from 79b664c to 724eb21 Compare September 17, 2025 09:07
    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch 2 times, most recently from c36c676 to 1f8f009 Compare October 13, 2025 09:25
    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: ktx-vaidehi | Branch: feat/dashboard/variables-using-tabs-panels | Commit: 1f8f009

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    1 test failed 81 76 1 2 2 94% 24m 10s

    Test Failure Analysis

    1. alerts-import.spec.js: Visibility assertion failure due to multiple matching elements
      1. Alerts Import/Export Destination Import from URL and File: 'Successfully imported' resolved to 2 elements, causing strict mode violation.

    Root Cause Analysis

    • The recent changes in VariablesValueSelector.vue may have introduced multiple notifications that conflict with the visibility assertion in the test.

    Recommended Actions

    1. Modify the test to specify a more unique text or selector to avoid ambiguity in alerts-import.spec.js. 2. Review the logic in VariablesValueSelector.vue to ensure only one notification is displayed for successful imports. 3. Implement a wait or check for the specific notification type before asserting visibility in the test.

    View Detailed Results

    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch from 1f8f009 to 5f627b4 Compare October 14, 2025 05:39
    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: ktx-vaidehi | Branch: feat/dashboard/variables-using-tabs-panels | Commit: 5f627b4

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    1 test failed 323 295 1 17 10 91% 4m 59s

    Test Failure Analysis

    1. dashboard-variables-setting.spec.js: Timeout errors due to element visibility and stability issues
      1. dashboard variables settings should verify that hide on constant variable dashboard is working: Element '[data-test="dashboard-settings-close-btn"]' not stable, causing click timeout.

    Root Cause Analysis

    • The recent changes in VariablesValueSelector.vue may have affected the stability of the dashboard settings close button.

    Recommended Actions

    1. Investigate the visibility and stability of the button '[data-test="dashboard-settings-close-btn"]' in dashboard-settings.js. 2. Increase the timeout duration for the click action in the test to accommodate potential delays. 3. Ensure that the DOM is fully rendered before attempting to click the button in the test.

    View Detailed Results

    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch from 5f627b4 to e560000 Compare October 15, 2025 05:17
    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: ktx-vaidehi | Branch: feat/dashboard/variables-using-tabs-panels | Commit: e560000

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    1 test failed 250 230 1 15 4 92% 4m 32s

    Test Failure Analysis

    1. dashboard-variables-setting.spec.js: Timeout issues while interacting with elements
      1. dashboard variables settings should verify textbox variable by adding and verify that its visible on dashboard: Locator timeout - button[data-test="dashboard-settings-close-btn"] not stable and detached from DOM.

    Root Cause Analysis

    • The recent changes in VariablesValueSelector.vue may have affected the stability of the dashboard settings close button, leading to timeout errors.

    Recommended Actions

    1. Investigate the stability of the button with data-test="dashboard-settings-close-btn" in VariablesValueSelector.vue. 2. Increase the timeout duration for click actions in dashboard-variables-setting.spec.js. 3. Ensure that the button is not detached from the DOM during the test execution.

    View Detailed Results

    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: ktx-vaidehi | Branch: feat/dashboard/variables-using-tabs-panels | Commit: bfa4c5b

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    1 test failed 157 141 1 8 7 90% 3m 2s

    Test Failure Analysis

    1. dashboard.spec.js: Assertion failure due to incorrect data count in chart
      1. dashboard UI testcases should update the line chart correctly when used camel case in custom sql query: Expected canvas count to be greater than 0 but received 0.

    Root Cause Analysis

    • The changes in web/.../dashboards/[VUE] VariablesValueSelector.vue may have affected the data flow, resulting in a canvas count of 0.

    Recommended Actions

    1. Review the data fetching logic in web/.../dashboards/[VUE] VariablesValueSelector.vue to ensure it populates the canvas correctly.
    2. Add additional logging in the data processing functions to trace the data flow and identify where the count becomes 0.
    3. Validate the SQL query used in the test to ensure it returns the expected results when using camel case.

    View Detailed Results

    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: Shrinath Rao | Branch: feat/dashboard/variables-using-tabs-panels | Commit: 2981c40

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    3 tests failed 231 212 3 14 2 92% 4m 44s

    Test Failure Analysis

    1. dashboard-variables-setting.spec.js: All tests failed due to timeout errors on element interactions
      1. dashboard variables settings should verify that hide on textbox variable dashboard is working: Timeout while clicking close button, element unstable.
      2. dashboard variables settings should verify textbox variable by adding and verify that its visible on dashboard: Timeout while clicking close button, element unstable.
      3. dashboard variables settings should verify that hide on constant variable dashboard is working: Timeout while clicking close button, element unstable.

    Root Cause Analysis

    • The failures are likely related to the changes in dashboard settings interactions in dashboard-settings.js.

    Recommended Actions

    1. Investigate the stability of the element with data-test="dashboard-settings-close-btn" in dashboard-settings.js. 2. Increase the timeout duration for the click actions in the tests to accommodate potential delays. 3. Ensure the element is present and stable before attempting to click, possibly by adding explicit waits.

    View Detailed Results

    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch from 2981c40 to 5a3c91a Compare October 28, 2025 04:43
    @testdino-playwright-reporter
    Copy link

    ⚠️ Test Run Unstable


    Author: ktx-vaidehi | Branch: feat/dashboard/variables-using-tabs-panels | Commit: 5a3c91a

    Testdino Test Results

    Status Total Passed Failed Skipped Flaky Pass Rate Duration
    3 tests failed 140 128 3 6 3 91% 4m 28s

    Test Failure Analysis

    1. dashboard-variables-setting.spec.js: All tests fail due to timeout issues with element visibility
      1. dashboard variables settings should verify that hide on textbox variable dashboard is working: Timeout waiting for button[data-test="dashboard-settings-close-btn"] to be clickable.
      2. dashboard variables settings should verify textbox variable by adding and verify that its visible on dashboard: Timeout waiting for button[data-test="dashboard-settings-close-btn"] to be clickable.
      3. dashboard variables settings should verify that hide on constant variable dashboard is working: Timeout waiting for button[data-test="dashboard-settings-close-btn"] to be clickable.

    Root Cause Analysis

    • The recent changes in VariablesValueSelector.vue may have introduced instability in the dashboard settings UI, causing timeouts.

    Recommended Actions

    1. Investigate the stability of the button[data-test="dashboard-settings-close-btn"] in the DOM during test execution. 2. Add explicit waits or checks for visibility before attempting clicks in dashboard-variables-setting.spec.js. 3. Review the logic in VariablesValueSelector.vue to ensure it does not interfere with UI rendering.

    View Detailed Results

    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch 5 times, most recently from 1220aca to 3a16c81 Compare November 4, 2025 09:45
    : variable.value;

    const placeholders = [
    `\${${variable.name}}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI 1 day ago

    To fix the problem, the code that escapes $, {, and } in the placeholders before constructing a RegExp pattern should use double backslashes ("\\$") in the replacement strings, so that the resultant string has a literal backslash before the meta-character, making it a valid RegExp escape inside the RegExp constructor.

    Edit lines 248, 249, and 250 in web/src/utils/dashboard/variables/variablesUtils.ts:

    • Change .replace(/\$/g, "\\$") to .replace(/\$/g, "\\\$")
    • Change .replace(/\{/g, "\\{") to .replace(/\{/g, "\\{") (unchanged, since { needs a single backslash and this is correct)
    • Change .replace(/\}/g, "\\}") to .replace(/\}/g, "\\}") (unchanged, since } needs a single backslash and this is correct)

    But wait: Are { and } escaping correct? The same logic applies—when building RegExp pattern strings, it is best to use double backslashes for escaping inside string, which results in a single backslash in the actual RegExp pattern.

    So, change:

    • .replace(/\$/g, "\\$") to .replace(/\$/g, "\\\$")
    • .replace(/\{/g, "\\{") to .replace(/\{/g, "\\\{")
    • .replace(/\}/g, "\\}") to .replace(/\}/g, "\\\}")

    This will ensure that the resulting RegExp pattern string has escaped characters for $, {, and } as needed to safely and literally match the placeholder strings.

    No imports or additional dependencies are required.


    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -245,9 +245,9 @@
           processedContent = processedContent.replace(
             new RegExp(
               placeholder
    -            .replace(/\$/g, "\\$")
    -            .replace(/\{/g, "\\{")
    -            .replace(/\}/g, "\\}"),
    +            .replace(/\$/g, "\\\$")
    +            .replace(/\{/g, "\\\{")
    +            .replace(/\}/g, "\\\}"),
               "g",
             ),
             value,
    EOF
    @@ -245,9 +245,9 @@
    processedContent = processedContent.replace(
    new RegExp(
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),
    .replace(/\$/g, "\\\$")
    .replace(/\{/g, "\\\{")
    .replace(/\}/g, "\\\}"),
    "g",
    ),
    value,
    Copilot is powered by AI and may make mistakes. Always verify output.

    const placeholders = [
    `\${${variable.name}}`,
    `\${${variable.name}:csv}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI 1 day ago

    To fix the problem, ensure that meta-characters $, {, and } are properly escaped when building a RegExp from a string literal. In JavaScript, this means using double backslashes in string literals so that the final string fed to new RegExp has a single backslash, as required by RegExp syntax. This affects lines 248-250:

    • Replace .replace(/\$/g, "\\$") with .replace(/\$/g, "\\\$")
    • Replace .replace(/\{/g, "\\{") with .replace(/\{/g, "\\{") (curly brace does not always need escaping unless used in quantifiers, but generally safe to escape as \\{)
    • Replace .replace(/\}/g, "\\}") with .replace(/\}/g, "\\}") (same as above)

    The most important fix is to ensure that $ is properly escaped as \\$ (string literal), resulting in a single \$ in the RegExp.

    Additionally, if any other characters with special meaning in RegExp (like ., *, ^, $, +, ?, (, ), [, ], {, }, |, \) could appear in the variable names or placeholders, consider a generic escape approach (using a utility like escapeRegExp). However, as per the snippet, only $, {, and } are targeted.

    No new imports are required; this can be implemented with string replace.


    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -245,7 +245,7 @@
           processedContent = processedContent.replace(
             new RegExp(
               placeholder
    -            .replace(/\$/g, "\\$")
    +            .replace(/\$/g, "\\\$")
                 .replace(/\{/g, "\\{")
                 .replace(/\}/g, "\\}"),
               "g",
    EOF
    @@ -245,7 +245,7 @@
    processedContent = processedContent.replace(
    new RegExp(
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\$/g, "\\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),
    "g",
    Copilot is powered by AI and may make mistakes. Always verify output.
    const placeholders = [
    `\${${variable.name}}`,
    `\${${variable.name}:csv}`,
    `\${${variable.name}:pipe}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI about 8 hours ago

    The best way to fix the problem is to remove the unnecessary backslash before $ in the string literal on line 224 (\$${variable.name}). Change it to $${variable.name} so the string matches the dollar sign literally, as intended, without a redundant escape that only makes the code harder to read and possibly misleading.

    Make this change only in the construction of the placeholders array, specifically on line 224. No other changes, imports, or definitions are required.


    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -221,7 +221,7 @@
           `\${${variable.name}:pipe}`,
           `\${${variable.name}:doublequote}`,
           `\${${variable.name}:singlequote}`,
    -      `\$${variable.name}`,
    +      `$${variable.name}`,
         ];
     
         placeholders.forEach((placeholder) => {
    EOF
    @@ -221,7 +221,7 @@
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,
    `\$${variable.name}`,
    `$${variable.name}`,
    ];

    placeholders.forEach((placeholder) => {
    Copilot is powered by AI and may make mistakes. Always verify output.
    `\${${variable.name}}`,
    `\${${variable.name}:csv}`,
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI about 8 hours ago

    To fix the problem, remove the unnecessary backslash from the dollar sign in the placeholder template on line 224 ('\$''$'). This ensures the placeholder string is actually as intended ($variable), and any required escaping for the RegExp string pattern is correctly accomplished by the subsequent replacement step (which replaces all $ with \\$). Only the line constructing the placeholders array needs to be updated in web/src/utils/dashboard/variables/variablesUtils.ts, changing the fifth item (line 224) to use a plain dollar sign. No other changes or imports are required.

    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -221,7 +221,7 @@
           `\${${variable.name}:pipe}`,
           `\${${variable.name}:doublequote}`,
           `\${${variable.name}:singlequote}`,
    -      `\$${variable.name}`,
    +      `$${variable.name}`,
         ];
     
         placeholders.forEach((placeholder) => {
    EOF
    @@ -221,7 +221,7 @@
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,
    `\$${variable.name}`,
    `$${variable.name}`,
    ];

    placeholders.forEach((placeholder) => {
    Copilot is powered by AI and may make mistakes. Always verify output.
    `\${${variable.name}:csv}`,
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI 1 day ago

    To fix the problem, remove the unnecessary backslash escaping in the placeholder string on line 224, changing \$${variable.name} to simply $${variable.name}. Since the code that generates the RegExp pattern string already escapes $ characters on line 248 via .replace(/\$/g, "\\$"), the literal $ will be properly handled in the final RegExp pattern. No other changes are needed, as the escaping logic after this will ensure correctness in the final regular expression. Edit line 224 in web/src/utils/dashboard/variables/variablesUtils.ts, replacing \$${variable.name}, with $${variable.name},.

    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -221,7 +221,7 @@
           `\${${variable.name}:pipe}`,
           `\${${variable.name}:doublequote}`,
           `\${${variable.name}:singlequote}`,
    -      `\$${variable.name}`,
    +      `$${variable.name}`,
         ];
     
         placeholders.forEach((placeholder) => {
    EOF
    @@ -221,7 +221,7 @@
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,
    `\$${variable.name}`,
    `$${variable.name}`,
    ];

    placeholders.forEach((placeholder) => {
    Copilot is powered by AI and may make mistakes. Always verify output.
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,
    `\$${variable.name}`,

    Check failure

    Code scanning / CodeQL

    Useless regular-expression character escape High

    The escape sequence '$' is equivalent to just '$', so the sequence may still represent a meta-character when it is used in a
    regular expression
    .

    Copilot Autofix

    AI 1 day ago

    To fix this issue, we should remove the unnecessary escape character before $ in the placeholder string array on line 224. That is, change \$${variable.name} to $${variable.name} in the placeholders array.
    This fix should be made directly at the array construction, as the subsequent code already ensures the correct escaping of $ when building the regular expression pattern. No other code, imports, or refactoring is required.
    Change the file web/src/utils/dashboard/variables/variablesUtils.ts, line 224:

    • from: \${variable.name}
    • to: $${variable.name}

    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -221,7 +221,7 @@
           `\${${variable.name}:pipe}`,
           `\${${variable.name}:doublequote}`,
           `\${${variable.name}:singlequote}`,
    -      `\$${variable.name}`,
    +      `$${variable.name}`,
         ];
     
         placeholders.forEach((placeholder) => {
    EOF
    @@ -221,7 +221,7 @@
    `\${${variable.name}:pipe}`,
    `\${${variable.name}:doublequote}`,
    `\${${variable.name}:singlequote}`,
    `\$${variable.name}`,
    `$${variable.name}`,
    ];

    placeholders.forEach((placeholder) => {
    Copilot is powered by AI and may make mistakes. Always verify output.
    Comment on lines +247 to +250
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),

    Check failure

    Code scanning / CodeQL

    Incomplete string escaping or encoding High

    This does not escape backslash characters in the input.

    Copilot Autofix

    AI 1 day ago

    The best fix is to properly escape all RegExp special characters when building a regex from any user-controlled or dynamic string. The standard way to do this is to use a function that escapes all special regex meta-characters—including backslash—in the placeholder string before passing it to new RegExp. This is best achieved by defining an escapeRegExp helper function, such as:

    function escapeRegExp(string: string): string {
      return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    }

    Then, replace the current manual escaping with a call to this helper. This change should be made only within the region where the RegExp is constructed—specifically, replace the chained .replace statements on lines 248–250 with a call to escapeRegExp.

    Add the new helper function at an appropriate location in the file (often at the top or with other utilities).


    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -1,3 +1,8 @@
    +// Utility to escape regex special characters in a dynamic string
    +function escapeRegExp(string: string): string {
    +  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    +}
    +
     export const formatInterval = (interval: any) => {
       switch (true) {
         // 0.01s
    @@ -244,10 +249,7 @@
     
           processedContent = processedContent.replace(
             new RegExp(
    -          placeholder
    -            .replace(/\$/g, "\\$")
    -            .replace(/\{/g, "\\{")
    -            .replace(/\}/g, "\\}"),
    +          escapeRegExp(placeholder),
               "g",
             ),
             value,
    EOF
    @@ -1,3 +1,8 @@
    // Utility to escape regex special characters in a dynamic string
    function escapeRegExp(string: string): string {
    return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    }

    export const formatInterval = (interval: any) => {
    switch (true) {
    // 0.01s
    @@ -244,10 +249,7 @@

    processedContent = processedContent.replace(
    new RegExp(
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),
    escapeRegExp(placeholder),
    "g",
    ),
    value,
    Copilot is powered by AI and may make mistakes. Always verify output.
    Comment on lines +247 to +249
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")

    Check failure

    Code scanning / CodeQL

    Incomplete string escaping or encoding High

    This does not escape backslash characters in the input.

    Copilot Autofix

    AI 1 day ago

    The best way to fix the issue is to robustly escape all RegExp meta-characters in the dynamic placeholder string before using it in new RegExp(placeholder, "g"). The core issue is that the code currently uses a series of replace calls to escape certain characters, but misses escaping the backslash itself and any other RegExp special characters. The most robust solution is to use a well-tested escape function, such as escape-string-regexp from npm. Since we may only edit code we've been shown, we can safely add a well-known minimal helper function for escaping RegExp special characters.

    For this file, add a local utility function escapeRegExp above this block, and then use it to escape placeholder before passing to RegExp. Remove the custom .replace(/\$/g, "\\$").replace(/\{/g, ...) logic and instead use escapeRegExp(placeholder).

    No external npm dependencies are required for the minimal robust escape function. Only this region (lines 245-253) is changed, with the helper inserted earlier in the file.

    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -1,3 +1,9 @@
    +// Escapes special characters for use in a regular expression
    +function escapeRegExp(string: string): string {
    +  // From MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
    +  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    +}
    +
     export const formatInterval = (interval: any) => {
       switch (true) {
         // 0.01s
    @@ -244,10 +250,7 @@
     
           processedContent = processedContent.replace(
             new RegExp(
    -          placeholder
    -            .replace(/\$/g, "\\$")
    -            .replace(/\{/g, "\\{")
    -            .replace(/\}/g, "\\}"),
    +          escapeRegExp(placeholder),
               "g",
             ),
             value,
    EOF
    @@ -1,3 +1,9 @@
    // Escapes special characters for use in a regular expression
    function escapeRegExp(string: string): string {
    // From MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
    return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    }

    export const formatInterval = (interval: any) => {
    switch (true) {
    // 0.01s
    @@ -244,10 +250,7 @@

    processedContent = processedContent.replace(
    new RegExp(
    placeholder
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),
    escapeRegExp(placeholder),
    "g",
    ),
    value,
    Copilot is powered by AI and may make mistakes. Always verify output.
    Comment on lines +247 to +248
    placeholder
    .replace(/\$/g, "\\$")

    Check failure

    Code scanning / CodeQL

    Incomplete string escaping or encoding High

    This does not escape backslash characters in the input.

    Copilot Autofix

    AI 1 day ago

    The best way to fix the problem is to ensure that all occurrences of backslash in the placeholder string are escaped before constructing the dynamic regular expression. This can be done by adding a .replace(/\\/g, "\\\\") call to the chain before the other replacements. Thus, the code should replace placeholder's backslashes to double backslashes, so that the resulting regex is correct. The fix is limited to the region of lines 246-250 in web/src/utils/dashboard/variables/variablesUtils.ts.

    Suggested changeset 1
    web/src/utils/dashboard/variables/variablesUtils.ts

    Autofix patch

    Autofix patch
    Run the following command in your local git repository to apply this patch
    cat << 'EOF' | git apply
    diff --git a/web/src/utils/dashboard/variables/variablesUtils.ts b/web/src/utils/dashboard/variables/variablesUtils.ts
    --- a/web/src/utils/dashboard/variables/variablesUtils.ts
    +++ b/web/src/utils/dashboard/variables/variablesUtils.ts
    @@ -245,6 +245,7 @@
           processedContent = processedContent.replace(
             new RegExp(
               placeholder
    +            .replace(/\\/g, "\\\\")
                 .replace(/\$/g, "\\$")
                 .replace(/\{/g, "\\{")
                 .replace(/\}/g, "\\}"),
    EOF
    @@ -245,6 +245,7 @@
    processedContent = processedContent.replace(
    new RegExp(
    placeholder
    .replace(/\\/g, "\\\\")
    .replace(/\$/g, "\\$")
    .replace(/\{/g, "\\{")
    .replace(/\}/g, "\\}"),
    Copilot is powered by AI and may make mistakes. Always verify output.
    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch 2 times, most recently from a3b1996 to 15117e1 Compare November 5, 2025 10:24
    … management
    
    - Added lazy loading capability to VariablesValueSelector for improved performance.
    - Introduced a new composable `useVariablesLoadingManager` to handle cascade decisions and dependency resolution.
    - Updated RenderDashboardCharts.vue to support lazy loading for both global and tab-level variables.
    - Implemented visibility tracking for panels to trigger loading of variables only when needed.
    - Enhanced logging for better debugging and tracking of variable updates and dependencies.
    @ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/variables-using-tabs-panels branch from ea4daeb to 0d3bed4 Compare November 5, 2025 13:08
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants