fix(editor): hide commit/rollback for clean mysql/pg manual transactions
Closes #9018
This commit is contained in:
1 parent
91b8fa0aa8
commit
e9be6d0419
15 files changed
+1016
-137
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeDetachedTabRuntime, type DetachedTabRuntimeState } from "@/lib/app/detachedTabHandoff";
|
||||
|
||||
describe("normalizeDetachedTabRuntime", () => {
|
||||
it("migrates a legacy-only oracleTxnPossiblyDirty key to txnPossiblyDirty", () => {
|
||||
// Detached handoffs persist to disk, so payloads written by pre-#9018
|
||||
// builds can still carry the old key; the sticky dirty bit must survive.
|
||||
const runtime: DetachedTabRuntimeState = { oracleTxnPossiblyDirty: true };
|
||||
expect(normalizeDetachedTabRuntime(runtime)).toEqual({ txnPossiblyDirty: true });
|
||||
});
|
||||
|
||||
it("prefers the renamed key when both are present", () => {
|
||||
const runtime: DetachedTabRuntimeState = { txnPossiblyDirty: false, oracleTxnPossiblyDirty: true };
|
||||
expect(normalizeDetachedTabRuntime(runtime)).toEqual({ txnPossiblyDirty: false });
|
||||
});
|
||||
|
||||
it("keeps a legacy clean bit as clean", () => {
|
||||
const runtime: DetachedTabRuntimeState = { txnSessionId: "txn-1", oracleTxnPossiblyDirty: false };
|
||||
expect(normalizeDetachedTabRuntime(runtime)).toEqual({ txnSessionId: "txn-1", txnPossiblyDirty: false });
|
||||
});
|
||||
|
||||
it("leaves runtimes without either key untouched", () => {
|
||||
expect(normalizeDetachedTabRuntime({ txnSessionId: "txn-1" })).toEqual({ txnSessionId: "txn-1" });
|
||||
});
|
||||
});
|
||||
@@ -8,10 +8,24 @@ export interface DetachedTabRuntimeState {
|
||||
editorSelection?: QueryTab["editorSelection"];
|
||||
txnSessionId?: string;
|
||||
txnAutoRolledBack?: boolean;
|
||||
txnPossiblyDirty?: boolean;
|
||||
/** Legacy key from before the #9018 rename. Handoffs persist to disk
|
||||
* (DETACHED_TABS_STATE_KEY), so payloads written by older builds may still
|
||||
* carry it; run restored runtimes through normalizeDetachedTabRuntime. */
|
||||
oracleTxnPossiblyDirty?: boolean;
|
||||
activeOutputView?: DetachedOutputView;
|
||||
}
|
||||
|
||||
/** Migrates a restored handoff runtime: prefer the renamed key, fall back to
|
||||
* the pre-#9018 key, and drop the legacy field so it never leaks onto a tab. */
|
||||
export function normalizeDetachedTabRuntime(runtime: DetachedTabRuntimeState): DetachedTabRuntimeState {
|
||||
const { oracleTxnPossiblyDirty, ...rest } = runtime;
|
||||
if (rest.txnPossiblyDirty === undefined && oracleTxnPossiblyDirty !== undefined) {
|
||||
rest.txnPossiblyDirty = oracleTxnPossiblyDirty;
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
export interface DetachedTabHandoff {
|
||||
schemaVersion: 1;
|
||||
tabId: string;
|
||||
|
||||
Reference in new issue
Block a user