feat(tabs): show table comments in tab tooltips

Closes #8342
This commit is contained in:
t8y2 committed 2026-09-07 14:10:16 +08:00
1 parent c0c97ef0e4
commit 5f81ed2e11
21 files changed
+75 -11

No files matched your search

@@ -202,16 +202,24 @@ describe("useSidebarDataOpenRuntime", () => {
it("reuses a sidebar tab for the same table in same-table mode", async () => {
mocks.openDataTabsNextToActive = true;
await useSidebarDataOpenRuntime().openData(tableNode);
await useSidebarDataOpenRuntime().openData(tableNode);
await useSidebarDataOpenRuntime().openData({ ...tableNode, comment: "Old comment" });
await useSidebarDataOpenRuntime().openData({ ...tableNode, comment: "Updated comment" });
expect(mocks.tabs).toHaveLength(1);
expect(mocks.tabs[0]?.tableComment).toBe("Updated comment");
});
it("copies the existing sidebar table comment without another metadata request", async () => {
await useSidebarDataOpenRuntime().openData({ ...tableNode, comment: "Application users" });
expect(mocks.tabs[0]?.tableComment).toBe("Application users");
expect(mocks.loadTableMetadata).toHaveBeenCalledTimes(1);
});
it("keeps different sidebar tables independent in same-table mode", async () => {
const ordersNode = { ...tableNode, id: "table-orders", label: "orders" };
await useSidebarDataOpenRuntime().openData(tableNode);
await useSidebarDataOpenRuntime().openData({ ...tableNode, comment: "User table" });
await useSidebarDataOpenRuntime().openData(ordersNode);
expect(mocks.tabs).toHaveLength(2);
@@ -270,6 +278,7 @@ describe("useSidebarDataOpenRuntime", () => {
expect(mocks.tabs).toHaveLength(1);
expect(mocks.tabs[0]?.title).toBe("orders");
expect(mocks.tabs[0]?.tableComment).toBeUndefined();
expect(mocks.tabs[0]?.tableMeta?.tableName).toBe("orders");
expect(mocks.tabs[0]?.resultLocalSortOriginalLargeValueCells).toBeUndefined();
});
@@ -22,6 +22,7 @@ export type NavigationTarget = {
schema?: string;
tableName: string;
tableType?: string;
comment?: string | null;
columnName?: string;
whereInput?: string;
};
@@ -72,7 +73,10 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
}
const tabId = queryStore.createTab(target.connectionId, target.database, tabTitle, "data", tableSchema, undefined, undefined, { forceNew: true });
const targetTab = queryStore.tabs.find((tab) => tab.id === tabId);
if (targetTab) targetTab.tableInfoTab = options.tableInfoTab;
if (targetTab) {
targetTab.tableInfoTab = options.tableInfoTab;
targetTab.tableComment = target.comment;
}
// Stamp the new table identity synchronously so SQL rebuilds (refresh,
// filters, row count) never read a stale tableMeta from a reused tab or
// fall back to parsing the schema-qualified tab title (issue #3613).
@@ -339,6 +343,7 @@ export function useNavigationTargets(dialogs: { showFieldLineageDialog: { value:
schema: target.schema,
catalog: target.catalog,
tableType: target.tableType,
comment: target.comment,
},
undefined,
"default",
@@ -173,6 +173,7 @@ export function useSidebarDataOpenRuntime() {
};
if (existingSameTableTab && (existingSameTableTab.isExecuting || canActivateExistingDataTableTab(existingSameTableTab, { activateExecuting: false }))) {
if (node.comment !== undefined) existingSameTableTab.tableComment = node.comment;
queryStore.switchTab(existingSameTableTab.id);
logPhase("existing-tab-activated", { table: node.label });
// 代次失配视同冷缓存(即使位于 30s TTL 窗口内也要重建):disconnect /
@@ -192,12 +193,16 @@ export function useSidebarDataOpenRuntime() {
if (existingDataTabCandidate) {
queryStore.switchTab(existingDataTabCandidate.tab.id);
resetReusedDataTabState(existingDataTabCandidate.tab);
existingDataTabCandidate.tab.tableComment = node.comment;
return existingDataTabCandidate.tab.id;
}
return queryStore.createTab(node.connectionId, node.database, node.label, "data", tableSchema, undefined, node.catalog, {
const createdTabId = queryStore.createTab(node.connectionId, node.database, node.label, "data", tableSchema, undefined, node.catalog, {
forceNew: true,
insertAfterActive: settingsStore.editorSettings.openDataTabsNextToActive,
});
const createdTab = queryStore.tabs.find((tab) => tab.id === createdTabId);
if (createdTab) createdTab.tableComment = node.comment;
return createdTabId;
})();
openDataLog("info", "tab-created", { traceId, tabId, elapsed: elapsed() });
logPhase("tab-created", { tabId });