fix(grid): mask loading only on executing result run
This commit is contained in:
1 parent
1aa9f06719
commit
f19439ad7a
9 files changed
+115
-8
No files matched your search
@@ -51,6 +51,19 @@ describe("openTabsPersistence originalSql round-trip", () => {
|
||||
expect(restored.originalSql).toBe("");
|
||||
});
|
||||
|
||||
it("does not persist the transient result execution target", () => {
|
||||
const tab = queryTab({ activeResultRunId: "run-1", executingResultRunId: "run-1", isExecuting: true });
|
||||
const [saved] = serializeOpenTabs([tab]);
|
||||
const [restored] = restoreOpenTabsPayload({
|
||||
tabs: [{ ...saved, executingResultRunId: "run-1" }],
|
||||
activeTabId: tab.id,
|
||||
}).tabs;
|
||||
|
||||
expect(saved).not.toHaveProperty("executingResultRunId");
|
||||
expect(restored.executingResultRunId).toBeUndefined();
|
||||
expect(restored.isExecuting).toBe(false);
|
||||
});
|
||||
|
||||
it("preserves an external Doris catalog across tab restore", () => {
|
||||
const [restored] = roundTrip([queryTab({ database: "dbx_catalog_completion", catalog: "dbx_mysql_catalog" })]);
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isActiveResultLoading, type QueryResultLoadingStateLike } from "@/lib/sql/queryExecutionState";
|
||||
|
||||
function state(overrides: Partial<QueryResultLoadingStateLike> = {}): QueryResultLoadingStateLike {
|
||||
return {
|
||||
isExecuting: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("active query result loading", () => {
|
||||
it("keeps the single-result execution loading", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: true, executingResultRunId: null }))).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps the result run being updated loading", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: true, activeResultRunId: "run-b", executingResultRunId: "run-b" }))).toBe(true);
|
||||
});
|
||||
|
||||
it("does not load a completed result while a new run is executing", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: true, activeResultRunId: "run-a", executingResultRunId: null }))).toBe(false);
|
||||
});
|
||||
|
||||
it("loads again when the user switches back to the executing run", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: true, activeResultRunId: "run-b", executingResultRunId: "run-b" }))).toBe(true);
|
||||
});
|
||||
|
||||
it("clears loading after execution finishes", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: false, activeResultRunId: "run-b", executingResultRunId: "run-b" }))).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps legacy unscoped executions conservative", () => {
|
||||
expect(isActiveResultLoading(state({ isExecuting: true, activeResultRunId: "run-a" }))).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -190,6 +190,7 @@ function restoreOpenTabsArray(parsed: unknown, rawActiveTabId: string | null, op
|
||||
isExecuting: false,
|
||||
isCancelling: false,
|
||||
queryExecutionStartedAt: undefined,
|
||||
executingResultRunId: undefined,
|
||||
editorViewport: undefined,
|
||||
editorSelection: undefined,
|
||||
isExplaining: false,
|
||||
|
||||
@@ -8,6 +8,21 @@ export function canCancelQueryExecution(state: QueryExecutionStateLike): boolean
|
||||
return state.isExecuting && !!state.executionId && !state.isCancelling;
|
||||
}
|
||||
|
||||
export interface QueryResultLoadingStateLike extends QueryExecutionStateLike {
|
||||
activeResultRunId?: string;
|
||||
/** The result run being updated; null means the execution will create a new run. */
|
||||
executingResultRunId?: string | null;
|
||||
}
|
||||
|
||||
export function isActiveResultLoading(state: QueryResultLoadingStateLike): boolean {
|
||||
if (!state.isExecuting) return false;
|
||||
if (!state.activeResultRunId) return true;
|
||||
// Keep unscoped legacy callers conservative while all new executions set an
|
||||
// explicit run id (or null when they are producing a new result run).
|
||||
if (state.executingResultRunId === undefined) return true;
|
||||
return state.executingResultRunId === state.activeResultRunId;
|
||||
}
|
||||
|
||||
export function queryExecutionLabelKey(state: Pick<QueryExecutionStateLike, "isCancelling">): "common.loading" | "common.stopping" {
|
||||
return state.isCancelling ? "common.stopping" : "common.loading";
|
||||
}
|
||||
Reference in new issue
Block a user