fix(mcp): honor target_tab parameter when adding charts to tabbed dashboards#38409
fix(mcp): honor target_tab parameter when adding charts to tabbed dashboards#38409aminghadersohi wants to merge 4 commits intoapache:masterfrom
Conversation
Code Review Agent Run #46cae8Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
superset/mcp_service/dashboard/tool/add_chart_to_existing_dashboard.py
Outdated
Show resolved
Hide resolved
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
4f1ef5a to
def55b1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #38409 +/- ##
==========================================
+ Coverage 64.82% 64.96% +0.14%
==========================================
Files 1815 2515 +700
Lines 71917 126769 +54852
Branches 22915 29237 +6322
==========================================
+ Hits 46618 82359 +35741
- Misses 25299 42981 +17682
- Partials 0 1429 +1429
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review Agent Run #9001caActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #c68503Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
2f45396 to
77af2d2
Compare
Code Review Agent Run #9e6756Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…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.
Previously the tab selection helper returned the fallback from the first TABS container without searching later groups, causing charts to be placed in the wrong tab when the target only exists in a later group.
Two bugs fixed in add_chart_to_existing_dashboard: 1. Tab search only checked GRID_ID children for TABS components, but Superset dashboards can place TABS under ROOT_ID. Now searches both ROOT_ID and GRID_ID children. 2. Tab name matching was exact-only, failing when tab text contains emoji prefixes (e.g., "🧭 Exploratory"). Added flexible matching that strips emoji and compares case-insensitively.
77af2d2 to
0707512
Compare
There was a problem hiding this comment.
Code Review Agent Run #141bf2
Actionable Suggestions - 1
-
superset/mcp_service/dashboard/tool/add_chart_to_existing_dashboard.py - 1
- Incorrect emoji regex pattern · Line 72-74
Review Details
-
Files reviewed - 2 · Commit Range:
71afcd8..0707512- 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
| r"[\U0001F300-\U0001F9FF\U00002600-\U000027BF\U0000FE00-\U0000FE0F" | ||
| r"\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002702-\U000027B0" | ||
| r"\U0000200D\U0000FE0F]+", |
There was a problem hiding this comment.
The regex in _normalize_tab_text uses incorrect Unicode escape syntax with double backslashes (\\U), which matches literal strings like '\U0001F300' instead of actual emoji characters. This prevents proper emoji stripping for flexible tab matching. The pattern should use single backslashes in a regular string to enable Unicode character matching.
Code suggestion
Check the AI-generated fix before applying
- r"[\\U0001F300-\\U0001F9FF\\U00002600-\\U000027BF\\U0000FE00-\\U0000FE0F"
- r"\\U0001FA00-\\U0001FA6F\\U0001FA70-\\U0001FAFF\\U00002702-\\U000027B0"
- r"\\U0000200D\\U0000FE0F]+",
+ "[\U0001F300-\U0001F9FF\U00002600-\U000027BF\U0000FE00-\U0000FE0F"
+ "\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002702-\U000027B0"
+ "\U0000200D\U0000FE0F]+",
Code Review Run #141bf2
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
User description
SUMMARY
When adding charts to a dashboard that uses tabs via the
add_chart_to_existing_dashboardMCP tool, thetarget_tabparameter was accepted without error but completely ignored. Charts were always placed in the first tab or underGRID_IDat the root level, where they become invisible ghost entries — registered in the dashboard metadata but never rendered in the UI.Root causes fixed:
target_tabwas never passed to_find_tab_insert_target()— the parameter was accepted but silently discarded🧭 Exploratorywouldn't match when user passes"Exploratory", added flexible emoji-stripped case-insensitive matchingBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend logic change, no UI modifications.
TESTING INSTRUCTIONS
add_chart_to_existing_dashboardwithtarget_tabset to the second tab's name (without emoji)target_tab— chart should still land in the first tab (backward compat)ADDITIONAL INFORMATION
MCP Testing (via localhost MCP service on branch
amin/fix-target-tab-placement)Test 1: Target tab with emoji text — "Exploratory" matches "🧭 Exploratory"
get_dashboard_info(6)→ Sales Dashboard has tabs: "🎯 Sales Overview" (TAB-d-E0Zc1cTH) and "🧭 Exploratory" (TAB-4fthLQmdX)add_chart_to_existing_dashboard(dashboard_id=6, chart_id=2, target_tab="Exploratory")["ROOT_ID", "TABS-e5Ruro0cjP", "TAB-4fthLQmdX", ...]— correctly placed in Exploratory tab ✅Test 2: Target tab with emoji text — "Sales Overview" matches "🎯 Sales Overview"
add_chart_to_existing_dashboard(dashboard_id=6, chart_id=3, target_tab="Sales Overview")["ROOT_ID", "TABS-e5Ruro0cjP", "TAB-d-E0Zc1cTH", ...]— correctly placed in Sales Overview tab ✅Test 3: ROOT_ID TABS search (bug found & fixed)
_find_tab_insert_targetonly searched GRID_ID childrenTest 4: Unit tests
pytest tests/unit_tests/mcp_service/dashboard/ -x -q→ 45 passed ✅CodeAnt-AI Description
Honor target_tab when adding charts to tabbed dashboards
What Changed
Impact
✅ Charts land in the intended dashboard tab✅ No more invisible charts under GRID_ID✅ Targeting tabs works with emoji-prefixed tab names💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.