Skip to content

Fix AI Insert opening new window when no tabs are open#638

Merged
datlechin merged 1 commit intomainfrom
fix/ai-insert-empty-tabs
Apr 8, 2026
Merged

Fix AI Insert opening new window when no tabs are open#638
datlechin merged 1 commit intomainfrom
fix/ai-insert-empty-tabs

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

When no tabs are open ("No tabs open" empty state) and the user clicks "Insert" on an AI chat code block, it incorrectly opened a new native window tab instead of creating a query tab in the current window. This also caused the right sidebar to switch from AI Chat to Details pane (since new windows initialize with .details as the default).

Root cause: insertQueryFromAI() was missing the empty-tabs check that newTab() already has. When tabManager.tabs is empty, it fell through to WindowOpener.shared.openNativeTab().

Fix: Added else if tabManager.tabs.isEmpty branch that calls tabManager.addTab() directly — matching the existing newTab() pattern.

Test plan

  • Connect to a database, close all tabs → verify "No tabs open" state
  • Open AI Chat in right sidebar, ask a question that returns SQL
  • Click "Insert" on the code block → query tab should open in the same window
  • Right sidebar should remain on AI Chat pane
  • With a query tab already open, Insert should append to existing query
  • With a table tab selected, Insert should open a new native window tab (existing behavior)

@datlechin datlechin merged commit 74a6eb9 into main Apr 8, 2026
2 checks passed
@datlechin datlechin deleted the fix/ai-insert-empty-tabs branch April 8, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant