From 556c31388091c7d1eb519589396f1b8a0bf31d3d Mon Sep 17 00:00:00 2001 From: U1 <56990620+CHNHJF@users.noreply.github.com> Date: Mon, 21 Sep 2026 12:28:31 +0800 Subject: [PATCH] fix(ai): format pre-load database fallback with shared label helper --- .../src/components/editor/AiAssistant.vue | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vue index 9b651a508d..601bc4e397 100644 --- a/apps/desktop/src/components/editor/AiAssistant.vue +++ b/apps/desktop/src/components/editor/AiAssistant.vue @@ -1521,7 +1521,25 @@ const selectedDatabaseValues = computed(() => new Set(selectedDatabases.value)); const selectedDatabaseLabel = computed(() => { if (!props.connection) return t("editor.selectDatabase"); const labels = dbSelectOptions.value.filter((option) => selectedDatabaseValues.value.has(option.database)).map((option) => option.label); - return labels.length ? labels.join(", ") : t("editor.selectDatabase"); + if (labels.length) return labels.join(", "); + // The options list loads asynchronously (on popover open or connection + // switch), so before it arrives the selection is still valid — fall back to + // the raw database names instead of the "select database" placeholder, + // which made the button look unselected while the dropdown showed a check. + // Format with the same helper as the option labels so the text stays + // identical once the options load (e.g. Redis "db0", localized defaults). + const raw = [...selectedDatabaseValues.value]; + if (raw.length) { + return raw + .map((database) => + formatDatabaseLabel(props.connection, database, { + defaultDatabase: t("editor.defaultDatabase"), + noDatabase: t("editor.noDatabase"), + }), + ) + .join(", "); + } + return t("editor.selectDatabase"); }); function syncSelectedDatabases() {