Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(settings): add custom driver store path with migration

t8y2d974ad55336a
diff --git a/apps/desktop/src/components/config/DriverStoreDialog.vue b/apps/desktop/src/components/config/DriverStoreDialog.vue
index 98816a99fa..4f2194cddd 100644
--- a/apps/desktop/src/components/config/DriverStoreDialog.vue
+++ b/apps/desktop/src/components/config/DriverStoreDialog.vue
@@ -1,12 +1,13 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, computed, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { Activity, ExternalLink, Cpu, FolderOpen, MemoryStick, Search, Square, Trash2, Download, RotateCcw, Loader2, RefreshCw, Check, Clock3, FileUp } from "@lucide/vue";
+import { Activity, ExternalLink, Cpu, FolderOpen, FolderSync, MemoryStick, Search, Square, Trash2, Download, RotateCcw, Loader2, RefreshCw, Check, Clock3, FileUp } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Badge } from "@/components/ui/badge";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import DriverInstallProgressCircle from "@/components/config/DriverInstallProgressCircle.vue";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
@@ -38,6 +39,71 @@ const emit = defineEmits<{
const driverStoreTab = ref("agent");
+// ──────────── Driver store path ────────────
+
+import { useSettingsStore } from "@/stores/settingsStore";
+import type { DriverStorePathInfo } from "@/lib/api";
+const settingsStore = useSettingsStore();
+
+const driverStoreDir = computed(() => settingsStore.desktopSettings.driver_store_dir ?? null);
+const driverStoreDirMigrating = ref(false);
+const currentDriverStorePath = ref<DriverStorePathInfo | null>(null);
+
+async function loadDriverStorePath() {
+ if (isWeb) return;
+ try {
+ currentDriverStorePath.value = await api.getDriverStorePath();
+ } catch {
+ currentDriverStorePath.value = null;
+ }
+}
+
+const driverStoreDirDisplay = computed(() => {
+ if (currentDriverStorePath.value) {
+ return driverStoreDir.value || currentDriverStorePath.value.plugins_dir;
+ }
+ return driverStoreDir.value || t("driverStore.driverStoreDirDefault");
+});
+
+async function chooseDriverStoreDir() {
+ if (isWeb || driverStoreDirMigrating.value) return;
+ const { open } = await import("@tauri-apps/plugin-dialog");
+ const selected = await open({
+ title: t("driverStore.driverStoreDirDialogTitle"),
+ directory: true,
+ multiple: false,
+ });
+ if (typeof selected === "string") {
+ await applyDriverStoreDir(selected);
+ }
+}
+
+async function resetDriverStoreDir() {
+ if (driverStoreDirMigrating.value) return;
+ await applyDriverStoreDir(null);
+}
+
+async function applyDriverStoreDir(newDir: string | null) {
+ if (driverStoreDirMigrating.value) return;
+
+ const confirmed = window.confirm(t("driverStore.driverStoreDirConfirm"));
+ if (!confirmed) return;
+
+ driverStoreDirMigrating.value = true;
+ try {
+ const result = await api.setDriverStoreDir(newDir);
+ settingsStore.desktopSettings.driver_store_dir = result.driver_store_dir;
+ toast(t("driverStore.driverStoreDirSuccess"));
+ // Restart the app to use the new paths
+ const { relaunch } = await import("@tauri-apps/plugin-process");
+ relaunch();
+ } catch (e: any) {
+ toast(t("driverStore.driverStoreDirMigrationFailed", { error: e?.message || String(e) }), 5000);
+ } finally {
+ driverStoreDirMigrating.value = false;
+ }
+}
+
// ──────────── Agent drivers ────────────
const drivers = ref<AgentDriverInfo[]>([]);
@@ -585,7 +651,7 @@ function startDriverRuntimePolling() {
if (runtimeTimer) return;
void loadDriverRuntimeSummary(true);
runtimeTimer = setInterval(() => {
- if (driverStoreTab.value !== "runtime") {
+ if (driverStoreTab.value !== "storage") {
stopDriverRuntimePolling();
return;
}
@@ -817,6 +883,7 @@ onMounted(async () => {
updateAgentDrivers(await api.listInstalledAgentsLocal());
void loadJavaRuntimeConfig();
void loadDriverStoreUsage();
+ void loadDriverStorePath();
if (props.updateNotificationsEnabled) {
api.listInstalledAgents().then((result) => {
@@ -846,7 +913,7 @@ onUnmounted(() => {
});
watch(driverStoreTab, (tab) => {
- if (tab === "runtime") {
+ if (tab === "storage") {
startDriverRuntimePolling();
} else {
stopDriverRuntimePolling();
@@ -859,32 +926,6 @@ watch(driverStoreTab, (tab) => {
<div class="flex-1 min-h-0 overflow-y-auto">
<div class="max-w-4xl mx-auto px-6 py-6">
<Tabs v-model="driverStoreTab" default-value="agent">
- <div class="mb-5 rounded-xl border bg-muted/20 p-4">
- <div class="flex items-center justify-between gap-3">
- <div class="text-sm font-medium">{{ t("driverStore.usageTitle") }}</div>
- <div class="text-xs text-muted-foreground">
- {{ usageSummary.length ? t("driverStore.usageTotal", { size: formatBytes(usageSummary[0].bytes) }) : t("driverStore.calculating") }}
- </div>
- </div>
- <div v-if="usageSummary.length" class="mt-3 grid grid-cols-2 gap-2 sm:grid-cols-5">
- <div v-for="item in usageSummary" :key="item.key" class="rounded-lg border bg-background/50 px-2.5 py-2 text-center">
- <div class="text-[11px] text-muted-foreground">{{ item.label }}</div>
- <div class="mt-0.5 text-xs font-medium">{{ formatBytes(item.bytes) }}</div>
- </div>
- </div>
- <div class="mt-3 rounded-lg border bg-background/50 px-2.5 py-2">
- <div class="flex items-center justify-between gap-3">
- <div class="min-w-0 truncate text-xs text-muted-foreground">
- {{ t("driverStore.offlineDownloadHint") }}
- </div>
- <Button variant="outline" size="sm" class="h-7 shrink-0 rounded-full text-xs gap-1 whitespace-nowrap" @click="openOfflineDriverDownload">
- <ExternalLink class="h-3.5 w-3.5" />
- {{ t("driverStore.offlineDownloadLink") }}
- </Button>
- </div>
- </div>
- </div>
-
<div class="flex items-center justify-between">
<TabsList class="w-fit">
<TabsTrigger value="agent" class="gap-1.5 relative">
@@ -895,11 +936,11 @@ watch(driverStoreTab, (tab) => {
{{ t("driverStore.jdbcDrivers") }}
<span v-if="jdbcTabUpdateCount > 0" class="inline-block h-2 w-2 rounded-full bg-red-500" />
</TabsTrigger>
- <TabsTrigger value="runtime" class="gap-1.5 relative">
- {{ t("driverStore.runtimeDrivers") }}
+ <TabsTrigger value="storage" class="gap-1.5">
+ {{ t("driverStore.storageTab") }}
</TabsTrigger>
</TabsList>
- <div v-if="driverStoreTab !== 'runtime'" class="flex items-center gap-2">
+ <div v-if="driverStoreTab !== 'storage'" class="flex items-center gap-2">
<Button variant="ghost" size="sm" class="h-7 rounded-full text-xs gap-1 text-muted-foreground" :disabled="importingZip" @click="importOfflineZip">
<FileUp class="h-3.5 w-3.5" />
{{ importingZip ? t("driverStore.importing") : t("driverStore.importOfflinePackage") }}
@@ -1164,7 +1205,66 @@ watch(driverStoreTab, (tab) => {
</TabsContent>
<!-- Runtime Tab -->
- <TabsContent value="runtime" class="mt-5">
+ <TabsContent value="storage" class="mt-5 space-y-5">
+ <!-- Storage Usage -->
+ <div class="rounded-xl border bg-muted/20 p-4 space-y-3">
+ <div class="flex items-center justify-between gap-3">
+ <div class="text-sm font-medium">{{ t("driverStore.usageTitle") }}</div>
+ <div class="text-xs text-muted-foreground">
+ {{ usageSummary.length ? t("driverStore.usageTotal", { size: formatBytes(usageSummary[0].bytes) }) : t("driverStore.calculating") }}
+ </div>
+ </div>
+ <div v-if="usageSummary.length" class="grid grid-cols-2 gap-2 sm:grid-cols-5">
+ <div v-for="item in usageSummary" :key="item.key" class="rounded-lg border bg-background/50 px-2.5 py-2 text-center">
+ <div class="text-[11px] text-muted-foreground">{{ item.label }}</div>
+ <div class="mt-0.5 text-xs font-medium">{{ formatBytes(item.bytes) }}</div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Driver Store Path -->
+ <div v-if="!isWeb" class="rounded-xl border bg-muted/20 p-4 space-y-3">
+ <div class="text-sm font-medium">{{ t("driverStore.driverStoreDir") }}</div>
+ <p class="text-xs text-muted-foreground">{{ t("driverStore.driverStoreDirDescription") }}</p>
+ <div class="flex items-center gap-2">
+ <Tooltip>
+ <TooltipTrigger as-child>
+ <div class="min-w-0 flex-1 rounded-md border bg-background px-3 py-2 text-xs font-mono truncate">
+ {{ driverStoreDirDisplay }}
+ </div>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" class="max-w-100 break-all text-xs">
+ {{ driverStoreDirDisplay }}
+ </TooltipContent>
+ </Tooltip>
+ <Button variant="outline" size="sm" class="shrink-0 gap-1" :disabled="driverStoreDirMigrating" @click="chooseDriverStoreDir">
+ <FolderSync class="h-3.5 w-3.5" />
+ {{ t("driverStore.driverStoreDirChange") }}
+ </Button>
+ <Button v-if="driverStoreDir" variant="ghost" size="sm" class="shrink-0 gap-1 text-muted-foreground" :disabled="driverStoreDirMigrating" @click="resetDriverStoreDir">
+ {{ t("driverStore.driverStoreDirReset") }}
+ </Button>
+ </div>
+ <p v-if="driverStoreDirMigrating" class="text-xs text-muted-foreground flex items-center gap-1.5">
+ <Loader2 class="h-3 w-3 animate-spin" />
+ {{ t("driverStore.driverStoreDirMigrating") }}
+ </p>
+ </div>
+
+ <!-- Offline Download -->
+ <div class="rounded-xl border bg-muted/20 p-4">
+ <div class="flex items-center justify-between gap-3">
+ <div class="min-w-0 text-xs text-muted-foreground">
+ {{ t("driverStore.offlineDownloadHint") }}
+ </div>
+ <Button variant="outline" size="sm" class="shrink-0 gap-1" @click="openOfflineDriverDownload">
+ <ExternalLink class="h-3.5 w-3.5" />
+ {{ t("driverStore.offlineDownloadLink") }}
+ </Button>
+ </div>
+ </div>
+
+ <!-- Runtime Info -->
<div class="overflow-hidden rounded-md border bg-background">
<div class="flex flex-col gap-3 border-b px-4 py-3 lg:flex-row lg:items-center lg:justify-between">
<div class="flex min-w-0 items-center gap-2.5">
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index a14c996b70..64c1d57d47 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -2266,6 +2266,7 @@
update: "Update",
localInstall: "Local install",
runtimeDrivers: "Runtime",
+ storageTab: "Storage",
runtimeTitle: "Driver runtime",
runtimeHint: "Runtime metrics are collected only while this panel is open.",
runtimeRunning: "Running",
@@ -2294,6 +2295,16 @@
runtimeStopFailed: "Failed to stop {label}: {error}",
runtimeRestartSuccess: "{label} runtime restarted",
runtimeRestartFailed: "Failed to restart {label}: {error}",
+ driverStoreDir: "Driver Store Path",
+ driverStoreDirDescription: "Customize where drivers and JREs are stored. The app will restart automatically after migration.",
+ driverStoreDirDefault: "Default (install directory)",
+ driverStoreDirChange: "Change",
+ driverStoreDirReset: "Reset to Default",
+ driverStoreDirMigrating: "Migrating driver data…",
+ driverStoreDirConfirm: "Changing the driver store path will migrate all driver data to the new location. Active driver connections will be disconnected during migration. The app will restart automatically after migration. Continue?",
+ driverStoreDirMigrationFailed: "Driver store migration failed: {error}",
+ driverStoreDirDialogTitle: "Select Driver Store Directory",
+ driverStoreDirSuccess: "Driver store path changed, restarting…",
},
databaseExport: {
title: "Export Database",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 1ef46851fe..c4527edd56 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -1970,6 +1970,7 @@
update: "Actualizar",
localInstall: "Instalación local",
runtimeDrivers: "Runtime",
+ storageTab: "Almacenamiento",
runtimeTitle: "Runtime de drivers",
runtimeHint: "Las métricas de runtime se recopilan solo mientras este panel está abierto.",
runtimeRunning: "En ejecución",
@@ -1998,6 +1999,16 @@
runtimeStopFailed: "Error al detener {label}: {error}",
runtimeRestartSuccess: "Runtime de {label} reiniciado",
runtimeRestartFailed: "Error al reiniciar {label}: {error}",
+ driverStoreDir: "Ruta de almacenamiento de controladores",
+ driverStoreDirDescription: "Personaliza dónde se almacenan los controladores y JRE. La aplicación se reiniciará automáticamente después de la migración.",
+ driverStoreDirDefault: "Predeterminado (directorio de instalación)",
+ driverStoreDirChange: "Cambiar",
+ driverStoreDirReset: "Restablecer",
+ driverStoreDirMigrating: "Migrando datos de controladores…",
+ driverStoreDirConfirm: "Cambiar la ruta de almacenamiento migrará todos los datos de controladores a la nueva ubicación. Las conexiones activas se desconectarán durante la migración. La aplicación se reiniciará automáticamente después. ¿Continuar?",
+ driverStoreDirMigrationFailed: "Error en la migración de controladores: {error}",
+ driverStoreDirDialogTitle: "Seleccionar directorio de controladores",
+ driverStoreDirSuccess: "Ruta de almacenamiento cambiada, reiniciando…",
},
databaseExport: {
title: "Exportar base de datos",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index e2b884bb4a..77cf87cf21 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -2039,6 +2039,7 @@
update: "Aggiorna",
localInstall: "Installazione locale",
runtimeDrivers: "Runtime",
+ storageTab: "Archiviazione",
runtimeTitle: "Runtime del driver",
runtimeHint: "Le metriche di runtime vengono raccolte solo mentre questo pannello è aperto.",
runtimeRunning: "In esecuzione",
@@ -2067,6 +2068,16 @@
runtimeStopFailed: "Arresto di {label} non riuscito: {error}",
runtimeRestartSuccess: "Runtime {label} riavviato",
runtimeRestartFailed: "Riavvio di {label} non riuscito: {error}",
+ driverStoreDir: "Percorso archiviazione driver",
+ driverStoreDirDescription: "Personalizza dove vengono archiviati driver e JRE. L'app si riavvierà automaticamente dopo la migrazione.",
+ driverStoreDirDefault: "Predefinito (directory di installazione)",
+ driverStoreDirChange: "Cambia",
+ driverStoreDirReset: "Ripristina",
+ driverStoreDirMigrating: "Migrazione dati driver in corso…",
+ driverStoreDirConfirm: "La modifica del percorso di archiviazione migrerà tutti i dati dei driver nella nuova posizione. Le connessioni attive verranno disconnesse durante la migrazione. L'app si riavvierà automaticamente dopo. Continuare?",
+ driverStoreDirMigrationFailed: "Migrazione driver fallita: {error}",
+ driverStoreDirDialogTitle: "Seleziona directory driver",
+ driverStoreDirSuccess: "Percorso cambiato, riavvio in corso…",
},
databaseExport: {
title: "Esporta Database",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index d6e1364748..ab0aaae78f 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -2050,6 +2050,7 @@
update: "Atualizar",
localInstall: "Instalação local",
runtimeDrivers: "Runtime",
+ storageTab: "Armazenamento",
runtimeTitle: "Runtime do driver",
runtimeHint: "As métricas de runtime são coletadas apenas enquanto este painel está aberto.",
runtimeRunning: "Em execução",
@@ -2078,6 +2079,16 @@
runtimeStopFailed: "Falha ao parar {label}: {error}",
runtimeRestartSuccess: "Runtime {label} reiniciado",
runtimeRestartFailed: "Falha ao reiniciar {label}: {error}",
+ driverStoreDir: "Caminho de armazenamento de drivers",
+ driverStoreDirDescription: "Personalize onde drivers e JREs são armazenados. O app será reiniciado automaticamente após a migração.",
+ driverStoreDirDefault: "Padrão (diretório de instalação)",
+ driverStoreDirChange: "Alterar",
+ driverStoreDirReset: "Restaurar padrão",
+ driverStoreDirMigrating: "Migrando dados de drivers…",
+ driverStoreDirConfirm: "Alterar o caminho de armazenamento migrará todos os dados de drivers para o novo local. Conexões ativas serão desconectadas durante a migração. O app será reiniciado automaticamente após. Continuar?",
+ driverStoreDirMigrationFailed: "Falha na migração de drivers: {error}",
+ driverStoreDirDialogTitle: "Selecionar diretório de drivers",
+ driverStoreDirSuccess: "Caminho alterado, reiniciando…",
},
databaseExport: {
title: "Exportar banco de dados",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index ac3aa17de1..4e3983339c 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -2290,6 +2290,7 @@
update: "更新",
localInstall: "本地安装",
runtimeDrivers: "运行时",
+ storageTab: "存储",
runtimeTitle: "驱动运行时",
runtimeHint: "仅在打开此面板时采集运行时指标。",
runtimeRunning: "运行中",
@@ -2318,6 +2319,16 @@
runtimeStopFailed: "停止 {label} 失败: {error}",
runtimeRestartSuccess: "{label} 运行时已重启",
runtimeRestartFailed: "重启 {label} 失败: {error}",
+ driverStoreDir: "驱动存储路径",
+ driverStoreDirDescription: "自定义驱动和 JRE 的存储位置,迁移后应用将自动重启。",
+ driverStoreDirDefault: "默认(安装目录)",
+ driverStoreDirChange: "更改",
+ driverStoreDirReset: "恢复默认",
+ driverStoreDirMigrating: "正在迁移驱动数据…",
+ driverStoreDirConfirm: "更改驱动存储路径将迁移所有驱动数据到新位置,迁移期间会断开驱动连接。迁移完成后应用将自动重启。是否继续?",
+ driverStoreDirMigrationFailed: "驱动存储路径迁移失败:{error}",
+ driverStoreDirDialogTitle: "选择驱动存储目录",
+ driverStoreDirSuccess: "驱动存储路径已更改,正在重启…",
},
databaseExport: {
title: "导出数据库",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 9f417224f3..8efac630d4 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -2045,6 +2045,7 @@
update: "更新",
localInstall: "本機安裝",
runtimeDrivers: "執行環境",
+ storageTab: "儲存",
runtimeTitle: "驅動程式執行環境",
runtimeHint: "僅在開啟此面板時收集執行環境指標。",
runtimeRunning: "執行中",
@@ -2073,6 +2074,16 @@
runtimeStopFailed: "停止 {label} 失敗: {error}",
runtimeRestartSuccess: "{label} 執行環境已重新啟動",
runtimeRestartFailed: "重新啟動 {label} 失敗: {error}",
+ driverStoreDir: "驅動儲存路徑",
+ driverStoreDirDescription: "自訂驅動和 JRE 的儲存位置,遷移後應用將自動重啟。",
+ driverStoreDirDefault: "預設(安裝目錄)",
+ driverStoreDirChange: "更改",
+ driverStoreDirReset: "恢復預設",
+ driverStoreDirMigrating: "正在遷移驅動資料…",
+ driverStoreDirConfirm: "更改驅動儲存路徑將遷移所有驅動資料到新位置,遷移期間會斷開驅動連線。遷移完成後應用將自動重啟。是否繼續?",
+ driverStoreDirMigrationFailed: "驅動儲存路徑遷移失敗:{error}",
+ driverStoreDirDialogTitle: "選擇驅動儲存目錄",
+ driverStoreDirSuccess: "驅動儲存路徑已更改,正在重啟…",
},
databaseExport: {
title: "匯出資料庫",
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index 4bc1e0dbe4..599848f383 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -187,6 +187,8 @@ export const saveAiConfig = forward("saveAiConfig");
export const loadAiConfig = forward("loadAiConfig");
export const loadDesktopSettings = forward("loadDesktopSettings");
export const saveDesktopSettings = forward("saveDesktopSettings");
+export const setDriverStoreDir = forward("setDriverStoreDir");
+export const getDriverStorePath = forward("getDriverStorePath");
export const loadPinnedTreeNodeIds = forward("loadPinnedTreeNodeIds");
export const savePinnedTreeNodeIds = forward("savePinnedTreeNodeIds");
export const webdavSyncTest = forward("webdavSyncTest");
@@ -318,6 +320,8 @@ export type {
JavaRuntimeMode,
JavaRuntimeConfig,
DriverInstallProgress,
+ DriverStoreMigrationResult,
+ DriverStorePathInfo,
WebDavConfig,
WebDavPasswordStatus,
WebDavSyncSummary,
diff --git a/apps/desktop/src/lib/http.ts b/apps/desktop/src/lib/http.ts
index fda7893a2a..54b24a9a8e 100644
--- a/apps/desktop/src/lib/http.ts
+++ b/apps/desktop/src/lib/http.ts
@@ -851,13 +851,33 @@ export async function loadAiConfig(): Promise<AiConfig | null> {
}
export async function loadDesktopSettings(): Promise<DesktopSettings> {
- return { show_tray_icon: true, icon_theme: "default", debug_logging_enabled: false, saved_sql_sync_dir: null };
+ return { show_tray_icon: true, icon_theme: "default", debug_logging_enabled: false, saved_sql_sync_dir: null, driver_store_dir: null };
}
export async function saveDesktopSettings(_settings: DesktopSettings): Promise<void> {
return;
}
+export interface DriverStoreMigrationResult {
+ driver_store_dir: string | null;
+ migrated_plugins: boolean;
+ migrated_agents: boolean;
+}
+
+export async function setDriverStoreDir(_newDir: string | null): Promise<DriverStoreMigrationResult> {
+ throw new Error("Not available in web mode");
+}
+
+export interface DriverStorePathInfo {
+ driver_store_dir: string | null;
+ plugins_dir: string;
+ agents_dir: string;
+}
+
+export async function getDriverStorePath(): Promise<DriverStorePathInfo> {
+ throw new Error("Not available in web mode");
+}
+
export interface WebDavConfig {
endpoint: string;
username?: string;
diff --git a/apps/desktop/src/lib/tauri.ts b/apps/desktop/src/lib/tauri.ts
index f9621ee0b2..29c97d3211 100644
--- a/apps/desktop/src/lib/tauri.ts
+++ b/apps/desktop/src/lib/tauri.ts
@@ -126,6 +126,7 @@ export interface DesktopSettings {
icon_theme: "default" | "black";
debug_logging_enabled: boolean;
saved_sql_sync_dir?: string | null;
+ driver_store_dir?: string | null;
}
export interface SavedSqlSyncEntry {
@@ -331,6 +332,26 @@ export async function saveDesktopSettings(settings: DesktopSettings): Promise<vo
return invoke("save_desktop_settings", { settings });
}
+export interface DriverStoreMigrationResult {
+ driver_store_dir: string | null;
+ migrated_plugins: boolean;
+ migrated_agents: boolean;
+}
+
+export async function setDriverStoreDir(newDir: string | null): Promise<DriverStoreMigrationResult> {
+ return invoke("set_driver_store_dir", { newDir });
+}
+
+export interface DriverStorePathInfo {
+ driver_store_dir: string | null;
+ plugins_dir: string;
+ agents_dir: string;
+}
+
+export async function getDriverStorePath(): Promise<DriverStorePathInfo> {
+ return invoke("get_driver_store_path");
+}
+
export async function webdavSyncTest(config: WebDavConfig): Promise<void> {
return invoke("webdav_sync_test", { config });
}
diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.ts
index 63f4071f48..e4395fbc39 100644
--- a/apps/desktop/src/stores/settingsStore.ts
+++ b/apps/desktop/src/stores/settingsStore.ts
@@ -40,6 +40,7 @@ export interface DesktopSettings {
icon_theme: DesktopIconTheme;
debug_logging_enabled: boolean;
saved_sql_sync_dir?: string | null;
+ driver_store_dir?: string | null;
}
export type DesktopIconTheme = "default" | "black";
@@ -49,6 +50,7 @@ export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
icon_theme: "default",
debug_logging_enabled: false,
saved_sql_sync_dir: null,
+ driver_store_dir: null,
};
function normalizeDesktopSettings(settings: Partial<DesktopSettings> | null | undefined): DesktopSettings {
@@ -58,6 +60,7 @@ function normalizeDesktopSettings(settings: Partial<DesktopSettings> | null | un
icon_theme: iconTheme,
debug_logging_enabled: settings?.debug_logging_enabled ?? DEFAULT_DESKTOP_SETTINGS.debug_logging_enabled,
saved_sql_sync_dir: settings?.saved_sql_sync_dir?.trim() || DEFAULT_DESKTOP_SETTINGS.saved_sql_sync_dir,
+ driver_store_dir: settings?.driver_store_dir?.trim() || DEFAULT_DESKTOP_SETTINGS.driver_store_dir,
};
}
diff --git a/crates/dbx-core/src/storage.rs b/crates/dbx-core/src/storage.rs
index a7a9a10c68..4a7957803e 100644
--- a/crates/dbx-core/src/storage.rs
+++ b/crates/dbx-core/src/storage.rs
@@ -36,6 +36,8 @@ pub struct DesktopSettings {
pub debug_logging_enabled: bool,
#[serde(default)]
pub saved_sql_sync_dir: Option<String>,
+ #[serde(default)]
+ pub driver_store_dir: Option<String>,
}
impl Default for DesktopSettings {
@@ -45,6 +47,7 @@ impl Default for DesktopSettings {
icon_theme: DesktopIconTheme::Default,
debug_logging_enabled: false,
saved_sql_sync_dir: None,
+ driver_store_dir: None,
}
}
}
@@ -529,6 +532,12 @@ impl Storage {
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToString::to_string),
+ driver_store_dir: settings
+ .get("driver_store_dir")
+ .and_then(|value| value.as_str())
+ .map(str::trim)
+ .filter(|value| !value.is_empty())
+ .map(ToString::to_string),
})
}
diff --git a/src-tauri/src/commands/app_settings.rs b/src-tauri/src/commands/app_settings.rs
index 7b645b18ea..71394c61c3 100644
--- a/src-tauri/src/commands/app_settings.rs
+++ b/src-tauri/src/commands/app_settings.rs
@@ -6,6 +6,13 @@ use tauri::{AppHandle, Manager, State};
use super::connection::AppState;
use crate::{apply_debug_log_level, apply_desktop_settings};
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct DriverStoreMigrationResult {
+ pub driver_store_dir: Option<String>,
+ pub migrated_plugins: bool,
+ pub migrated_agents: bool,
+}
+
#[tauri::command]
pub async fn load_desktop_settings(state: State<'_, Arc<AppState>>) -> Result<DesktopSettings, String> {
state.storage.load_desktop_settings().await
@@ -43,6 +50,173 @@ pub async fn load_native_debug_logs(app: AppHandle) -> Result<String, String> {
.map_err(|err| err.to_string())?
}
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct DriverStorePathInfo {
+ pub driver_store_dir: Option<String>,
+ pub plugins_dir: String,
+ pub agents_dir: String,
+}
+
+#[tauri::command]
+pub async fn get_driver_store_path(state: State<'_, Arc<AppState>>) -> Result<DriverStorePathInfo, String> {
+ let settings = state.storage.load_desktop_settings().await.unwrap_or_default();
+ Ok(DriverStorePathInfo {
+ driver_store_dir: settings.driver_store_dir,
+ plugins_dir: state.plugins.root_dir().to_string_lossy().to_string(),
+ agents_dir: state.agent_manager.base_dir().to_string_lossy().to_string(),
+ })
+}
+
+#[tauri::command]
+pub async fn set_driver_store_dir(
+ state: State<'_, Arc<AppState>>,
+ new_dir: Option<String>,
+) -> Result<DriverStoreMigrationResult, String> {
+ let new_dir = new_dir.filter(|d| !d.trim().is_empty()).map(|d| d.trim().to_string());
+ let new_path = new_dir.as_ref().map(PathBuf::from);
+
+ // Resolve current plugin/agent directories
+ let current_plugins_dir = state.plugins.root_dir().to_path_buf();
+ let current_agents_dir = state.agent_manager.base_dir().clone();
+
+ // Validate: if setting a custom dir, it must be different from current parent
+ if let Some(ref np) = new_path {
+ let target_plugins = np.join("plugins");
+ let target_agents = np.join("agents");
+
+ // Canonicalize for comparison (both sides)
+ let np_canonical = if np.exists() {
+ np.canonicalize().map_err(|e| format!("Invalid path {}: {e}", np.display()))?
+ } else {
+ std::fs::create_dir_all(np).map_err(|e| format!("Failed to create directory {}: {e}", np.display()))?;
+ np.canonicalize().map_err(|e| format!("Invalid path {}: {e}", np.display()))?
+ };
+
+ let current_plugins_parent = current_plugins_dir.parent();
+ let current_agents_parent = current_agents_dir.parent();
+
+ // Check if the new dir is the same as the current parent (no-op)
+ if current_plugins_parent == Some(&np_canonical) && current_agents_parent == Some(&np_canonical) {
+ return Ok(DriverStoreMigrationResult {
+ driver_store_dir: new_dir,
+ migrated_plugins: false,
+ migrated_agents: false,
+ });
+ }
+
+ // Stop all running agent daemons before migration
+ state.agent_manager.stop_daemons().await;
+
+ // Migrate plugins directory
+ let migrated_plugins = if current_plugins_dir.exists() {
+ migrate_directory(&current_plugins_dir, &target_plugins)?;
+ true
+ } else {
+ false
+ };
+
+ // Migrate agents directory
+ let migrated_agents = if current_agents_dir.exists() {
+ migrate_directory(&current_agents_dir, &target_agents)?;
+ true
+ } else {
+ false
+ };
+
+ // Verify migration
+ if migrated_plugins {
+ verify_migration(&current_plugins_dir, &target_plugins)?;
+ }
+ if migrated_agents {
+ verify_migration(&current_agents_dir, &target_agents)?;
+ }
+
+ // Delete old data after successful verification
+ if migrated_plugins {
+ if let Err(err) = std::fs::remove_dir_all(&current_plugins_dir) {
+ log::warn!("Failed to remove old plugins dir {}: {err}", current_plugins_dir.display());
+ }
+ }
+ if migrated_agents {
+ if let Err(err) = std::fs::remove_dir_all(&current_agents_dir) {
+ log::warn!("Failed to remove old agents dir {}: {err}", current_agents_dir.display());
+ }
+ }
+ }
+
+ // Save the setting
+ let mut settings = state.storage.load_desktop_settings().await.unwrap_or_default();
+ settings.driver_store_dir = new_dir.clone();
+ state.storage.save_desktop_settings(&settings).await?;
+
+ Ok(DriverStoreMigrationResult { driver_store_dir: new_dir, migrated_plugins: true, migrated_agents: true })
+}
+
+/// Recursively copy a directory to a new location.
+fn migrate_directory(src: &PathBuf, dst: &PathBuf) -> Result<(), String> {
+ if !src.exists() {
+ return Ok(());
+ }
+ std::fs::create_dir_all(dst).map_err(|e| format!("Failed to create {}: {e}", dst.display()))?;
+ copy_dir_recursive(src, dst)
+}
+
+fn copy_dir_recursive(src: &std::path::Path, dst: &std::path::Path) -> Result<(), String> {
+ std::fs::create_dir_all(dst).map_err(|e| format!("Failed to create {}: {e}", dst.display()))?;
+ for entry in std::fs::read_dir(src).map_err(|e| format!("Failed to read {}: {e}", src.display()))? {
+ let entry = entry.map_err(|e| e.to_string())?;
+ let src_path = entry.path();
+ let dst_path = dst.join(entry.file_name());
+ if src_path.is_dir() {
+ copy_dir_recursive(&src_path, &dst_path)?;
+ } else {
+ std::fs::copy(&src_path, &dst_path)
+ .map_err(|e| format!("Failed to copy {} to {}: {e}", src_path.display(), dst_path.display()))?;
+ }
+ }
+ Ok(())
+}
+
+/// Verify that the migrated directory has the same file count and total size.
+fn verify_migration(src: &PathBuf, dst: &PathBuf) -> Result<(), String> {
+ let src_info = count_files_recursive(src)?;
+ let dst_info = count_files_recursive(dst)?;
+ if src_info.count != dst_info.count || src_info.total_size != dst_info.total_size {
+ // Rollback: remove the incomplete destination
+ let _ = std::fs::remove_dir_all(dst);
+ return Err(format!(
+ "Migration verification failed: source had {} files ({} bytes), destination has {} files ({} bytes)",
+ src_info.count, src_info.total_size, dst_info.count, dst_info.total_size
+ ));
+ }
+ Ok(())
+}
+
+struct DirStats {
+ count: usize,
+ total_size: u64,
+}
+
+fn count_files_recursive(dir: &std::path::Path) -> Result<DirStats, String> {
+ let mut count = 0usize;
+ let mut total_size = 0u64;
+ fn walk(dir: &std::path::Path, count: &mut usize, total_size: &mut u64) -> Result<(), String> {
+ for entry in std::fs::read_dir(dir).map_err(|e| e.to_string())? {
+ let entry = entry.map_err(|e| e.to_string())?;
+ let path = entry.path();
+ if path.is_dir() {
+ walk(&path, count, total_size)?;
+ } else {
+ *count += 1;
+ *total_size += entry.metadata().map(|m| m.len()).unwrap_or(0);
+ }
+ }
+ Ok(())
+ }
+ walk(dir, &mut count, &mut total_size)?;
+ Ok(DirStats { count, total_size })
+}
+
fn load_native_debug_logs_from_dir(log_dir: PathBuf) -> Result<String, String> {
const MAX_FILES: usize = 6;
const MAX_FILE_BYTES: u64 = 512 * 1024;
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 09442b484b..0e7426bf55 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -261,7 +261,15 @@ pub fn run() {
apply_debug_log_level(desktop_settings.debug_logging_enabled);
eprintln!("[STARTUP] storage ready in {:?}", t.elapsed());
- let state = if data_dir::uses_custom_data_dir() {
+ let state = if let Some(ref driver_dir) = desktop_settings.driver_store_dir {
+ let driver_base = std::path::PathBuf::from(driver_dir);
+ Arc::new(AppState::new_with_plugin_and_agent_dir_and_app_version(
+ storage,
+ driver_base.join("plugins"),
+ driver_base.join("agents"),
+ env!("CARGO_PKG_VERSION"),
+ ))
+ } else if data_dir::uses_custom_data_dir() {
Arc::new(AppState::new_with_plugin_and_agent_dir_and_app_version(
storage,
data_dir.join("plugins"),
@@ -328,6 +336,8 @@ pub fn run() {
commands::ai::delete_ai_conversation,
commands::app_settings::load_desktop_settings,
commands::app_settings::save_desktop_settings,
+ commands::app_settings::set_driver_store_dir,
+ commands::app_settings::get_driver_store_path,
commands::app_settings::load_pinned_tree_node_ids,
commands::app_settings::save_pinned_tree_node_ids,
commands::app_settings::load_native_debug_logs,