fix(grid): reload restored data tabs from shortcuts

This commit is contained in:
t8y2 committed 2026-07-11 00:17:02 +08:00
1 parent 9cf62a1c71
commit 16d7aef4db
3 files changed
+37 -4

No files matched your search

@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { canReloadUnavailableDataTab } from "@/lib/table/tableDataRefresh";
describe("canReloadUnavailableDataTab", () => {
it("allows restored data tabs to reload before the grid mounts", () => {
expect(canReloadUnavailableDataTab({ mode: "data", result: undefined, isExecuting: false })).toBe(true);
});
it("does not start duplicate or unrelated reloads", () => {
expect(canReloadUnavailableDataTab({ mode: "data", result: undefined, isExecuting: true })).toBe(false);
expect(canReloadUnavailableDataTab({ mode: "query", result: undefined, isExecuting: false })).toBe(false);
});
it("keeps populated data tabs on the DataGrid refresh path", () => {
expect(
canReloadUnavailableDataTab({
mode: "data",
isExecuting: false,
result: { columns: ["id"], rows: [[1]], row_count: 1, execution_time_ms: 1 },
}),
).toBe(false);
});
});
@@ -0,0 +1,7 @@
import type { QueryTab } from "@/types/database";
type RefreshableDataTab = Pick<QueryTab, "mode" | "result" | "isExecuting">;
export function canReloadUnavailableDataTab(tab: RefreshableDataTab): boolean {
return tab.mode === "data" && !tab.result && !tab.isExecuting;
}