codeant-ai-for-open-source[bot] commented on code in PR #41285:
URL: https://github.com/apache/superset/pull/41285#discussion_r3518588131


##########
superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx:
##########
@@ -94,6 +97,114 @@ const TabTitle = styled.span`
 // Get the user's OS
 const userOS = detectOS();
 
+const newTabTooltip =
+  userOS === 'Windows' ? t('New tab (Ctrl + q)') : t('New tab (Ctrl + t)');
+
+const PlusIcon = (
+  <Icons.PlusOutlined
+    iconSize="l"
+    css={css`
+      vertical-align: middle;
+    `}
+    data-test="add-tab-icon"
+  />
+);
+
+function NewTabButton({ onAddSqlEditor }: { onAddSqlEditor: () => void }) {
+  const [open, setOpen] = useState(false);
+
+  const dropdownItems = useMemo<MenuItemType[]>(() => {
+    if (!open) return [];
+    const primaryItems =
+      menus.getMenu(ViewLocations.sqllab.newTab)?.primary ?? [];
+    return [
+      {
+        key: 'sql-editor',
+        label: t('SQL Editor'),
+        icon: <Icons.TableOutlined iconSize="m" />,
+        onClick: () => {
+          setOpen(false);
+          onAddSqlEditor();
+        },
+      },
+      ...primaryItems.flatMap(item => {
+        const command = commands.getCommand(item.command);
+        if (!command) {
+          // An extension contributed this menu item but its command isn't
+          // registered (load is still pending or failed). Skip it so clicking
+          // can't throw "Command not found" and break the add-tab flow.
+          return [];
+        }
+        const Icon = command.icon
+          ? ((Icons as Record<string, typeof Icons.FileOutlined>)[
+              command.icon
+            ] ?? Icons.FileOutlined)
+          : Icons.FileOutlined;
+        return [
+          {
+            key: command.id,
+            label: command.title ?? item.command,
+            icon: <Icon iconSize="m" />,
+            onClick: () => {
+              setOpen(false);
+              commands.executeCommand(item.command);

Review Comment:
   **Suggestion:** The command execution is asynchronous but its returned 
Promise is ignored, so command failures become unhandled promise rejections and 
can leave the add-tab flow in a silent broken state. Handle the Promise 
explicitly (await or catch) and surface failures to the user/logs. [possible 
bug]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   ⚠️ New-tab dropdown uses commands.executeCommand for extension actions.
   ❌ Failing command callbacks produce unhandled promise rejections, no 
feedback.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Register a SQL Lab extension command contributing a new-tab type under the
   `sqllab.newTab` menu so it appears in the dropdown built from
   `menus.getMenu(ViewLocations.sqllab.newTab)?.primary` in
   `superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx:116-120`.
   
   2. Open SQL Lab and click the `+` new-tab button; the capture-phase handler 
in
   `NewTabButton` at `TabbedSqlEditors/index.tsx:170-192` toggles `open`, 
causing the AntD
   `Dropdown` to render items whose `onClick` handlers are defined in
   `TabbedSqlEditors/index.tsx:145-151`.
   
   3. Click the extension-provided tab type; its click handler executes
   `commands.executeCommand(item.command)` at
   `superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx:150` 
without awaiting
   or attaching a `.catch` to the returned Promise from `executeCommand`.
   
   4. If the extension’s registered callback (via `commands.registerCommand` in
   `superset-frontend/src/core/commands/index.ts:29-50`) returns a Promise that 
rejects (for
   example, due to an API failure while creating the tab), the rejection 
surfaces as an
   unhandled Promise rejection from `executeCommand` (defined async in
   `src/core/commands/index.ts:52-61`), producing console-level errors with no 
user-visible
   feedback while the add-tab interaction silently fails.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1ee67b64b8554fe186571c4ec4d721b8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1ee67b64b8554fe186571c4ec4d721b8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx
   **Line:** 150:150
   **Comment:**
        *Possible Bug: The command execution is asynchronous but its returned 
Promise is ignored, so command failures become unhandled promise rejections and 
can leave the add-tab flow in a silent broken state. Handle the Promise 
explicitly (await or catch) and surface failures to the user/logs.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41285&comment_hash=f1ba956a15388bb130b3a496a744d181c16435985b728c94fdfa6d7acded2c92&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41285&comment_hash=f1ba956a15388bb130b3a496a744d181c16435985b728c94fdfa6d7acded2c92&reaction=dislike'>👎</a>



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