From 39d956f2e8a31b02676eb8eb6905b52b76eac810 Mon Sep 17 00:00:00 2001
From: t8y2 <1156263951@qq.com>
Date: Thu, 9 Jul 2026 18:59:12 +0800
Subject: [PATCH] fix(redis): skip confirmation for regular writes
---
.../src/components/redis/RedisKeyBrowser.vue | 14 ++-
apps/desktop/src/i18n/locales/en.ts | 1 +
apps/desktop/src/i18n/locales/es.ts | 1 +
apps/desktop/src/i18n/locales/it.ts | 1 +
apps/desktop/src/i18n/locales/ja.ts | 1 +
apps/desktop/src/i18n/locales/pt-BR.ts | 1 +
apps/desktop/src/i18n/locales/zh-CN.ts | 1 +
apps/desktop/src/i18n/locales/zh-TW.ts | 1 +
apps/desktop/src/lib/backend/tauri.ts | 2 +-
.../src/lib/redis/redisCommandSafety.ts | 79 ++++++++++++---
.../src/lib/redis/redisCommandTable.ts | 70 +++++++++++--
.../src/lib/redis/redisSyntaxDiagnostics.ts | 2 +-
crates/dbx-core/src/db/redis_driver.rs | 20 ++--
packages/app-tests/redisCommandSafety.test.ts | 13 +++
packages/app-tests/redisCommandTable.test.ts | 10 +-
.../app-tests/redisSyntaxDiagnostics.test.ts | 35 +++----
packages/mcp-server/tests/server.test.ts | 2 +-
packages/node-core/src/redis-command.ts | 99 +++++++++++++------
.../node-core/tests/redis-command.test.ts | 3 +-
packages/node-core/tests/redis-direct.test.ts | 11 ++-
20 files changed, 283 insertions(+), 84 deletions(-)
create mode 100644 packages/app-tests/redisCommandSafety.test.ts
diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.vue b/apps/desktop/src/components/redis/RedisKeyBrowser.vue
index 9d258955a..657eb6ec5 100644
--- a/apps/desktop/src/components/redis/RedisKeyBrowser.vue
+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.vue
@@ -151,6 +151,11 @@ const dangerConfirmLabel = computed(() => {
if (pendingDanger.value?.kind === "command") return t("dangerDialog.confirm");
return t("dangerDialog.deleteConfirm");
});
+const dangerMessage = computed(() => {
+ // Redis write commands such as SET/HSET are mutating but not necessarily delete operations.
+ if (pendingDanger.value?.kind === "command") return t("dangerDialog.redisCommandMessage");
+ return t("dangerDialog.deleteMessage");
+});
const commandPrompt = computed(() => `db${commandDb.value}>`);
const createKeyTypeOptions = computed<{ value: RedisCreateKeyType; label: string }[]>(() => [
{ value: "string", label: "String" },
@@ -518,12 +523,11 @@ async function runRedisCommand(command: string) {
// The db this command ran on — capture before nextRedisCommandDb() advances it.
const executedDb = commandDb.value;
commandDb.value = nextRedisCommandDb(commandDb.value, command, result.value);
- if (result.safety === "confirm") {
- await loadKeys();
- }
// Drop the cached key-name completion for this db so the editor's autocomplete
// reflects keys added/removed/renamed by SET/DEL/RENAME/...
- if (isRedisMutatingCommand(command)) {
+ const mutatesKeys = isRedisMutatingCommand(command);
+ if (mutatesKeys) {
+ await loadKeys();
connectionStore.invalidateCompletionCache(props.connectionId, String(executedDb));
// Refresh the sidebar db key counts (INFO keyspace) so `dbN (count)` stays accurate
// after the write. Fire-and-forget so the terminal stays responsive.
@@ -1224,7 +1228,7 @@ defineExpose({ focusSearch });
-
+