codeant-ai-for-open-source[bot] commented on code in PR #41285:
URL: https://github.com/apache/superset/pull/41285#discussion_r3498042192
##########
superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx:
##########
@@ -93,6 +96,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);
+ },
+ } as MenuItemType,
+ ];
+ }),
+ ];
+ }, [open, onAddSqlEditor]);
+
+ const activate = useCallback(() => {
+ const primaryItems =
+ menus.getMenu(ViewLocations.sqllab.newTab)?.primary ?? [];
+ if (primaryItems.length === 0) {
+ onAddSqlEditor();
+ } else {
+ setOpen(prev => !prev);
Review Comment:
**Suggestion:** The new add-tab interception path creates tabs without
calling the existing timing marker used by other add-tab entry points, so
add-tab performance telemetry will be missing/inconsistent for “+” button
creations. Call the same timing marker before invoking the add-tab action in
this branch (and the SQL Editor dropdown branch) to keep instrumentation
behavior consistent. [incomplete implementation]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
❌ SQL Lab tab creation telemetry missing for plus-button tabs.
⚠️ Performance metrics inconsistent between keyboard and mouse new tabs.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Render the SQL Lab tab strip via the `TabbedSqlEditors` component in
`superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx:209-380`.
This
component is used as the main SQL Lab tab UI in tests (see
`TabbedSqlEditors.test.tsx:43-47`, which calls `render(<TabbedSqlEditors />,
{ useRedux:
true, initialState })`).
2. Ensure the Redux `sqlLab.queryEditors` array is non-empty so the tabs
render, and note
that the `StyledEditableTabs` instance at `index.tsx:367-377` receives
`addIcon` as
`<NewTabButton onAddSqlEditor={() => newQueryEditor()} />` and
`onEdit={handleEdit}` where
`handleEdit` calls `Logger.markTimeOrigin()` before creating a tab when
`action === 'add'`
(`index.tsx:277-288`).
3. Click the "+" add-tab button in the UI. The native button wrapping
`addIcon` receives
the click, and the `useEffect` hook in `NewTabButton` at `index.tsx:169-191`
adds a
capture-phase `click` listener (`handleActivate`) on that button. This
listener calls
`activate()` and invokes `e.preventDefault()` and `e.stopPropagation()`, so
the underlying
AntD Tabs `onEdit('add')` handler (which calls `Logger.markTimeOrigin()` in
`handleEdit`)
is never reached for this interaction.
4. In `activate()` at `index.tsx:157-165`, when no extensions contribute
`sqllab.newTab`
items (`menus.getMenu(ViewLocations.sqllab.newTab)?.primary ?? []` yields an
empty array),
the code executes the existing snippet:
160 if (primaryItems.length === 0) {
161 onAddSqlEditor();
162 } else {
163 setOpen(prev => !prev);
164 }
`onAddSqlEditor` is the `newQueryEditor` callback defined at
`index.tsx:252-254`, which
simply calls `actions.addNewQueryEditor()` without
`Logger.markTimeOrigin()`. Similarly,
the built-in dropdown item "SQL Editor" in `dropdownItems`
(`index.tsx:120-128`) calls
`onAddSqlEditor()` directly. In contrast, the keyboard shortcut path in
`SqlEditor`
(`superset-frontend/src/SqlLab/components/SqlEditor/index.tsx:12-25`) and
the original
tab-add path in `handleEdit` (`index.tsx:285-288`) both call
`Logger.markTimeOrigin()`
before `addNewQueryEditor()`. As a result, clicking the "+" button or
choosing "SQL
Editor" from its dropdown creates new tabs without updating
`Logger.timeOriginOffset`, so
any performance telemetry relying on `Logger.getTimestamp()` for SQL Lab tab
creation will
be missing or inconsistent compared to keyboard-initiated tab creations.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4d3700a3e41d412ab058c5a846311342&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4d3700a3e41d412ab058c5a846311342&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:** 160:163
**Comment:**
*Incomplete Implementation: The new add-tab interception path creates
tabs without calling the existing timing marker used by other add-tab entry
points, so add-tab performance telemetry will be missing/inconsistent for “+”
button creations. Call the same timing marker before invoking the add-tab
action in this branch (and the SQL Editor dropdown branch) to keep
instrumentation behavior consistent.
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=c952f6b4bd3502aa056970a562006935734037ddb410e357cc444fc0451e78e9&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41285&comment_hash=c952f6b4bd3502aa056970a562006935734037ddb410e357cc444fc0451e78e9&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]