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。

fix(cloud-sync): improve sync selection dialog UX and counts

Terry Yaoa812c94f67a4
diff --git a/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue b/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue
index b49f09bd10..7b0fdd5ffc 100644
--- a/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue
+++ b/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { ChevronDown, ChevronRight, FoldVertical, FolderOpen, ListChecks, ListX, UnfoldVertical } from "@lucide/vue";
+import { ChevronDown, ChevronRight, FoldVertical, FolderOpen, ListChecks, ListX, Lock, UnfoldVertical } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import type { PluginUiStorageItemRef, SyncCatalogItem, SyncSelection, SyncSnapshotCatalog } from "@/lib/backend/api";
@@ -28,9 +28,11 @@ const emit = defineEmits<{
}>();
const selection = ref<SyncSelection>(emptySelection());
-const secretsPassphraseRequired = ref(false);
const localExportPathRequired = ref(false);
const isRestore = computed(() => props.mode === "restore");
+// Without a passphrase no encrypted item can be selected, so the dialog hides the secret
+// checkboxes entirely and shows a persistent hint inside the affected groups instead.
+const secretsUnavailable = computed(() => props.secretsPassphraseAvailable === false);
const SYNC_GROUP_IDS = ["connections", "tunnels", "savedSql", "settings", "secrets", "workspace"] as const;
type SyncGroupId = (typeof SYNC_GROUP_IDS)[number];
@@ -44,6 +46,13 @@ function toggleGroup(id: SyncGroupId) {
collapsedGroups.value = next;
}
+function expandGroup(id: SyncGroupId) {
+ if (!collapsedGroups.value.has(id)) return;
+ const next = new Set(collapsedGroups.value);
+ next.delete(id);
+ collapsedGroups.value = next;
+}
+
function toggleAllGroups() {
collapsedGroups.value = allGroupsCollapsed.value ? new Set() : new Set(SYNC_GROUP_IDS);
}
@@ -202,6 +211,18 @@ const secretsSummary = computed(() => {
return { selected, total };
});
+// Connection/tunnel credentials render per-item under their own groups; the aggregate rows inside
+// the encrypted group exist so the group header count adds up to its visible children.
+const connectionSecretsSummary = computed(() => ({
+ selected: props.catalog?.connectionSecrets.filter((id) => selection.value.connectionSecrets?.includes(id)).length ?? 0,
+ total: props.catalog?.connectionSecrets.length ?? 0,
+}));
+
+const tunnelSecretsSummary = computed(() => ({
+ selected: props.catalog?.tunnelSecrets.filter((id) => selection.value.tunnelSecrets?.includes(id)).length ?? 0,
+ total: props.catalog?.tunnelSecrets.length ?? 0,
+}));
+
const workspaceSummary = computed(() => {
const catalog = props.catalog;
if (!catalog) return { selected: 0, total: 0 };
@@ -240,26 +261,28 @@ function resetFromCatalog() {
const catalog = props.catalog;
if (!catalog) return;
const saved = catalog.selection;
+ const secretsAvailable = !secretsUnavailable.value;
const desktopSettings = selectableDesktopSettings(catalog);
const editorSettings = selectableEditorSettings(catalog);
selection.value = {
...emptySelection(),
connections: saved?.connections ?? catalog.connections.map((item) => item.id),
- connectionSecrets: saved?.connectionSecrets ?? (catalog.hasEncryptedSecrets ? catalog.connectionSecrets : []),
+ connectionSecrets: secretsAvailable ? (saved?.connectionSecrets ?? (catalog.hasEncryptedSecrets ? catalog.connectionSecrets : [])) : [],
tunnelProfiles: saved?.tunnelProfiles ?? catalog.tunnelProfiles.map((item) => item.id),
- tunnelSecrets: saved?.tunnelSecrets ?? (catalog.hasEncryptedSecrets ? catalog.tunnelSecrets : []),
+ tunnelSecrets: secretsAvailable ? (saved?.tunnelSecrets ?? (catalog.hasEncryptedSecrets ? catalog.tunnelSecrets : [])) : [],
savedSqlFolders: saved?.savedSqlFolders ?? catalog.savedSqlFolders.map((item) => item.id),
savedSqlFiles: saved?.savedSqlFiles ?? catalog.savedSqlFiles.map((item) => item.id),
desktopSettings: selectedSettings(saved?.desktopSettings, desktopSettings),
editorSettings: selectedSettings(saved?.editorSettings, editorSettings),
- aiConfigs: saved?.aiConfigs ?? (catalog.aiConfigsLocked ? undefined : catalog.aiConfigs.map((item) => item.id)),
+ aiConfigs: secretsAvailable ? (saved?.aiConfigs ?? (catalog.aiConfigsLocked ? undefined : catalog.aiConfigs.map((item) => item.id))) : [],
// While locked the plugin items cannot be enumerated, so the selection is an aggregate "include all" flag.
// The encrypted blob only contains what the saved selection covered, so `undefined` restores the same data.
- pluginUiStorage: catalog.pluginUiStorageLocked ? undefined : (saved?.pluginUiStorage ?? catalog.pluginUiStorage),
+ // `[]` (not `undefined`) when no passphrase is available: `undefined` would mean "include all".
+ pluginUiStorage: secretsAvailable ? (catalog.pluginUiStorageLocked ? undefined : (saved?.pluginUiStorage ?? catalog.pluginUiStorage)) : [],
sidebarLayout: saved?.sidebarLayout ?? catalog.hasSidebarLayout,
pinnedTreeNodeIds: saved?.pinnedTreeNodeIds ?? catalog.hasPinnedTreeNodeIds,
- includeSecrets: props.secretsPassphraseAvailable === false ? false : (saved?.includeSecrets ?? (isRestore.value ? catalog.hasEncryptedSecrets : !!props.defaultIncludeSecrets)),
- syncCredentials: saved?.syncCredentials ?? (isRestore.value ? catalog.hasEncryptedSecrets : !!props.defaultIncludeSecrets),
+ includeSecrets: secretsAvailable && (saved?.includeSecrets ?? (isRestore.value ? catalog.hasEncryptedSecrets : !!props.defaultIncludeSecrets)),
+ syncCredentials: secretsAvailable && (saved?.syncCredentials ?? (isRestore.value ? catalog.hasEncryptedSecrets : !!props.defaultIncludeSecrets)),
};
if (selection.value.includeSecrets && !saved) fillMissingSecrets();
}
@@ -268,7 +291,6 @@ watch(
() => [props.open, props.catalog] as const,
([open]) => {
if (open) {
- secretsPassphraseRequired.value = false;
localExportPathRequired.value = false;
collapsedGroups.value = new Set(SYNC_GROUP_IDS);
resetFromCatalog();
@@ -342,15 +364,30 @@ function pluginGroupState(group: { items: PluginUiStorageItemRef[] }): Selection
return selected === 0 ? "none" : selected === group.items.length ? "all" : "partial";
}
+// Deselecting a connection/tunnel also drops its credentials: a kept secret id would stay counted
+// in the encrypted aggregate even though its owner is no longer part of the backup.
+function pruneOrphanSecrets(key: "connections" | "tunnelProfiles") {
+ const secretsKey = key === "connections" ? "connectionSecrets" : "tunnelSecrets";
+ const owners = new Set(ids(key));
+ const kept = ids(secretsKey).filter((id) => owners.has(id));
+ if (kept.length !== ids(secretsKey).length) {
+ selection.value[secretsKey] = kept;
+ syncIncludeSecrets();
+ }
+}
+
function toggleId(key: "connections" | "connectionSecrets" | "tunnelProfiles" | "tunnelSecrets" | "savedSqlFolders" | "savedSqlFiles" | "desktopSettings" | "editorSettings" | "aiConfigs", id: string) {
const current = ids(key);
- selection.value[key] = current.includes(id) ? current.filter((item) => item !== id) : [...current, id];
+ const removing = current.includes(id);
+ selection.value[key] = removing ? current.filter((item) => item !== id) : [...current, id];
+ if (removing && (key === "connections" || key === "tunnelProfiles")) pruneOrphanSecrets(key);
}
function toggleAll(key: "connections" | "tunnelProfiles" | "savedSqlFolders" | "savedSqlFiles" | "desktopSettings" | "editorSettings" | "aiConfigs", items: SyncCatalogItem[]) {
const current = ids(key);
const isAllSelected = items.length > 0 && items.every((item) => current.includes(item.id));
selection.value[key] = isAllSelected ? [] : items.map((item) => item.id);
+ if (isAllSelected && (key === "connections" || key === "tunnelProfiles")) pruneOrphanSecrets(key);
}
function toggleSavedSql() {
@@ -447,6 +484,27 @@ function toggleAllAiConfigs() {
syncIncludeSecrets();
}
+// The aggregate credential rows toggle every connection/tunnel secret id at once, under the same
+// passphrase gate as the other encrypted items.
+function toggleSecretIdsAll(key: "connectionSecrets" | "tunnelSecrets", event: Event) {
+ const catalogIds = (key === "connectionSecrets" ? props.catalog?.connectionSecrets : props.catalog?.tunnelSecrets) ?? [];
+ // Credentials of deselected connections/tunnels are filtered out server-side (metadata_ids),
+ // so the aggregate row must only select ids whose owner row is still selected.
+ const ownerIds = ids(key === "connectionSecrets" ? "connections" : "tunnelProfiles");
+ const selectableIds = catalogIds.filter((id) => ownerIds.includes(id));
+ const current = ids(key);
+ const allSelected = selectableIds.length > 0 && selectableIds.every((id) => current.includes(id));
+ if (!allSelected && !ensureSecretsEnabled()) {
+ // State did not change, so Vue will not re-sync the checkbox the user just flipped; revert it manually.
+ const input = event.target as HTMLInputElement;
+ input.checked = false;
+ input.indeterminate = summaryState(key === "connectionSecrets" ? connectionSecretsSummary.value : tunnelSecretsSummary.value) === "partial";
+ return;
+ }
+ selection.value[key] = allSelected ? [] : [...selectableIds];
+ syncIncludeSecrets();
+}
+
// The encrypted group checkbox is an aggregate over its items: locked `undefined` selections count as "include all".
function secretsLeafSelected(): boolean {
const s = selection.value;
@@ -489,9 +547,14 @@ function fillMissingSecrets() {
function onSecretsGroupChanged(event: Event) {
const input = event.target as HTMLInputElement;
+ if (secretsUnavailable.value) {
+ // Nothing inside can be selected without a passphrase; open the group so the hint explains why.
+ input.checked = false;
+ expandGroup("secrets");
+ return;
+ }
if (summaryState(secretsSummary.value) === "all") {
clearAllSecretsItems();
- secretsPassphraseRequired.value = false;
return;
}
if (!ensureSecretsEnabled()) {
@@ -507,11 +570,7 @@ function onSecretsGroupChanged(event: Event) {
// (same passphrase guard as the master checkbox), while unchecking stays allowed.
function ensureSecretsEnabled(): boolean {
if (selection.value.includeSecrets) return true;
- if (props.secretsPassphraseAvailable === false) {
- secretsPassphraseRequired.value = true;
- return false;
- }
- secretsPassphraseRequired.value = false;
+ if (secretsUnavailable.value) return false;
selection.value.includeSecrets = true;
return true;
}
@@ -560,10 +619,10 @@ function selectAllItems() {
const catalog = props.catalog;
if (!catalog) return;
// Encrypted items only make sense when the snapshot has them (restore) and the passphrase is available;
- // otherwise surface the same passphrase hint the encrypted checkbox would show.
+ // otherwise expand the encrypted group so its hint explains what was skipped.
const wantsSecrets = !isRestore.value || catalog.hasEncryptedSecrets;
const secretsAvailable = wantsSecrets && props.secretsPassphraseAvailable !== false;
- secretsPassphraseRequired.value = wantsSecrets && !secretsAvailable;
+ if (wantsSecrets && !secretsAvailable) expandGroup("secrets");
selection.value = {
connections: catalog.connections.map((item) => item.id),
connectionSecrets: secretsAvailable ? [...catalog.connectionSecrets] : [],
@@ -584,7 +643,6 @@ function selectAllItems() {
}
function deselectAllItems() {
- secretsPassphraseRequired.value = false;
selection.value = emptySelection();
}
@@ -667,12 +725,15 @@ function confirmSelection() {
<ChevronRight v-else class="size-4 shrink-0 text-muted-foreground" />
</summary>
<div class="ml-6 space-y-1 pb-2">
+ <p v-if="secretsUnavailable && catalog.connectionSecrets.length" class="py-1 text-xs text-destructive">
+ {{ t("settings.localBackupSecretsPassphraseRequiredHint") }}
+ </p>
<div v-for="item in catalog.connections" :key="item.id" class="py-1">
<label class="flex min-h-7 items-center gap-2 text-sm">
<input :checked="checked('connections', item.id)" type="checkbox" class="size-4 accent-primary" @change="toggleId('connections', item.id)" />
<span class="min-w-0 truncate">{{ item.label || item.id }}</span>
</label>
- <label v-if="catalog.connectionSecrets.includes(item.id)" class="ml-6 flex min-h-7 items-center gap-2 text-xs text-muted-foreground">
+ <label v-if="!secretsUnavailable && catalog.connectionSecrets.includes(item.id)" class="ml-6 flex min-h-7 items-center gap-2 text-xs text-muted-foreground">
<input :checked="checked('connectionSecrets', item.id)" :disabled="!selection.connections?.includes(item.id)" type="checkbox" class="size-3.5 accent-primary" @change="toggleSecretId('connectionSecrets', item.id, $event)" />
<span>{{ t("settings.syncSelectionConnectionSecrets") }}</span>
</label>
@@ -698,12 +759,15 @@ function confirmSelection() {
<ChevronRight v-else class="size-4 shrink-0 text-muted-foreground" />
</summary>
<div class="ml-6 space-y-1 pb-2">
+ <p v-if="secretsUnavailable && catalog.tunnelSecrets.length" class="py-1 text-xs text-destructive">
+ {{ t("settings.localBackupSecretsPassphraseRequiredHint") }}
+ </p>
<div v-for="item in catalog.tunnelProfiles" :key="item.id" class="py-1">
<label class="flex min-h-7 items-center gap-2 text-sm">
<input :checked="checked('tunnelProfiles', item.id)" type="checkbox" class="size-4 accent-primary" @change="toggleId('tunnelProfiles', item.id)" />
<span class="min-w-0 truncate">{{ item.label || item.id }}</span>
</label>
- <label v-if="catalog.tunnelSecrets.includes(item.id)" class="ml-6 flex min-h-7 items-center gap-2 text-xs text-muted-foreground">
+ <label v-if="!secretsUnavailable && catalog.tunnelSecrets.includes(item.id)" class="ml-6 flex min-h-7 items-center gap-2 text-xs text-muted-foreground">
<input :checked="checked('tunnelSecrets', item.id)" :disabled="!selection.tunnelProfiles?.includes(item.id)" type="checkbox" class="size-3.5 accent-primary" @change="toggleSecretId('tunnelSecrets', item.id, $event)" />
<span>{{ t("settings.syncSelectionTunnelSecrets") }}</span>
</label>
@@ -779,58 +843,81 @@ function confirmSelection() {
<summary class="flex cursor-pointer list-none items-center gap-2 py-2 text-sm font-medium" @click.prevent="toggleGroup('secrets')">
<input :checked="summaryState(secretsSummary) === 'all'" :indeterminate="summaryState(secretsSummary) === 'partial'" type="checkbox" class="size-4 accent-primary" @click.stop @change="onSecretsGroupChanged($event)" />
<span>{{ t("settings.syncSelectionEncrypted") }}</span>
+ <Lock v-if="secretsUnavailable" class="size-3.5 shrink-0 text-muted-foreground" />
<span class="ml-auto text-xs text-muted-foreground">{{ secretsSummary.selected }}/{{ secretsSummary.total }}</span>
<ChevronDown v-if="!collapsedGroups.has('secrets')" class="size-4 shrink-0 text-muted-foreground" />
<ChevronRight v-else class="size-4 shrink-0 text-muted-foreground" />
</summary>
<div class="ml-6 space-y-2 pb-2">
- <p v-if="secretsPassphraseRequired" role="alert" class="text-xs text-destructive">
- {{ t("settings.localBackupSecretsPassphraseRequiredHint") }}
- </p>
- <label class="flex min-h-7 items-center gap-2 text-sm">
- <input :checked="selection.syncCredentials" type="checkbox" class="size-4 accent-primary" @change="onSyncCredentialsChanged($event)" />
- <span>{{ t("settings.syncSelectionSyncCredentials") }}</span>
- </label>
- <div>
- <label v-if="catalog.aiConfigsLocked" class="flex min-h-7 items-center gap-2 text-sm">
- <input :checked="selection.aiConfigs === undefined" type="checkbox" class="size-4 accent-primary" @change="onAiConfigsToggleAll($event)" />
- <span>{{ t("settings.syncSelectionAiLocked") }}</span>
+ <template v-if="secretsUnavailable">
+ <p v-if="isRestore && !catalog.hasEncryptedSecrets" class="text-xs text-muted-foreground">
+ {{ t("settings.syncSelectionNoEncrypted") }}
+ </p>
+ <p v-else role="alert" class="text-xs text-destructive">
+ {{ t("settings.localBackupSecretsPassphraseRequiredHint") }}
+ </p>
+ </template>
+ <template v-else>
+ <label class="flex min-h-7 items-center gap-2 text-sm">
+ <input :checked="selection.syncCredentials" type="checkbox" class="size-4 accent-primary" @change="onSyncCredentialsChanged($event)" />
+ <span>{{ t("settings.syncSelectionSyncCredentials") }}</span>
</label>
- <template v-else>
- <label class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground hover:text-foreground">
- <input :checked="aiConfigsState === 'all'" :indeterminate="aiConfigsState === 'partial'" :disabled="!catalog.aiConfigs.length" type="checkbox" class="size-3.5 accent-primary" @change="onAiConfigsToggleAll($event)" />
- <span>{{ t("settings.syncSelectionAiConfigs") }} ({{ selection.aiConfigs?.length ?? 0 }}/{{ catalog.aiConfigs.length }})</span>
- </label>
- <label v-for="item in catalog.aiConfigs" :key="item.id" class="flex min-h-7 items-center gap-2 text-sm">
- <input :checked="checked('aiConfigs', item.id)" type="checkbox" class="size-4 accent-primary" @change="toggleSecretId('aiConfigs', item.id, $event)" />
- <span class="min-w-0 truncate">{{ item.label || item.id }}</span>
- </label>
- </template>
- </div>
- <div>
- <label v-if="catalog.pluginUiStorageLocked" class="flex min-h-7 items-center gap-2 text-sm">
- <input :checked="selection.pluginUiStorage === undefined" type="checkbox" class="size-4 accent-primary" @change="onPluginToggleAll($event)" />
- <span>{{ t("settings.syncSelectionPluginLocked") }}</span>
+ <label class="flex min-h-7 items-center gap-2 text-sm">
+ <input
+ :checked="summaryState(connectionSecretsSummary) === 'all'"
+ :indeterminate="summaryState(connectionSecretsSummary) === 'partial'"
+ :disabled="!connectionSecretsSummary.total"
+ type="checkbox"
+ class="size-4 accent-primary"
+ @change="toggleSecretIdsAll('connectionSecrets', $event)"
+ />
+ <span>{{ t("settings.syncSelectionConnectionCredentials") }} ({{ connectionSecretsSummary.selected }}/{{ connectionSecretsSummary.total }})</span>
</label>
- <template v-else>
- <label class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground hover:text-foreground">
- <input :checked="pluginUiStorageState === 'all'" :indeterminate="pluginUiStorageState === 'partial'" :disabled="!catalog.pluginUiStorage.length" type="checkbox" class="size-3.5 accent-primary" @change="onPluginToggleAll($event)" />
- <span>{{ t("settings.syncSelectionPluginData") }} ({{ selection.pluginUiStorage?.length ?? 0 }}/{{ catalog.pluginUiStorage.length }})</span>
+ <label class="flex min-h-7 items-center gap-2 text-sm">
+ <input :checked="summaryState(tunnelSecretsSummary) === 'all'" :indeterminate="summaryState(tunnelSecretsSummary) === 'partial'" :disabled="!tunnelSecretsSummary.total" type="checkbox" class="size-4 accent-primary" @change="toggleSecretIdsAll('tunnelSecrets', $event)" />
+ <span>{{ t("settings.syncSelectionTunnelSecrets") }} ({{ tunnelSecretsSummary.selected }}/{{ tunnelSecretsSummary.total }})</span>
+ </label>
+ <div>
+ <label v-if="catalog.aiConfigsLocked" class="flex min-h-7 items-center gap-2 text-sm">
+ <input :checked="selection.aiConfigs === undefined" type="checkbox" class="size-4 accent-primary" @change="onAiConfigsToggleAll($event)" />
+ <span>{{ t("settings.syncSelectionAiLocked") }}</span>
</label>
- <div v-for="group in pluginUiGroups" :key="group.pluginId" class="pl-1">
+ <template v-else>
<label class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground hover:text-foreground">
- <input :checked="pluginGroupState(group) === 'all'" :indeterminate="pluginGroupState(group) === 'partial'" type="checkbox" class="size-3.5 accent-primary" @change="togglePluginGroup(group.pluginId, $event)" />
- <span class="min-w-0 truncate">{{ group.name }} ({{ pluginGroupSelected(group) }}/{{ group.items.length }})</span>
+ <input :checked="aiConfigsState === 'all'" :indeterminate="aiConfigsState === 'partial'" :disabled="!catalog.aiConfigs.length" type="checkbox" class="size-3.5 accent-primary" @change="onAiConfigsToggleAll($event)" />
+ <span>{{ t("settings.syncSelectionAiConfigs") }} ({{ selection.aiConfigs?.length ?? 0 }}/{{ catalog.aiConfigs.length }})</span>
</label>
- <label v-for="item in group.items" :key="item.key" class="flex min-h-7 items-center gap-2 pl-3 text-sm">
- <input :checked="selection.pluginUiStorage?.some((entry) => entry.pluginId === item.pluginId && entry.key === item.key)" type="checkbox" class="size-4 accent-primary" @change="togglePluginItem(item.pluginId, item.key, $event)" />
- <span class="min-w-0 truncate">{{ item.key }}</span>
+ <label v-for="item in catalog.aiConfigs" :key="item.id" class="flex min-h-7 items-center gap-2 text-sm">
+ <input :checked="checked('aiConfigs', item.id)" type="checkbox" class="size-4 accent-primary" @change="toggleSecretId('aiConfigs', item.id, $event)" />
+ <span class="min-w-0 truncate">{{ item.label || item.id }}</span>
</label>
- </div>
- <p v-if="!catalog.pluginUiStorage.length" class="text-xs text-muted-foreground">{{ t("settings.syncSelectionNoPluginData") }}</p>
- </template>
- </div>
- <p v-if="!catalog.hasEncryptedSecrets && isRestore" class="text-xs text-muted-foreground">{{ t("settings.syncSelectionNoEncrypted") }}</p>
+ </template>
+ </div>
+ <div>
+ <label v-if="catalog.pluginUiStorageLocked" class="flex min-h-7 items-center gap-2 text-sm">
+ <input :checked="selection.pluginUiStorage === undefined" type="checkbox" class="size-4 accent-primary" @change="onPluginToggleAll($event)" />
+ <span>{{ t("settings.syncSelectionPluginLocked") }}</span>
+ </label>
+ <template v-else>
+ <label class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground hover:text-foreground">
+ <input :checked="pluginUiStorageState === 'all'" :indeterminate="pluginUiStorageState === 'partial'" :disabled="!catalog.pluginUiStorage.length" type="checkbox" class="size-3.5 accent-primary" @change="onPluginToggleAll($event)" />
+ <span>{{ t("settings.syncSelectionPluginData") }} ({{ selection.pluginUiStorage?.length ?? 0 }}/{{ catalog.pluginUiStorage.length }})</span>
+ </label>
+ <div v-for="group in pluginUiGroups" :key="group.pluginId" class="pl-1">
+ <label class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground hover:text-foreground">
+ <input :checked="pluginGroupState(group) === 'all'" :indeterminate="pluginGroupState(group) === 'partial'" type="checkbox" class="size-3.5 accent-primary" @change="togglePluginGroup(group.pluginId, $event)" />
+ <span class="min-w-0 truncate">{{ group.name }} ({{ pluginGroupSelected(group) }}/{{ group.items.length }})</span>
+ </label>
+ <label v-for="item in group.items" :key="item.key" class="flex min-h-7 items-center gap-2 pl-3 text-sm">
+ <input :checked="selection.pluginUiStorage?.some((entry) => entry.pluginId === item.pluginId && entry.key === item.key)" type="checkbox" class="size-4 accent-primary" @change="togglePluginItem(item.pluginId, item.key, $event)" />
+ <span class="min-w-0 truncate">{{ item.key }}</span>
+ </label>
+ </div>
+ <p v-if="!catalog.pluginUiStorage.length" class="text-xs text-muted-foreground">{{ t("settings.syncSelectionNoPluginData") }}</p>
+ </template>
+ </div>
+ <p v-if="!catalog.hasEncryptedSecrets && isRestore" class="text-xs text-muted-foreground">{{ t("settings.syncSelectionNoEncrypted") }}</p>
+ </template>
</div>
</details>
diff --git a/apps/desktop/src/components/editor/__tests__/CloudSyncSelectionDialog.spec.ts b/apps/desktop/src/components/editor/__tests__/CloudSyncSelectionDialog.spec.ts
index 47e1c84184..9451e1397f 100644
--- a/apps/desktop/src/components/editor/__tests__/CloudSyncSelectionDialog.spec.ts
+++ b/apps/desktop/src/components/editor/__tests__/CloudSyncSelectionDialog.spec.ts
@@ -329,18 +329,149 @@ describe.each(["restore", "upload"] as const)("CloudSyncSelectionDialog %s group
expect(secretChild.checked).toBe(false);
});
- it("keeps the secrets child off and shows the passphrase hint when no passphrase is available", async () => {
- await mount({ connectionSecrets: ["connection-1"] }, { secretsPassphraseAvailable: false });
+ it("hides unselectable secret checkboxes and shows the passphrase hint when no passphrase is available", async () => {
+ await mount(
+ {
+ hasEncryptedSecrets: true,
+ connectionSecrets: ["connection-1"],
+ tunnelProfiles: [{ id: "tunnel-1", label: "Tunnel" }],
+ tunnelSecrets: ["tunnel-1"],
+ aiConfigs: [{ id: "ai-1", label: "AI" }],
+ pluginUiStorage: [{ pluginId: "devtools", key: "devtools:favorites", pluginName: "Dev Tools" }],
+ },
+ { secretsPassphraseAvailable: false },
+ );
const sections = Array.from(root!.querySelectorAll("details"));
const secretsMaster = sections[4].querySelector<HTMLInputElement>("summary input")!;
- const secretChild = sections[0].querySelectorAll<HTMLInputElement>("input")[2];
+
+ // Nothing encrypted is pre-selected, so the group stays fully unchecked.
expect(secretsMaster.checked).toBe(false);
+ expect(secretsMaster.indeterminate).toBe(false);
+ expect(sections[4].querySelector("summary")!.textContent).toContain("0/5");
- secretChild.click();
+ // Per-item credential rows are removed from the connection/tunnel groups; each shows the hint instead.
+ expect(sections[0].querySelectorAll("input")).toHaveLength(2);
+ expect(sections[0].textContent).toContain("settings.localBackupSecretsPassphraseRequiredHint");
+ expect(sections[1].querySelectorAll("input")).toHaveLength(2);
+ expect(sections[1].textContent).toContain("settings.localBackupSecretsPassphraseRequiredHint");
+
+ // The encrypted group lists only the hint; clicking its master checkbox just expands the group.
+ expect(sections[4].querySelectorAll("label input")).toHaveLength(0);
+ expect(sections[4].textContent).toContain("settings.localBackupSecretsPassphraseRequiredHint");
+ expect(sections[4].open).toBe(false);
+ secretsMaster.click();
await nextTick();
expect(secretsMaster.checked).toBe(false);
- expect(secretChild.checked).toBe(false);
- expect(sections[4].textContent).toContain("settings.localBackupSecretsPassphraseRequiredHint");
+ expect(sections[4].open).toBe(true);
+ });
+
+ it("keeps encrypted items deselected by default when no passphrase is available", async () => {
+ await mount(
+ {
+ connectionSecrets: ["connection-1"],
+ aiConfigs: [{ id: "ai-1", label: "AI" }],
+ pluginUiStorage: [{ pluginId: "devtools", key: "devtools:favorites", pluginName: "Dev Tools" }],
+ },
+ { secretsPassphraseAvailable: false },
+ );
+ const secretsSummaryText = Array.from(root!.querySelectorAll("details"))[4].querySelector("summary")!.textContent;
+ expect(secretsSummaryText).toContain("0/4");
+ });
+
+ it("offers aggregate credential rows inside the encrypted group", async () => {
+ await mount(
+ {
+ connections: [
+ { id: "connection-1", label: "Primary" },
+ { id: "connection-2", label: "Secondary" },
+ ],
+ connectionSecrets: ["connection-1", "connection-2"],
+ tunnelProfiles: [{ id: "tunnel-1", label: "Tunnel" }],
+ tunnelSecrets: ["tunnel-1"],
+ },
+ { secretsPassphraseAvailable: true },
+ );
+ const secretsSection = Array.from(root!.querySelectorAll("details"))[4];
+ const rows = Array.from(secretsSection.querySelectorAll("label"));
+ const connectionRow = rows.find((label) => label.textContent?.includes("settings.syncSelectionConnectionCredentials"))!;
+ const tunnelRow = rows.find((label) => label.textContent?.includes("settings.syncSelectionTunnelSecrets"))!;
+
+ expect(connectionRow.textContent).toContain("(0/2)");
+ expect(tunnelRow.textContent).toContain("(0/1)");
+ // The header total equals the sum of the visible rows: sync credentials 1 + credentials 2 + tunnel 1.
+ expect(secretsSection.querySelector("summary")!.textContent).toContain("0/4");
+
+ connectionRow.querySelector("input")!.click();
+ await nextTick();
+ expect(connectionRow.textContent).toContain("(2/2)");
+ expect(secretsSection.querySelector("summary")!.textContent).toContain("2/4");
+
+ // The aggregate selects the same ids as the per-connection checkboxes under the connections group.
+ const connectionsSection = Array.from(root!.querySelectorAll("details"))[0];
+ const credentialBoxes = Array.from(connectionsSection.querySelectorAll<HTMLInputElement>("label input")).filter((_, index) => index % 2 === 1);
+ expect(credentialBoxes.every((input) => input.checked)).toBe(true);
+
+ tunnelRow.querySelector("input")!.click();
+ await nextTick();
+ expect(secretsSection.querySelector("summary")!.textContent).toContain("3/4");
+ });
+
+ it("drops a credential selection when its connection is deselected", async () => {
+ await mount(
+ {
+ connections: [
+ { id: "connection-1", label: "Primary" },
+ { id: "connection-2", label: "Secondary" },
+ ],
+ connectionSecrets: ["connection-1", "connection-2"],
+ selection: {
+ connections: ["connection-1", "connection-2"],
+ connectionSecrets: ["connection-1", "connection-2"],
+ includeSecrets: true,
+ syncCredentials: true,
+ },
+ },
+ { secretsPassphraseAvailable: true },
+ );
+ const sections = Array.from(root!.querySelectorAll("details"));
+ expect(sections[4].querySelector("summary")!.textContent).toContain("3/3");
+
+ const connectionRow = sections[0].querySelectorAll<HTMLInputElement>("label input")[0];
+ connectionRow.click();
+ await nextTick();
+ // Deselecting connection-1 removes its credential too, so only connection-2's remains selected.
+ expect(sections[4].querySelector("summary")!.textContent).toContain("2/3");
+ const credentialBoxes = Array.from(sections[0].querySelectorAll<HTMLInputElement>("label input")).filter((_, index) => index % 2 === 1);
+ expect(credentialBoxes[0].checked).toBe(false);
+ expect(credentialBoxes[0].disabled).toBe(true);
+ expect(credentialBoxes[1].checked).toBe(true);
+ });
+
+ it("only selects credentials of still-selected owners on the aggregate row", async () => {
+ await mount(
+ {
+ connections: [
+ { id: "connection-1", label: "Primary" },
+ { id: "connection-2", label: "Secondary" },
+ ],
+ connectionSecrets: ["connection-1", "connection-2"],
+ tunnelProfiles: [{ id: "tunnel-1", label: "Tunnel" }],
+ tunnelSecrets: ["tunnel-1"],
+ selection: { connections: ["connection-2"] },
+ },
+ { secretsPassphraseAvailable: true },
+ );
+ const secretsSection = Array.from(root!.querySelectorAll("details"))[4];
+ const rows = Array.from(secretsSection.querySelectorAll("label"));
+ const connectionRow = rows.find((label) => label.textContent?.includes("settings.syncSelectionConnectionCredentials"))!;
+ expect(connectionRow.textContent).toContain("(0/2)");
+
+ connectionRow.querySelector("input")!.click();
+ await nextTick();
+ // connection-1 is deselected, so its credential cannot be aggregated in even though the
+ // catalog lists it; only connection-2's credential is selected.
+ expect(connectionRow.textContent).toContain("(1/2)");
+ expect(secretsSection.querySelector("summary")!.textContent).toContain("1/4");
});
it("disables the confirm action while nothing is selected", async () => {
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 88b16d16cc..b61d66827b 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -8679,6 +8679,7 @@ export default {
syncSelectionRestoreNote: "Unchecked local content will be kept.",
syncSelectionConnections: "Connections and SSH",
syncSelectionConnectionSecrets: "Passwords, SSH passwords/key passphrases, and connection credentials",
+ syncSelectionConnectionCredentials: "Connection credentials",
syncSelectionNoConnections: "No connections",
syncSelectionTunnels: "Shared tunnel profiles",
syncSelectionTunnelSecrets: "Tunnel credentials",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 041dc75b87..928972d25e 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -7929,6 +7929,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "El contenido local sin seleccionar se conservará.",
syncSelectionConnections: "Conexiones y SSH",
syncSelectionConnectionSecrets: "Contraseñas, contraseñas de SSH/frases de contraseña de claves y credenciales de conexión",
+ syncSelectionConnectionCredentials: "Credenciales de conexión",
syncSelectionNoConnections: "No hay conexiones",
syncSelectionTunnels: "Perfiles de túnel compartidos",
syncSelectionTunnelSecrets: "Credenciales del túnel",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 476e2c336d..f8c9142cad 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -8404,6 +8404,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "Konten lokal yang tidak dicentang akan tetap dipertahankan.",
syncSelectionConnections: "Koneksi dan SSH",
syncSelectionConnectionSecrets: "Kata sandi, kata sandi SSH/passphrase kunci, dan kredensial koneksi",
+ syncSelectionConnectionCredentials: "Kredensial koneksi",
syncSelectionNoConnections: "Tidak ada koneksi",
syncSelectionTunnels: "Profil tunnel bersama",
syncSelectionTunnelSecrets: "Kredensial tunnel",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 2b4017bee5..69a34aace7 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -7707,6 +7707,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "I contenuti locali non selezionati verranno mantenuti.",
syncSelectionConnections: "Connessioni e SSH",
syncSelectionConnectionSecrets: "Password, password SSH/passphrase delle chiavi e credenziali di connessione",
+ syncSelectionConnectionCredentials: "Credenziali di connessione",
syncSelectionNoConnections: "Nessuna connessione",
syncSelectionTunnels: "Profili tunnel condivisi",
syncSelectionTunnelSecrets: "Credenziali del tunnel",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index bff6d4fbe1..bafaaeb8a6 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -7720,6 +7720,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "選択されていないローカルデータは保持されます。",
syncSelectionConnections: "接続情報とSSH",
syncSelectionConnectionSecrets: "パスワード、SSHパスワード/鍵のパスフレーズ、接続認証情報",
+ syncSelectionConnectionCredentials: "接続認証情報",
syncSelectionNoConnections: "接続情報はありません",
syncSelectionTunnels: "共有トンネルプロファイル",
syncSelectionTunnelSecrets: "トンネル認証情報",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 7eacc703a3..2fe221e7a5 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -7544,6 +7544,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "선택하지 않은 로컬 콘텐츠는 유지됩니다.",
syncSelectionConnections: "연결 정보 및 SSH",
syncSelectionConnectionSecrets: "비밀번호, SSH 비밀번호/키 암호 및 연결 자격 증명",
+ syncSelectionConnectionCredentials: "연결 자격 증명",
syncSelectionNoConnections: "연결 정보가 없습니다",
syncSelectionTunnels: "공유 터널 프로필",
syncSelectionTunnelSecrets: "터널 자격 증명",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 69a99e533c..a765f2c5b1 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -7707,6 +7707,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "O conteúdo local não selecionado será mantido.",
syncSelectionConnections: "Conexões e SSH",
syncSelectionConnectionSecrets: "Senhas, senhas SSH/frases secretas de chaves e credenciais de conexão",
+ syncSelectionConnectionCredentials: "Credenciais de conexão",
syncSelectionNoConnections: "Nenhuma conexão",
syncSelectionTunnels: "Perfis de túnel compartilhados",
syncSelectionTunnelSecrets: "Credenciais do túnel",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 51326434ab..3869b963fd 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -8959,6 +8959,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "Невыбранные локальные данные останутся без изменений.",
syncSelectionConnections: "Подключения и SSH",
syncSelectionConnectionSecrets: "Пароли, пароли SSH/парольные фразы ключей и учетные данные подключений",
+ syncSelectionConnectionCredentials: "Учетные данные подключений",
syncSelectionNoConnections: "Нет подключений",
syncSelectionTunnels: "Общие профили туннелей",
syncSelectionTunnelSecrets: "Учетные данные туннеля",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 5ef7e9d796..2ce228f366 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -8664,6 +8664,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "未勾选的本地内容会保留。",
syncSelectionConnections: "连接信息与 SSH",
syncSelectionConnectionSecrets: "密码、SSH 密码/密钥口令及连接凭据",
+ syncSelectionConnectionCredentials: "连接凭据",
syncSelectionNoConnections: "无连接项目",
syncSelectionTunnels: "共享隧道配置",
syncSelectionTunnelSecrets: "隧道凭据",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index fa479d31da..b267629f5e 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -7055,6 +7055,7 @@ export default withEnglishFallback({
syncSelectionRestoreNote: "未勾選的本機內容會保留。",
syncSelectionConnections: "連線資訊與 SSH",
syncSelectionConnectionSecrets: "密碼、SSH 密碼/金鑰密語及連線憑證",
+ syncSelectionConnectionCredentials: "連線憑證",
syncSelectionNoConnections: "沒有連線項目",
syncSelectionTunnels: "共用通道設定",
syncSelectionTunnelSecrets: "通道憑證",
diff --git a/crates/dbx-core/src/persistence/cloud_sync.rs b/crates/dbx-core/src/persistence/cloud_sync.rs
index 96e411d5d3..a172865884 100644
--- a/crates/dbx-core/src/persistence/cloud_sync.rs
+++ b/crates/dbx-core/src/persistence/cloud_sync.rs
@@ -447,7 +447,23 @@ pub async fn describe_local_sync_state(
)
.await?;
let mut catalog = describe_sync_snapshot(&snapshot, None)?;
- catalog.connection_secrets = catalog.connections.iter().map(|item| item.id.clone()).collect();
+ // Snapshot connections are already scrubbed, so reload the hydrated rows
+ // and count only connections that would actually carry a secret into the
+ // encrypted payload. Otherwise the export dialog lists every connection
+ // as a credential candidate while a restore of that backup reports fewer.
+ let source_connections = storage.load_connections().await?;
+ let mut connection_secret_ids = Vec::new();
+ for config in &source_connections {
+ let mut secrets = Vec::new();
+ // `true` mirrors every real export path: the Tauri/web commands tie
+ // include_plugin_secrets to include_secrets, so the catalog must count
+ // plugin-secret-only connections as credential candidates too.
+ collect_connection_secrets(&mut secrets, config, true)?;
+ if !secrets.is_empty() {
+ connection_secret_ids.push(config.id.clone());
+ }
+ }
+ catalog.connection_secrets = connection_secret_ids;
catalog.tunnel_secrets = catalog.tunnel_profiles.iter().map(|item| item.id.clone()).collect();
catalog.ai_configs = storage
.load_ai_configs()
@@ -2401,6 +2417,60 @@ async fn build_sensitive_payload(
.await
}
+/// Collects every secret a real export would place in the encrypted payload
+/// for a single connection. Shared with the export catalog so its credential
+/// counts match what a restore of that backup will report.
+fn collect_connection_secrets(
+ secrets: &mut Vec<ConnectionSecretSnapshot>,
+ config: &ConnectionConfig,
+ include_plugin_secrets: bool,
+) -> Result<(), String> {
+ // A transient password must not become durable through a sync snapshot.
+ if config.save_password {
+ push_secret(secrets, &config.id, "password", &config.password);
+ }
+ push_secret(secrets, &config.id, "init_script", config.init_script.as_deref().unwrap_or(""));
+ push_secret(secrets, &config.id, "url_params", config.url_params.as_deref().unwrap_or(""));
+ for (index, layer) in config.transport_layers.iter().enumerate() {
+ match layer {
+ TransportLayerConfig::Ssh(ssh) => {
+ push_secret(secrets, &config.id, &transport_layer_ssh_password_key(index, layer), &ssh.password);
+ push_secret(
+ secrets,
+ &config.id,
+ &transport_layer_ssh_key_passphrase_key(index, layer),
+ &ssh.key_passphrase,
+ );
+ }
+ TransportLayerConfig::Proxy(proxy) => {
+ push_secret(secrets, &config.id, &transport_layer_proxy_password_key(index, layer), &proxy.password);
+ }
+ TransportLayerConfig::HttpTunnel(http) => {
+ push_secret(secrets, &config.id, &transport_layer_http_tunnel_token_key(index, layer), &http.token);
+ }
+ }
+ }
+ push_secret(secrets, &config.id, "redis_sentinel_password", &config.redis_sentinel_password);
+ if let Some(connection_string) = &config.connection_string {
+ push_secret(secrets, &config.id, "connection_string", connection_string);
+ }
+ push_mq_external_config_secrets(secrets, config);
+ push_mqtt_external_config_secret(secrets, config);
+ push_cassandra_tls_secrets(secrets, config);
+ if config.save_password {
+ push_nacos_external_config_secrets(secrets, config);
+ }
+ // Plugin secrets are independent of the primary connection password.
+ // A plugin may persist a token while `save_password` is disabled, so
+ // gate these values only on the explicit plugin export option.
+ if include_plugin_secrets {
+ for (key, secret) in &config.connection_secrets {
+ push_secret(secrets, &config.id, &plugin_connection_secret_key(key)?, secret);
+ }
+ }
+ Ok(())
+}
+
async fn build_sensitive_payload_with_options(
storage: &Storage,
connections: &[ConnectionConfig],
@@ -2409,64 +2479,7 @@ async fn build_sensitive_payload_with_options(
) -> Result<SensitiveSyncPayload, String> {
let mut connection_secrets = Vec::new();
for config in connections {
- // A transient password must not become durable through a sync snapshot.
- if config.save_password {
- push_secret(&mut connection_secrets, &config.id, "password", &config.password);
- }
- push_secret(&mut connection_secrets, &config.id, "init_script", config.init_script.as_deref().unwrap_or(""));
- push_secret(&mut connection_secrets, &config.id, "url_params", config.url_params.as_deref().unwrap_or(""));
- for (index, layer) in config.transport_layers.iter().enumerate() {
- match layer {
- TransportLayerConfig::Ssh(ssh) => {
- push_secret(
- &mut connection_secrets,
- &config.id,
- &transport_layer_ssh_password_key(index, layer),
- &ssh.password,
- );
- push_secret(
- &mut connection_secrets,
- &config.id,
- &transport_layer_ssh_key_passphrase_key(index, layer),
- &ssh.key_passphrase,
- );
- }
- TransportLayerConfig::Proxy(proxy) => {
- push_secret(
- &mut connection_secrets,
- &config.id,
- &transport_layer_proxy_password_key(index, layer),
- &proxy.password,
- );
- }
- TransportLayerConfig::HttpTunnel(http) => {
- push_secret(
- &mut connection_secrets,
- &config.id,
- &transport_layer_http_tunnel_token_key(index, layer),
- &http.token,
- );
- }
- }
- }
- push_secret(&mut connection_secrets, &config.id, "redis_sentinel_password", &config.redis_sentinel_password);
- if let Some(connection_string) = &config.connection_string {
- push_secret(&mut connection_secrets, &config.id, "connection_string", connection_string);
- }
- push_mq_external_config_secrets(&mut connection_secrets, config);
- push_mqtt_external_config_secret(&mut connection_secrets, config);
- push_cassandra_tls_secrets(&mut connection_secrets, config);
- if config.save_password {
- push_nacos_external_config_secrets(&mut connection_secrets, config);
- }
- // Plugin secrets are independent of the primary connection password.
- // A plugin may persist a token while `save_password` is disabled, so
- // gate these values only on the explicit plugin export option.
- if options.include_plugin_secrets {
- for (key, secret) in &config.connection_secrets {
- push_secret(&mut connection_secrets, &config.id, &plugin_connection_secret_key(key)?, secret);
- }
- }
+ collect_connection_secrets(&mut connection_secrets, config, options.include_plugin_secrets)?;
}
// Loading AI configurations includes decrypting their secret blobs. A
@@ -3263,7 +3276,7 @@ mod tests {
use super::{
apply_sensitive_payload, apply_sync_snapshot, build_sensitive_payload, build_sync_snapshot,
build_sync_snapshot_with_options, build_sync_snapshot_with_saved_secrets, decrypt_sensitive_payload,
- encrypt_sensitive_payload, encrypt_snippet_snapshot, finalize_snippet_migration,
+ describe_local_sync_state, encrypt_sensitive_payload, encrypt_snippet_snapshot, finalize_snippet_migration,
forget_webdav_sync_secrets_passphrase, gitee_snippet_payload, gitlab_instance_url, is_legacy_dbx_snapshot,
normalized_remote_path, parent_collection_paths, parse_legacy_dbx_snapshot, parse_snippet_snapshot,
prepare_legacy_snippet_snapshot, resolve_snippet_token, resolve_webdav_password,
@@ -5193,6 +5206,26 @@ mod tests {
assert!(target.load_connections().await.unwrap()[0].password.is_empty());
}
+ #[tokio::test]
+ async fn local_sync_catalog_lists_only_connections_with_exportable_secrets() {
+ let storage = crate::persistence::test_storage::open(&temp_db_path("sync-catalog-secret-count")).await.unwrap();
+ let mut unsaved = postgres_connection("unsaved", "transient-secret");
+ unsaved.save_password = false;
+ storage
+ .save_connections(&[
+ postgres_connection("with-secret", "db-secret"),
+ postgres_connection("no-secret", ""),
+ unsaved,
+ ])
+ .await
+ .unwrap();
+
+ let catalog = describe_local_sync_state(&storage, None, None).await.unwrap();
+
+ assert_eq!(catalog.connections.len(), 3);
+ assert_eq!(catalog.connection_secrets, vec!["with-secret".to_string()]);
+ }
+
#[tokio::test]
async fn wrong_sync_passphrase_does_not_modify_the_destination() {
let source = crate::persistence::test_storage::open(&temp_db_path("sync-wrong-pass-source")).await.unwrap();