Skip to content

fix(mcp): honor target_tab parameter when adding charts to tabbed dashboards#38372

Closed
aminghadersohi wants to merge 1 commit intoapache:masterfrom
aminghadersohi:amin/ch100339/fix-target-tab-placement
Closed

fix(mcp): honor target_tab parameter when adding charts to tabbed dashboards#38372
aminghadersohi wants to merge 1 commit intoapache:masterfrom
aminghadersohi:amin/ch100339/fix-target-tab-placement

Conversation

@aminghadersohi
Copy link
Contributor

SUMMARY

When adding charts to a dashboard that uses tabs via the add_chart_to_existing_dashboard MCP tool, the target_tab parameter was accepted without error but completely ignored. Charts were always placed in the first tab or under GRID_ID at the root level, where they become invisible ghost entries — registered in the dashboard metadata but never rendered in the UI.

Root cause: _find_tab_insert_target() always returned the first TAB child and the request.target_tab value was never passed to it.

Fix: _find_tab_insert_target() now accepts an optional target_tab parameter and resolves it by matching against the tab display name (meta.text) or the raw component ID. When no match is found it falls back to the first tab to preserve backward compatibility.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend logic change, no UI modifications.

TESTING INSTRUCTIONS

  1. Create a dashboard with multiple tabs (e.g., "Activity Metrics", "Customers")
  2. Call add_chart_to_existing_dashboard with target_tab set to the second tab's name
  3. Verify the chart appears inside the specified tab (not the first tab, and not invisible under GRID_ID)
  4. Call without target_tab — chart should still land in the first tab (backward compat)

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

…hboards

The target_tab parameter on add_chart_to_existing_dashboard was accepted
but silently ignored, causing charts to always land in the first tab (or
under GRID_ID where they become invisible).  _find_tab_insert_target now
resolves target_tab by display name or component ID before falling back
to the first tab.
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 4, 2026

Code Review Agent Run #1ddbaa

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 4f1ef5a..4f1ef5a
    • superset/mcp_service/dashboard/tool/add_chart_to_existing_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_generation.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the dashboard:tab Related to the usage of tabs in the Dashboard label Mar 4, 2026
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.08%. Comparing base (983b633) to head (4f1ef5a).
⚠️ Report is 22 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #38372      +/-   ##
==========================================
+ Coverage   64.30%   65.08%   +0.78%     
==========================================
  Files        1811     2484     +673     
  Lines       71557   124131   +52574     
  Branches    22810    28845    +6035     
==========================================
+ Hits        46015    80792   +34777     
- Misses      25542    41923   +16381     
- Partials        0     1416    +1416     
Flag Coverage Δ
hive 41.28% <ø> (?)
mysql 64.31% <ø> (?)
postgres 64.38% <ø> (?)
presto 41.30% <ø> (?)
python 66.13% <ø> (?)
sqlite 63.98% <ø> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi
Copy link
Contributor Author

Reopening with a clean branch name.

@aminghadersohi aminghadersohi deleted the amin/ch100339/fix-target-tab-placement branch March 4, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:tab Related to the usage of tabs in the Dashboard size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant