bito-code-review[bot] commented on code in PR #38410:
URL: https://github.com/apache/superset/pull/38410#discussion_r2891387332
##########
superset/mcp_service/dashboard/tool/generate_dashboard.py:
##########
@@ -138,6 +138,40 @@ def _create_dashboard_layout(chart_objects: List[Any]) ->
Dict[str, Any]:
return layout
+_MAX_TITLE_LENGTH = 150
+
+
+def _generate_title_from_charts(chart_objects: List[Any]) -> str:
+ """
+ Build a descriptive dashboard title from the included chart names.
+
+ Joins up to three chart ``slice_name`` values with " & " (two charts)
+ or ", " (three charts). When there are more than three charts the
+ remaining count is appended as "+ N more". The result is capped at
+ ``_MAX_TITLE_LENGTH`` characters.
+
+ Returns ``"Dashboard"`` when *chart_objects* is empty or no chart has
+ a usable name.
+ """
+ names = [c.slice_name for c in chart_objects if getattr(c, "slice_name",
None)]
+ if not names:
+ return "Dashboard"
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing i18n for user-facing text</b></div>
<div id="fix">
The fallback dashboard title 'Dashboard' appears user-facing and should be
wrapped with the translation function _() to support internationalization,
matching repository patterns seen in superset/views/dashboard/mixin.py.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
- from typing import Any, Dict, List
+ from typing import Any, Dict, List
+ from flask_babel import lazy_gettext as _
@@ -158,1 +158,1 @@
- return "Dashboard"
+ return _("Dashboard")
```
</div>
</details>
</div>
<small><i>Code Review Run #e11f7a</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]