From bd05c0350d27a8382b88d19e2102f73bce16da6a Mon Sep 17 00:00:00 2001 From: Abeautifulsnow Date: Thu, 27 Aug 2026 11:30:27 +0800 Subject: [PATCH] feat(oracle): hide commit/rollback for clean manual-transaction state --- apps/desktop/src/App.vue | 8 + .../src/components/layout/EditorToolbar.vue | 20 +- .../EditorToolbar.transactionMode.spec.ts | 9 + apps/desktop/src/lib/backend/http.ts | 2 +- apps/desktop/src/lib/backend/tauri.ts | 3 +- .../queryStore.hiddenPrimaryKey.spec.ts | 8 +- .../queryStore.oracleTxnStickyState.spec.ts | 343 ++++++++++++++++++ apps/desktop/src/stores/queryStore.ts | 61 +++- apps/desktop/src/types/database.ts | 11 + crates/dbx-core/src/query.rs | 108 +++++- crates/dbx-core/src/query_execution_sql.rs | 174 +++++++++ crates/dbx-web/src/routes/query.rs | 2 + src-tauri/src/commands/query.rs | 2 + 13 files changed, 729 insertions(+), 22 deletions(-) create mode 100644 apps/desktop/src/stores/__tests__/queryStore.oracleTxnStickyState.spec.ts diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index 5654dffb51..3a2f3e4ff5 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -341,6 +341,12 @@ const activeConnection = computed(() => { return tab ? connectionStore.getConfig(tab.connectionId) : undefined; }); +// Oracle manual-mode indicator derived from the RESOLVED database type (an +// Oracle connection uses the agent runtime but reports db_type "oracle"), so +// the toolbar's Commit/Rollback visibility can apply the Oracle dirty-state rule +// without inferring Oracle from the raw transport type. +const isOracleManualTransaction = computed(() => effectiveDatabaseTypeForConnection(activeConnection.value) === "oracle" && (activeTab.value?.autoCommit ?? true) === false); + function updateAgentDriverUpdateCount(count: number) { if (!settingsStore.editorSettings.updateNotificationsEnabled) { agentDriverUpdateCount.value = 0; @@ -3039,6 +3045,8 @@ onUnmounted(() => { :auto-commit="activeTab.autoCommit ?? true" :txn-session-id="activeTab?.txnSessionId" :txn-auto-rolled-back="activeTab?.txnAutoRolledBack" + :oracle-txn-possibly-dirty="activeTab?.oracleTxnPossiblyDirty" + :is-oracle-manual-transaction="isOracleManualTransaction" @update:explain-mode="(m: 'explain' | 'autotrace') => (explainMode = m)" @update:block-dangerous-redis-commands="(v: boolean) => (blockDangerousRedisCommands = v)" @update:auto-commit=" diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue index 8995f44761..6db03688a6 100644 --- a/apps/desktop/src/components/layout/EditorToolbar.vue +++ b/apps/desktop/src/components/layout/EditorToolbar.vue @@ -34,6 +34,12 @@ const props = defineProps<{ autoCommit?: boolean; txnSessionId?: string; txnAutoRolledBack?: boolean; + /** Oracle-only: whether the current manual Oracle session executed a statement + * DBX cannot prove read-only. Commit/Rollback are hidden while false. */ + oracleTxnPossiblyDirty?: boolean; + /** Oracle manual mode derived from the resolved database type (not raw + * db_type, which can be the agent transport). */ + isOracleManualTransaction?: boolean; }>(); const emit = defineEmits<{ @@ -153,6 +159,12 @@ function toggleSqlSemanticDiagnostics() { const isTransactionActive = computed(() => !!props.txnSessionId); const isManualTransactionMode = computed(() => props.autoCommit === false || isTransactionActive.value); const transactionModeBadge = computed(() => (isManualTransactionMode.value ? "M" : "A")); +// Oracle manual mode hides Commit/Rollback while the session is clean (no +// unproven statement executed). Every other database keeps the existing rule. +const showTxnActions = computed(() => { + if (props.isOracleManualTransaction) return isTransactionActive.value && props.oracleTxnPossiblyDirty === true; + return isTransactionActive.value; +}); const transactionTooltip = computed(() => { const isAgent = (props.activeConnection?.db_type as string) === "agent"; const isManual = isManualTransactionMode.value; @@ -430,8 +442,8 @@ async function changeCatalog(selectedCatalog: string) { {{ transactionTooltip }} - - + +