Skip to content

fix: query tab title incorrectly shows table name after execution (#668)#670

Merged
datlechin merged 1 commit intomainfrom
fix/query-tab-title
Apr 11, 2026
Merged

fix: query tab title incorrectly shows table name after execution (#668)#670
datlechin merged 1 commit intomainfrom
fix/query-tab-title

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Fix query tab's window title changing to the executed table name, which also breaks sidebar table navigation.

Closes #668

Root Cause

updateWindowTitleAndFileState() used selectedTab?.tableName as the window title regardless of tab type. After SELECT * FROM users, tableName = "users" is set (needed for edit support), but the window title also became "users".

This caused openTableTab's window dedup check (window.title == tableName) to match the query tab, preventing new table tabs from opening.

Fix

One line: guard tableName usage on tabType == .table. Query tabs use tab.title ("Query 1") as the window title.

// Before:
windowTitle = selectedTab?.tableName ?? ...

// After:
windowTitle = (selectedTab?.tabType == .table ? selectedTab?.tableName : nil)
    ?? selectedTab?.title ?? ...

Test plan

  • Execute SELECT * FROM users in query tab: window title stays "Query 1" (not "users")
  • Click "users" in sidebar: opens new table tab (not switches to query tab)
  • Open table tab for "users": window title shows "users"
  • ER Diagram tab: window title shows "ER Diagram"
  • Create Table tab: window title shows "Create Table"
  • File-backed query: window title shows filename

Root cause: updateWindowTitleAndFileState() used tab.tableName as the
window title for ALL tab types. After executing SELECT * FROM users,
tableName="users" was set (correct for edit support), but the window
title also became "users" instead of "Query 1".

This caused sidebar "open table" to match the query tab's window by
title, switching to it instead of opening a new table tab.

Fix: only use tableName as window title for .table tabs. For .query
tabs, use tab.title (the stable display name like "Query 1").
@datlechin datlechin merged commit 63bad40 into main Apr 11, 2026
2 checks passed
@datlechin datlechin deleted the fix/query-tab-title branch April 11, 2026 09:32
@datlechin datlechin restored the fix/query-tab-title branch April 11, 2026 09:35
@datlechin datlechin deleted the fix/query-tab-title branch April 11, 2026 10:05
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.

query tab name incorrect

1 participant