feat(query): auto-keep results by default and fix restore race

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-10 15:57:27 +08:00
1 parent 5b5d58cd2a
commit e0cc787f0a
19 files changed
+231 -17

No files matched your search

@@ -194,7 +194,7 @@ export function serializeOpenTabs(tabs: QueryTab[]): SavedOpenTab[] {
}
: {}),
...(tab.mode === "query" && tab.activeResultRunId !== undefined ? { activeResultRunId: tab.activeResultRunId } : {}),
...(tab.mode === "query" && tab.resultAutoSave ? { resultAutoSave: true } : {}),
...(tab.mode === "query" && typeof tab.resultAutoSave === "boolean" ? { resultAutoSave: tab.resultAutoSave } : {}),
}));
}
@@ -245,7 +245,7 @@ function restoreOpenTabsArray(parsed: unknown, rawActiveTabId: string | null, op
resultCacheState: mode !== "data" && tab.resultCacheKey ? "disk" : undefined,
resultRuns,
activeResultRunId: resultRuns?.some((run) => run.id === tab.activeResultRunId) ? tab.activeResultRunId : resultRuns?.[0]?.id,
resultAutoSave: mode === "query" && tab.resultAutoSave ? true : undefined,
resultAutoSave: mode === "query" && typeof tab.resultAutoSave === "boolean" ? tab.resultAutoSave : undefined,
};
});
const activeTabId = rawActiveTabId || null;
@@ -52,6 +52,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"dataGridFilterEditorView",
"dataGridKeepFilterEditorExpanded",
"dataGridTextFilterPanelHeight",
"defaultAutoKeepResults",
"multiStatementDefaultView",
"dataGridAutoTransposeSingleRow",
"dataGridCellDetailButtonVisible",
@@ -194,6 +194,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
{ id: "navigation-disconnect-tabs", category: "navigation", titleKey: "settings.disconnectTabHandlingMode", descriptionKey: "settings.disconnectTabHandlingModeDescription", targetId: "navigation" },
{ id: "query-page-size", category: "data", titleKey: "settings.queryPageSize", descriptionKey: "settings.queryPageSizeDescription", targetId: "data" },
{ id: "data-page-size", category: "data", titleKey: "settings.tableOpenPageSize", descriptionKey: "settings.tableOpenPageSizeDescription", targetId: "data" },
{ id: "default-auto-keep-results", category: "data", titleKey: "settings.defaultAutoKeepResults", descriptionKey: "settings.defaultAutoKeepResultsDescription", targetId: "default-auto-keep-results" },
{ id: "multi-statement-default-view", category: "data", titleKey: "settings.multiStatementDefaultView", descriptionKey: "settings.multiStatementDefaultViewDescription", targetId: "multi-statement-default-view" },
{ id: "query-result-max-rows", category: "data", titleKey: "settings.queryResultMaxRows", descriptionKey: "settings.queryResultMaxRowsDescription", targetId: "data" },
{ id: "data-grid-header-comments", category: "data", titleKey: "settings.showColumnCommentsInHeader", descriptionKey: "settings.showColumnCommentsInHeaderDescription", targetId: "data" },
@@ -143,6 +143,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
"dataGridFilterEditorView",
"dataGridKeepFilterEditorExpanded",
"dataGridTextFilterPanelHeight",
"defaultAutoKeepResults",
"multiStatementDefaultView",
"dataGridAutoTransposeSingleRow",
"dataGridCellDetailButtonVisible",