bito-code-review[bot] commented on code in PR #38277:
URL: https://github.com/apache/superset/pull/38277#discussion_r2894956872


##########
superset/mcp_service/chart/tool/get_chart_preview.py:
##########
@@ -89,19 +89,20 @@ def generate(self) -> ChartPreview | ChartError:
 
 
 class URLPreviewStrategy(PreviewFormatStrategy):
-    """Generate URL-based image preview."""
+    """Generate URL-based preview with explore link."""
 
     def generate(self) -> URLPreview | ChartError:
-        # Screenshot-based URL previews are not supported.
-        # Users should use the explore_url to view the chart interactively,
-        # or use other preview formats like 'ascii', 'table', or 'vega_lite'.
-        return ChartError(
-            error=(
-                "URL-based screenshot previews are not supported. "
-                "Use the explore_url to view the chart interactively, "
-                "or try formats: 'ascii', 'table', or 'vega_lite'."
-            ),
-            error_type="UnsupportedFormat",
+        chart = self.chart
+        if not chart.id:
+            return ChartError(
+                error="URL preview not available for transient charts without 
an ID",
+                error_type="UnsupportedFormat",
+            )
+        explore_url = f"{get_superset_base_url()}/explore/?slice_id={chart.id}"
+        return URLPreview(
+            preview_url=explore_url,
+            width=self.request.width or 800,
+            height=self.request.height or 600,
         )

Review Comment:
   <!-- Bito Reply -->
   Agreed, setting `supports_interaction=True` makes sense for the interactive 
explore link. Here's the updated code snippet:
   
   **superset/mcp_service/chart/tool/get_chart_preview.py**
   ```
   return URLPreview(
               preview_url=explore_url,
               width=self.request.width or 800,
               height=self.request.height or 600,
               supports_interaction=True,
           )
   ```



-- 
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]

Reply via email to