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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(ai): add independent conversation font settings
t8y2e9998e28067a
diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vueindex d9a6d5967e..7bbab812dc 100644--- a/apps/desktop/src/components/editor/AiAssistant.vue+++ b/apps/desktop/src/components/editor/AiAssistant.vue@@ -66,6 +66,7 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";import { usePromptTemplateStore } from "@/stores/promptTemplateStore";import { useUserSkillStore } from "@/stores/userSkillStore";import { buildSelectedSkillChips, capSkillsToCharLimit, removeSkillIds, userSkillSourceOfId } from "@/lib/ai/userSkillSelection";+import { aiConversationTypographyCssVariables } from "@/lib/ai/aiTypography";import { ACTIVE_SKILLS_TOTAL_MAX, type ReadUserSkill, type ReadUserSkillFailure, type UserSkillFailureReason, type UserSkillRootSettings } from "@/types/userSkills";import { supportsAiAssistantContext } from "@/lib/database/databaseFeatureSupport";import ConnectionIcon from "@/components/icons/ConnectionIcon.vue";@@ -210,6 +211,12 @@ const AiHtmlPreview = defineAsyncComponent({loader: () => import("@/components/ai/rich/AiHtmlPreview.vue"),});const settings = useSettingsStore();+const aiTypographyStyle = computed(() =>+ aiConversationTypographyCssVariables({+ fontFamily: settings.editorSettings.aiFontFamily,+ fontSize: settings.editorSettings.aiFontSize,+ }),+);const connectionStore = useConnectionStore();const savedSqlStore = useSavedSqlStore();const promptTemplateStore = usePromptTemplateStore();@@ -5419,7 +5426,7 @@ async function openExternalUrl(url: string) {</script><template>- <div ref="assistantRootRef" data-ai-assistant-root class="flex h-full min-h-0 flex-col overflow-hidden" @dragenter="onAttachmentDragEnter" @dragover="onAttachmentDragOver" @dragleave="onAttachmentDragLeave" @drop="onAttachmentDrop">+ <div ref="assistantRootRef" data-ai-assistant-root class="flex h-full min-h-0 flex-col overflow-hidden" :style="aiTypographyStyle" @dragenter="onAttachmentDragEnter" @dragover="onAttachmentDragOver" @dragleave="onAttachmentDragLeave" @drop="onAttachmentDrop"><div class="flex items-center gap-2 border-b px-3 shrink-0" :class="settings.editorSettings.appLayout === 'classic' ? 'h-9' : 'h-10'"><span class="flex flex-1 self-stretch items-center truncate text-xs font-medium" data-tauri-drag-region>{{ chatTitle }}@@ -5655,7 +5662,7 @@ async function openExternalUrl(url: string) {data-edit-textareav-model="editingContent"rows="3"- class="w-full resize-none rounded-lg border bg-background px-3 py-2 text-xs outline-none focus:ring-1 focus:ring-primary"+ class="ai-conversation-text w-full resize-none rounded-lg border bg-background px-3 py-2 text-xs outline-none focus:ring-1 focus:ring-primary"@keydown="onEditKeydown($event, i)"@compositionstart="editCompositionActive = true"@compositionend="editCompositionActive = false"@@ -5707,7 +5714,7 @@ async function openExternalUrl(url: string) {class="w-44"/></div>- <div v-if="messageReferenceMentions(msg).length || msg.content" class="min-w-0 rounded-lg bg-primary px-3 py-2 text-xs text-primary-foreground">+ <div v-if="messageReferenceMentions(msg).length || msg.content" class="ai-conversation-text min-w-0 rounded-lg bg-primary px-3 py-2 text-xs text-primary-foreground"><div v-if="messageReferenceMentions(msg).length" class="mb-1.5 flex flex-wrap justify-end gap-1"><buttonv-for="mention in messageReferenceMentions(msg)"@@ -5777,7 +5784,7 @@ async function openExternalUrl(url: string) {<!-- Keep the metadata row as wide as the reply card so its export action stays right-aligned. --><div v-else-if="msg.content || msg.reasoning || msg.isThinking" class="flex w-full max-w-[95%] min-w-0 flex-col">- <div class="w-full rounded-lg bg-muted px-3 py-2 text-xs leading-relaxed [overflow-wrap:anywhere]">+ <div data-ai-assistant-message-content class="ai-conversation-text w-full rounded-lg bg-muted px-3 py-2 text-xs leading-relaxed [overflow-wrap:anywhere]"><div v-if="msg.reasoning || msg.isThinking" class="mb-2"><button class="flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors" @click="toggleReasoning()"><ChevronRight class="h-3 w-3 transition-transform duration-200" :class="{ 'rotate-90': reasoningExpanded }" />@@ -6330,7 +6337,7 @@ async function openExternalUrl(url: string) {ref="promptTextareaRef"v-model="prompt":style="{ height: `${textareaHeight}px`, maxHeight: `${maxTextareaHeight()}px` }"- class="w-full resize-none bg-transparent text-xs outline-none placeholder:text-muted-foreground mb-1"+ class="ai-conversation-text w-full resize-none bg-transparent text-xs outline-none placeholder:text-muted-foreground mb-1":placeholder="activePlaceholder"@input="refreshMentionState"@click="refreshMentionState"@@ -6675,6 +6682,11 @@ async function openExternalUrl(url: string) {</template><style scoped>+.ai-conversation-text {+ font-family: var(--dbx-ai-content-font-family, inherit);+ font-size: var(--dbx-ai-content-font-size, 0.75rem);+}+.ai-prompt-context-row--compact .ai-prompt-context-spacer {flex: 0 0 0;}@@ -6791,7 +6803,7 @@ async function openExternalUrl(url: string) {border-radius: 0.25rem;background: var(--muted);padding: 0.125rem 0.375rem;- font-size: 11px;+ font-size: var(--dbx-ai-inline-code-font-size, 11px);font-family: ui-monospace, monospace;}.ai-markdown :deep(pre) {@@ -6873,6 +6885,11 @@ html.dbx-legacy-webview.dark .ai-markdown :deep(.ai-markdown-table-wrap:hover::-min-height: 1lh;}+.ai-code-block {+ font-family: ui-monospace, monospace;+ font-size: var(--dbx-ai-code-font-size, 0.75rem);+}+.ai-message-scroll :deep([data-slot="scroll-area-viewport"]) {overflow-anchor: none;}diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vueindex 83021b760f..cc78015224 100644--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue@@ -271,6 +271,16 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";import { usePromptTemplateStore } from "@/stores/promptTemplateStore";import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";import { currentLocale, previewLocale, restoreLocalePreview, setLocale, type Locale } from "@/i18n";+import {+ AI_CONVERSATION_FONT_FAMILY_DEFAULT,+ AI_CONVERSATION_FONT_SIZE_DEFAULT,+ AI_CONVERSATION_FONT_SIZE_MAX,+ AI_CONVERSATION_FONT_SIZE_MIN,+ aiConversationFontFamilyForName,+ normalizeAiConversationFontFamily,+ normalizeAiConversationFontFamilyInput,+ normalizeAiConversationFontSize,+} from "@/lib/ai/aiTypography";import {SETTINGS_SEARCH_DEFINITIONS,TOOLBAR_VISIBILITY_ITEMS,@@ -592,6 +602,9 @@ function createEmptyTableColumnTemplateRow(): TableColumnTemplateGridRow {// Local edit stateconst editFontFamily = ref(settingsStore.editorSettings.fontFamily);const editFontSize = ref(settingsStore.editorSettings.fontSize);+const editAiFontFamily = ref(settingsStore.editorSettings.aiFontFamily);+const editAiFontSize = ref<number | string>(settingsStore.editorSettings.aiFontSize);+const aiTypographySaving = ref(false);const editTableFontFamily = ref(settingsStore.editorSettings.tableFontFamily);const editUiFontFamily = ref(settingsStore.editorSettings.uiFontFamily);const editUiScale = ref(settingsStore.editorSettings.uiScale);@@ -1589,6 +1602,12 @@ const systemFontOptions = computed(() => {const tableFontOptions = computed(() => buildFontFamilyOptions(systemFonts.value, [editTableFontFamily.value], [DEFAULT_DATA_GRID_FONT_FAMILY]));+const aiFontOptions = computed(() => {+ const options = new Set([DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY, ...systemFonts.value.map(aiConversationFontFamilyForName)]);+ if (editAiFontFamily.value) options.add(editAiFontFamily.value);+ return [...options];+});+const uiFontOptions = computed(() => {const options = new Set([SYSTEM_UI_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY, ...systemFontOptions.value]);if (editUiFontFamily.value) options.add(editUiFontFamily.value);@@ -1601,6 +1620,11 @@ function displayUiFontFamily(value: string): string {return displayFontFamily(value);}+function displayAiFontFamily(value: string): string {+ if (!value) return t("ai.conversationFontFollowInterface");+ return displayUiFontFamily(value);+}+function fontOptionStyle(value: string, selectedValue = editFontFamily.value) {return isPresetFontFamily(value) || uiFontPreviewValues.has(value) || value === selectedValue ? { fontFamily: value } : undefined;}@@ -1630,6 +1654,8 @@ const hasImportedSettingsPendingApply = ref(false);function syncEditorSettingsDraftFromStore() {editFontFamily.value = settingsStore.editorSettings.fontFamily;editFontSize.value = settingsStore.editorSettings.fontSize;+ editAiFontFamily.value = settingsStore.editorSettings.aiFontFamily;+ editAiFontSize.value = settingsStore.editorSettings.aiFontSize;editTableFontFamily.value = settingsStore.editorSettings.tableFontFamily;editUiFontFamily.value = settingsStore.editorSettings.uiFontFamily;editUiScale.value = settingsStore.editorSettings.uiScale;@@ -2716,6 +2742,44 @@ function onUiFontFamilyChange(v: any) {}}+async function persistAiTypography(partial: Partial<Pick<EditorSettings, "aiFontFamily" | "aiFontSize">>) {+ aiTypographySaving.value = true;+ try {+ await settingsStore.updateEditorSettingsAndPersist(partial);+ } catch (error) {+ applySettingsErrorToast(error);+ } finally {+ editAiFontFamily.value = settingsStore.editorSettings.aiFontFamily;+ editAiFontSize.value = settingsStore.editorSettings.aiFontSize;+ aiTypographySaving.value = false;+ }+}++function onAiFontFamilyChange(value: unknown) {+ const fontFamily = normalizeAiConversationFontFamily(value);+ editAiFontFamily.value = fontFamily;+ if (fontFamily !== settingsStore.editorSettings.aiFontFamily) void persistAiTypography({ aiFontFamily: fontFamily });+}++function commitAiFontSize() {+ const fontSize = normalizeAiConversationFontSize(editAiFontSize.value);+ editAiFontSize.value = fontSize;+ if (fontSize !== settingsStore.editorSettings.aiFontSize) void persistAiTypography({ aiFontSize: fontSize });+}++function blurAiFontSizeInput(event: KeyboardEvent) {+ (event.target as HTMLInputElement | null)?.blur();+}++function resetAiTypography() {+ editAiFontFamily.value = AI_CONVERSATION_FONT_FAMILY_DEFAULT;+ editAiFontSize.value = AI_CONVERSATION_FONT_SIZE_DEFAULT;+ void persistAiTypography({+ aiFontFamily: AI_CONVERSATION_FONT_FAMILY_DEFAULT,+ aiFontSize: AI_CONVERSATION_FONT_SIZE_DEFAULT,+ });+}+const themeSelectValue = computed(() => {if (editTheme.value === "custom") {return `custom:${editActiveCustomThemeId.value}`;@@ -3144,6 +3208,7 @@ async function revealSettingsSearchTarget(result: SettingsSearchEntry) {async function selectSettingsSearchResult(result: SettingsSearchEntry) {pendingSettingsSearchResult = result;if (result.shortcutId) shortcutSearchQuery.value = result.title;+ if (result.category === "ai") aiConfigListMode.value = "list";applySettingsSearchRoute(result);settingsSearchQuery.value = "";settingsSearchOpen.value = false;@@ -9241,6 +9306,80 @@ LIMIT 100;</pre</div></div>+ <div v-if="aiConfigListMode === 'list'" data-settings-search-id="ai-typography" class="space-y-3">+ <Separator />+ <div class="settings-item space-y-3 rounded-md border bg-muted/20 px-3 py-2">+ <div class="flex items-start justify-between gap-3">+ <div class="space-y-1">+ <h3 class="text-sm font-medium">{{ t("ai.conversationTypography") }}</h3>+ <p class="text-xs text-muted-foreground">{{ t("ai.conversationTypographyDescription") }}</p>+ </div>+ <Button type="button" size="sm" variant="ghost" class="h-7 shrink-0 gap-1 px-2 text-xs" :disabled="aiTypographySaving || (editAiFontFamily === AI_CONVERSATION_FONT_FAMILY_DEFAULT && Number(editAiFontSize) === AI_CONVERSATION_FONT_SIZE_DEFAULT)" @click="resetAiTypography">+ <RotateCcw class="h-3.5 w-3.5" />+ {{ t("settings.reset") }}+ </Button>+ </div>+ <div class="grid gap-3 sm:grid-cols-[minmax(0,1fr)_9rem]">+ <div class="min-w-0 space-y-1.5">+ <Label>{{ t("ai.conversationFontFamily") }}</Label>+ <SearchableSelect+ :model-value="editAiFontFamily"+ :options="aiFontOptions"+ :placeholder="t('ai.conversationFontFollowInterface')"+ :search-placeholder="t('settings.searchFont')"+ :empty-text="t('settings.noFontsFound')"+ :loading-text="t('settings.loadingFonts')"+ :disabled="aiTypographySaving"+ allow-custom+ clearable+ :display-name="displayAiFontFamily"+ :normalize-custom="normalizeAiConversationFontFamilyInput"+ :trigger-class="appearanceFontSearchTriggerClass"+ :trigger-icon-class="appearanceFontSearchTriggerIconClass"+ content-class="w-[var(--reka-popover-trigger-width)] min-w-[260px]"+ @update:model-value="onAiFontFamilyChange"+ @update:open="(open: boolean) => open && loadSystemFontOptions()"+ >+ <template #trigger-label="{ label, loading }">+ <span class="truncate" :style="editAiFontFamily ? { fontFamily: editAiFontFamily } : undefined">+ {{ loading ? t("settings.loadingFonts") : label }}+ </span>+ </template>+ <template #option-label="{ option, label }">+ <span class="truncate" :style="fontOptionStyle(option, editAiFontFamily)">{{ label }}</span>+ </template>+ <template #custom-option-label="{ value }">+ <span class="truncate" :style="{ fontFamily: value }">+ {{ t("settings.useCustomFont", { font: readableFontFamily(value) }) }}+ </span>+ </template>+ </SearchableSelect>+ </div>+ <div class="space-y-1.5">+ <Label for="ai-conversation-font-size">{{ t("ai.conversationFontSize") }}</Label>+ <div class="flex items-center gap-2">+ <Input+ id="ai-conversation-font-size"+ v-model.number="editAiFontSize"+ type="number"+ :min="AI_CONVERSATION_FONT_SIZE_MIN"+ :max="AI_CONVERSATION_FONT_SIZE_MAX"+ step="1"+ class="h-8 text-xs"+ :disabled="aiTypographySaving"+ @change="commitAiFontSize"+ @keydown.enter="blurAiFontSizeInput"+ />+ <span class="text-xs text-muted-foreground">px</span>+ </div>+ <p class="text-[11px] text-muted-foreground">+ {{ t("ai.conversationFontSizeRange", { min: AI_CONVERSATION_FONT_SIZE_MIN, max: AI_CONVERSATION_FONT_SIZE_MAX }) }}+ </p>+ </div>+ </div>+ </div>+ </div>+<!-- Agent Turn Limit (list mode, global) --><div v-if="aiConfigListMode === 'list'" class="space-y-3"><Separator />diff --git a/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts b/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.tsindex d72b7b769b..53357ec9a5 100644--- a/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts+++ b/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts@@ -16,13 +16,30 @@ import { useConnectionStore } from "@/stores/connectionStore";import type { ConnectionConfig } from "@/types/database";import type { PluginAiRecommendationHostUpdate } from "@/lib/plugins/pluginHostBridge";+const aiAssistantMountApi = vi.hoisted(() => ({+ conversations: [] as Array<Record<string, unknown>>,+ runAgentStream: undefined as undefined | ((onEvent: (event: { type: string; delta?: string }) => void) => Promise<string>),+}));++vi.mock("@/lib/ai/ai", async (importOriginal) => {+ const actual = await importOriginal<Record<string, unknown>>();+ return {+ ...actual,+ runAgentStream: async (...args: unknown[]) => {+ const onEvent = args[2] as (event: { type: string; delta?: string }) => void;+ return aiAssistantMountApi.runAgentStream?.(onEvent) ?? "";+ },+ };+});+vi.mock("@/lib/backend/api", async (importOriginal) => {const actual = await importOriginal<Record<string, unknown>>();const empty = () => Promise.resolve([]);return {...actual,- loadAiConversations: empty,+ loadAiConversations: () => Promise.resolve(aiAssistantMountApi.conversations),loadAiRuns: empty,+ saveAiConversation: () => Promise.resolve(),readUserSkills: empty,loadAiConfigs: empty,listPlugins: empty,@@ -36,6 +53,8 @@ vi.mock("@/lib/backend/api", async (importOriginal) => {const cleanups: Array<() => void> = [];afterEach(() => {+ aiAssistantMountApi.conversations = [];+ aiAssistantMountApi.runAgentStream = undefined;while (cleanups.length) cleanups.pop()?.();});@@ -64,6 +83,104 @@ async function mountPanel(aiConfigLoaded: boolean, connection?: ConnectionConfig}describe("AiAssistant mount", () => {+ it("applies custom typography to restored message content and the prompt only", async () => {+ aiAssistantMountApi.conversations = [+ {+ id: "typography-conversation",+ title: "Typography",+ connectionName: "",+ connectionId: "",+ database: "",+ messages: [+ { role: "user", content: "User message" },+ { role: "assistant", content: "### Heading\n\nInline `value`.\n\n```sql\nSELECT 1\n```" },+ ],+ createdAt: "2026-09-27T00:00:00.000Z",+ updatedAt: "2026-09-27T00:00:00.000Z",+ },+ ];++ const { container, errors } = await mountPanel(true, undefined, (settings) => {+ settings.restoreLastConversation = true;+ settings.editorSettings.aiFontFamily = "Georgia, serif";+ settings.editorSettings.aiFontSize = 18;+ });++ const root = container.querySelector<HTMLElement>("[data-ai-assistant-root]");+ expect(root?.style.getPropertyValue("--dbx-ai-content-font-family")).toBe("Georgia, serif");+ expect(root?.style.getPropertyValue("--dbx-ai-content-font-size")).toBe("18px");+ expect(root?.style.getPropertyValue("--dbx-ai-code-font-size")).toBe("18px");+ expect(container.querySelector("[data-ai-user-message-content]")?.closest(".ai-conversation-text")).not.toBeNull();+ expect(container.querySelector("[data-ai-assistant-message-content]")?.classList.contains("ai-conversation-text")).toBe(true);+ expect(container.querySelector(".ai-markdown code")).not.toBeNull();+ expect(container.querySelector(".ai-code-block")).not.toBeNull();+ expect(container.querySelector("textarea.ai-conversation-text")).not.toBeNull();+ expect(container.firstElementChild?.firstElementChild?.classList.contains("ai-conversation-text")).toBe(false);+ expect(errors.map(String)).toEqual([]);+ });++ it("keeps the same typography scope while an answer streams and after it completes", async () => {+ let finishStream!: () => void;+ const streamPending = new Promise<void>((resolve) => {+ finishStream = resolve;+ });+ aiAssistantMountApi.runAgentStream = async (onEvent) => {+ onEvent({ type: "text_delta", delta: "**Streaming answer**" });+ await streamPending;+ onEvent({ type: "agent_end" });+ return "Streaming answer";+ };++ const recommendation = {+ pluginId: "sample.plugin",+ pluginName: "Sample",+ contributionId: "workbench",+ workbenchId: "cluster",+ context: { connectionId: "plugin-connection" },+ items: [{ id: "stream", label: "Stream answer", prompt: "Stream answer" }],+ };+ const { container, errors } = await mountPanel(+ true,+ { id: "plugin-connection", name: "Sample", db_type: "plugin", plugin_id: "sample.plugin", host: "localhost", port: 22, username: "", password: "" },+ (settings) => {+ settings.aiConfigs = [+ {+ id: "custom",+ name: "Custom",+ provider: "openai-compatible",+ apiKey: "test-key",+ authMethod: "api-key",+ endpoint: "https://example.com/v1",+ model: "test-model",+ apiStyle: "completions",+ isDefault: true,+ },+ ];+ settings.activeModel = { configId: "custom", modelId: "test-model" };+ settings.editorSettings.aiFontFamily = "Georgia, serif";+ settings.editorSettings.aiFontSize = 18;+ },+ recommendation,+ );++ container.querySelector<HTMLButtonElement>('button[title="Stream answer"]')!.click();+ await new Promise((resolve) => setTimeout(resolve, 30));++ const streamingContent = container.querySelector<HTMLElement>("[data-ai-assistant-message-content]");+ expect(streamingContent?.classList.contains("ai-conversation-text")).toBe(true);+ expect(streamingContent?.textContent).toContain("Streaming answer");+ expect(container.querySelector("[data-ai-generation-status]")).not.toBeNull();++ finishStream();+ await new Promise((resolve) => setTimeout(resolve, 30));++ const completedContent = container.querySelector<HTMLElement>("[data-ai-assistant-message-content]");+ expect(completedContent?.classList.contains("ai-conversation-text")).toBe(true);+ expect(completedContent?.textContent).toContain("Streaming answer");+ expect(container.querySelector("[data-ai-generation-status]")).toBeNull();+ expect(errors.map(String)).toEqual([]);+ });+it("keeps the real Agent mode and an interactive picker after clicking a plugin recommendation", async () => {const { container, errors } = await mountPanel(true,diff --git a/apps/desktop/src/components/editor/__tests__/AiAssistant.typography.spec.ts b/apps/desktop/src/components/editor/__tests__/AiAssistant.typography.spec.tsnew file mode 100644index 0000000000..39409f284b--- /dev/null+++ b/apps/desktop/src/components/editor/__tests__/AiAssistant.typography.spec.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from "vitest";+import assistantSource from "../AiAssistant.vue?raw";++describe("AiAssistant typography scope", () => {+ it("uses one scoped content wrapper for streaming and completed Markdown", () => {+ expect(assistantSource).toContain("messageRenderer.value.render(msg.content, { streaming: isStreamingMessage(msg) })");+ expect(assistantSource).toContain('data-ai-assistant-message-content class="ai-conversation-text');+ expect(assistantSource).toContain('data-ai-user-message-content class="whitespace-pre-wrap"');+ });++ it("scopes typography to message and input text while preserving monospace code", () => {+ expect(assistantSource).toContain('data-ai-assistant-root class="flex h-full min-h-0 flex-col overflow-hidden" :style="aiTypographyStyle"');+ expect(assistantSource).toContain('data-edit-textarea\n v-model="editingContent"');+ expect(assistantSource).toContain('class="ai-conversation-text w-full resize-none rounded-lg');+ expect(assistantSource).toContain('class="ai-conversation-text w-full resize-none bg-transparent');+ expect(assistantSource).toMatch(/\.ai-markdown :deep\(code\)[\s\S]*font-family: ui-monospace, monospace;/);+ expect(assistantSource).toMatch(/\.ai-code-block \{[\s\S]*font-family: ui-monospace, monospace;/);+ expect(assistantSource).not.toContain("document.body.style.fontFamily");+ });+});diff --git a/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTypography.spec.ts b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTypography.spec.tsnew file mode 100644index 0000000000..ef18694b4e--- /dev/null+++ b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.aiTypography.spec.ts@@ -0,0 +1,25 @@+import { describe, expect, it } from "vitest";+import { SETTINGS_SEARCH_DEFINITIONS } from "@/lib/settings/settingsSearch";+import dialogSource from "../EditorSettingsDialog.vue?raw";++describe("EditorSettingsDialog AI typography settings", () => {+ it("exposes the family and size controls through settings search", () => {+ const definitions = SETTINGS_SEARCH_DEFINITIONS.filter((definition) => definition.id.startsWith("ai-conversation-font-"));++ expect(definitions).toEqual([expect.objectContaining({ id: "ai-conversation-font-family", category: "ai", targetId: "ai-typography" }), expect.objectContaining({ id: "ai-conversation-font-size", category: "ai", targetId: "ai-typography" })]);+ expect(dialogSource).toContain('data-settings-search-id="ai-typography"');+ expect(dialogSource).toContain('id="ai-conversation-font-size"');+ });++ it("persists each control immediately and offers a dedicated reset", () => {+ expect(dialogSource).toContain('@update:model-value="onAiFontFamilyChange"');+ expect(dialogSource).toContain('@change="commitAiFontSize"');+ expect(dialogSource).toContain('@click="resetAiTypography"');+ expect(dialogSource).toContain("settingsStore.updateEditorSettingsAndPersist(partial)");+ });++ it("keeps system and custom conversation fonts independent from editor fallbacks", () => {+ expect(dialogSource).toContain("systemFonts.value.map(aiConversationFontFamilyForName)");+ expect(dialogSource).toContain(':normalize-custom="normalizeAiConversationFontFamilyInput"');+ });+});diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 4c9e7982e4..2342987407 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -3332,6 +3332,12 @@ export default withEnglishFallback({pluginFollowUp: "Cari kontekst barədə əlavə sual verin…",defaultAiMode: "Standart AI rejimi",defaultAiModeDescription: "Yeni AI söhbətinə başlayarkən istifadə olunan rejim. Cari söhbətdə rejimin dəyişdirilməsi bu parametri dəyişmir.",+ conversationTypography: "AI söhbət şrifti",+ conversationTypographyDescription: "SQL redaktorunu və ya interfeysi dəyişmədən AI mesajlarının və giriş sahəsinin şriftini təyin edin.",+ conversationFontFamily: "AI söhbət şrifti",+ conversationFontFollowInterface: "İnterfeys şriftindən istifadə et",+ conversationFontSize: "AI söhbət şriftinin ölçüsü",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Standart olaraq avtomatik niyyət marşrutlaşdırması",defaultAutoRoutingDescription: "Yeni AI söhbətləri Avtomatik seçimi ilə başlayır: AI göndərərkən niyyətinizi müəyyən edib uyğun əməliyyata yönləndirir. Cari söhbətə təsir etmir.",restoreLastConversation: "Son AI söhbətini bərpa et",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 3db12bb563..b1f889377f 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -3699,6 +3699,12 @@ export default {pluginFollowUp: "Ask a follow-up about the current context…",defaultAiMode: "Default AI Mode",defaultAiModeDescription: "Mode used when starting a new AI conversation. Switching mode in the current conversation does not change this setting.",+ conversationTypography: "Conversation Typography",+ conversationTypographyDescription: "Set the font used for AI messages and the prompt input without changing the SQL editor or interface.",+ conversationFontFamily: "AI Conversation Font",+ conversationFontFollowInterface: "Follow interface font",+ conversationFontSize: "AI Conversation Font Size",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Auto Intent Routing by Default",defaultAutoRoutingDescription: "Start new AI conversations with the Auto action: the assistant detects your intent at send time and routes it to a concrete action. Does not change the current conversation.",restoreLastConversation: "Restore last AI conversation",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 8d371c83cb..85addead74 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -3443,6 +3443,12 @@ export default withEnglishFallback({pluginFollowUp: "Haz una pregunta de seguimiento sobre el contexto actual…",defaultAiMode: "Modo de IA predeterminado",defaultAiModeDescription: "Modo usado al iniciar una nueva conversación de IA. Cambiar de modo en la conversación actual no modifica esta configuración.",+ conversationTypography: "Tipografía de conversación de IA",+ conversationTypographyDescription: "Configura la fuente de los mensajes y del campo de entrada de IA sin cambiar el editor SQL ni la interfaz.",+ conversationFontFamily: "Fuente de conversación de IA",+ conversationFontFollowInterface: "Usar la fuente de la interfaz",+ conversationFontSize: "Tamaño de fuente de conversación de IA",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Enrutamiento de intención automático por defecto",defaultAutoRoutingDescription: "Inicia nuevas conversaciones de IA con la acción Auto: la IA detecta tu intención al enviar y la dirige a una acción concreta. No cambia la conversación actual.",restoreLastConversation: "Restaurar la última conversación de IA al abrir",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 34f282edf6..d7eb8c5374 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -3262,6 +3262,12 @@ export default withEnglishFallback({pluginFollowUp: "Fai una domanda di approfondimento sul contesto attuale…",defaultAiMode: "Modalità IA predefinita",defaultAiModeDescription: "Modalità usata all'avvio di una nuova conversazione IA. Cambiare modalità nella conversazione corrente non modifica questa impostazione.",+ conversationTypography: "Tipografia della conversazione IA",+ conversationTypographyDescription: "Imposta il carattere dei messaggi e del campo di input IA senza modificare l'editor SQL o l'interfaccia.",+ conversationFontFamily: "Carattere della conversazione IA",+ conversationFontFollowInterface: "Usa il carattere dell'interfaccia",+ conversationFontSize: "Dimensione carattere della conversazione IA",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Routing automatico delle intenzioni predefinito",defaultAutoRoutingDescription: "Avvia le nuove conversazioni IA con l'azione Auto: l'IA rileva l'intento all'invio e lo instrada verso un'azione concreta. Non modifica la conversazione corrente.",restoreLastConversation: "Ripristina l'ultima conversazione IA all'apertura",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 0607984f3d..835fa6f86f 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -3402,6 +3402,12 @@ export default withEnglishFallback({pluginFollowUp: "現在のコンテキストについて追加で質問…",defaultAiMode: "既定の AI モード",defaultAiModeDescription: "新しい AI 会話を開始するときに使用されるモードです。現在の会話でモードを切り替えてもこの設定は変更されません。",+ conversationTypography: "AI 会話のフォント",+ conversationTypographyDescription: "SQL エディターやインターフェースを変更せずに、AI メッセージと入力欄のフォントを設定します。",+ conversationFontFamily: "AI 会話のフォント",+ conversationFontFollowInterface: "インターフェースのフォントに従う",+ conversationFontSize: "AI 会話のフォントサイズ",+ conversationFontSizeRange: "{min}~{max} px",defaultAutoRouting: "自動インテントルーティングを既定で有効化",defaultAutoRoutingDescription: "新しい AI 会話を「自動」アクションで開始します。送信時に AI が意図を判定して具体的なアクションにルーティングします。現在の会話には影響しません。",restoreLastConversation: "起動時に最後の AI 会話を復元",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex e5c8466396..789067fd33 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -3403,6 +3403,12 @@ export default withEnglishFallback({pluginFollowUp: "현재 컨텍스트에 대해 추가로 질문…",defaultAiMode: "기본 AI 모드",defaultAiModeDescription: "새 AI 대화를 시작할 때 사용되는 모드입니다. 현재 대화에서 모드를 전환해도 이 설정은 변경되지 않습니다.",+ conversationTypography: "AI 대화 글꼴",+ conversationTypographyDescription: "SQL 편집기나 전체 인터페이스를 변경하지 않고 AI 메시지와 입력창의 글꼴을 설정합니다.",+ conversationFontFamily: "AI 대화 글꼴",+ conversationFontFollowInterface: "인터페이스 글꼴 따르기",+ conversationFontSize: "AI 대화 글꼴 크기",+ conversationFontSizeRange: "{min}~{max}px",defaultAutoRouting: "자동 의도 라우팅 기본 사용",defaultAutoRoutingDescription: "새 AI 대화를 '자동' 선택으로 시작합니다. 전송 시 AI가 의도를 파악해 적절한 기능으로 전환합니다. 현재 대화에는 영향을 주지 않습니다.",restoreLastConversation: "열 때 마지막 AI 대화 복원",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 539a44dfb2..2f776a7138 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -3369,6 +3369,12 @@ export default withEnglishFallback({pluginFollowUp: "Faça uma pergunta de acompanhamento sobre o contexto atual…",defaultAiMode: "Modo de IA padrão",defaultAiModeDescription: "Modo usado ao iniciar uma nova conversa de IA. Alterar o modo na conversa atual não altera esta configuração.",+ conversationTypography: "Tipografia da conversa de IA",+ conversationTypographyDescription: "Defina a fonte das mensagens e da entrada de IA sem alterar o editor SQL ou a interface.",+ conversationFontFamily: "Fonte da conversa de IA",+ conversationFontFollowInterface: "Usar fonte da interface",+ conversationFontSize: "Tamanho da fonte da conversa de IA",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Roteamento automático de intenção por padrão",defaultAutoRoutingDescription: "Inicia novas conversas de IA com a ação Automático: a IA detecta sua intenção ao enviar e a direciona para uma ação concreta. Não altera a conversa atual.",restoreLastConversation: "Restaurar a última conversa de IA ao abrir",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 057f01aae9..29d0c4478e 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -3554,6 +3554,12 @@ export default withEnglishFallback({pluginFollowUp: "Задайте уточняющий вопрос о текущем контексте…",defaultAiMode: "Режим ИИ по умолчанию",defaultAiModeDescription: "Режим, используемый при начале нового диалога с ИИ. Переключение режима в текущем диалоге не изменяет эту настройку.",+ conversationTypography: "Шрифт диалога с ИИ",+ conversationTypographyDescription: "Настройте шрифт сообщений и поля ввода ИИ, не изменяя редактор SQL или интерфейс.",+ conversationFontFamily: "Шрифт диалога с ИИ",+ conversationFontFollowInterface: "Использовать шрифт интерфейса",+ conversationFontSize: "Размер шрифта диалога с ИИ",+ conversationFontSizeRange: "{min}–{max} пкс",defaultAutoRouting: "Автоопределение намерения по умолчанию",defaultAutoRoutingDescription: "Начинать новые диалоги с ИИ с действия «Авто»: ассистент определяет ваше намерение при отправке и направляет его в конкретное действие. Не изменяет текущий диалог.",restoreLastConversation: "Восстанавливать последний диалог с ИИ",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 6b4373d80c..f7451eb165 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -3305,6 +3305,12 @@ export default withEnglishFallback({pluginFollowUp: "Mevcut bağlam hakkında ek soru sorun…",defaultAiMode: "Varsayılan Yapay Zekâ Modu",defaultAiModeDescription: "Yeni bir yapay zekâ konuşması başlatılırken kullanılan mod. Geçerli konuşmada mod değiştirmek bu ayarı değiştirmez.",+ conversationTypography: "Yapay zekâ sohbet yazı tipi",+ conversationTypographyDescription: "SQL düzenleyiciyi veya arayüzü değiştirmeden yapay zekâ mesajlarının ve giriş alanının yazı tipini ayarlayın.",+ conversationFontFamily: "Yapay zekâ sohbet yazı tipi",+ conversationFontFollowInterface: "Arayüz yazı tipini kullan",+ conversationFontSize: "Yapay zekâ sohbet yazı tipi boyutu",+ conversationFontSizeRange: "{min}–{max} px",defaultAutoRouting: "Varsayılan olarak otomatik niyet yönlendirme",defaultAutoRoutingDescription: "Yeni yapay zekâ konuşmalarını Otomatik seçimiyle başlatır: yapay zekâ, gönderim sırasında niyetinizi algılar ve uygun eyleme yönlendirir. Geçerli konuşmayı değiştirmez.",restoreLastConversation: "Açılışta son yapay zekâ konuşmasını geri yükle",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex c3d93d0004..98df506181 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -3611,6 +3611,12 @@ export default withEnglishFallback({pluginFollowUp: "继续询问当前上下文…",defaultAiMode: "默认 AI 模式",defaultAiModeDescription: "新建 AI 对话时使用的模式。切换当前对话的模式不会修改此设置。",+ conversationTypography: "AI 对话字体",+ conversationTypographyDescription: "单独设置 AI 消息和输入框的字体,不影响 SQL 编辑器或全局界面。",+ conversationFontFamily: "AI 对话字体",+ conversationFontFollowInterface: "跟随界面字体",+ conversationFontSize: "AI 对话字号",+ conversationFontSizeRange: "{min}–{max} 像素",defaultAutoRouting: "默认启用自动意图路由",defaultAutoRoutingDescription: "新建 AI 对话时默认选择“自动”操作,发送时由 AI 识别意图并路由到具体操作。不影响当前对话。",restoreLastConversation: "打开时恢复最近的 AI 对话",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 5fde20dbde..2a6d37d131 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -3260,6 +3260,12 @@ export default withEnglishFallback({pluginFollowUp: "繼續詢問目前脈絡…",defaultAiMode: "預設 AI 模式",defaultAiModeDescription: "建立新 AI 對話時使用的模式。切換目前對話的模式不會變更此設定。",+ conversationTypography: "AI 對話字型",+ conversationTypographyDescription: "單獨設定 AI 訊息和輸入框的字型,不影響 SQL 編輯器或全域介面。",+ conversationFontFamily: "AI 對話字型",+ conversationFontFollowInterface: "跟隨介面字型",+ conversationFontSize: "AI 對話字級",+ conversationFontSizeRange: "{min}–{max} 像素",defaultAutoRouting: "預設啟用自動意圖路由",defaultAutoRoutingDescription: "建立新 AI 對話時預設選擇「自動」動作,傳送時由 AI 辨識意圖並路由到具體動作。不影響目前對話。",restoreLastConversation: "開啟時恢復最近的 AI 對話",diff --git a/apps/desktop/src/lib/ai/__tests__/aiTypography.spec.ts b/apps/desktop/src/lib/ai/__tests__/aiTypography.spec.tsnew file mode 100644index 0000000000..da47213cdf--- /dev/null+++ b/apps/desktop/src/lib/ai/__tests__/aiTypography.spec.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from "vitest";+import {+ AI_CONVERSATION_FONT_FAMILY_DEFAULT,+ AI_CONVERSATION_FONT_SIZE_DEFAULT,+ AI_CONVERSATION_FONT_SIZE_MAX,+ AI_CONVERSATION_FONT_SIZE_MIN,+ aiConversationFontFamilyForName,+ aiConversationTypographyCssVariables,+ normalizeAiConversationFontFamily,+ normalizeAiConversationFontFamilyInput,+ normalizeAiConversationFontSize,+ normalizeAiConversationTypography,+} from "@/lib/ai/aiTypography";++describe("AI conversation typography", () => {+ it("preserves the legacy inherited 12px appearance for sparse settings", () => {+ expect(normalizeAiConversationTypography(undefined)).toEqual({+ fontFamily: AI_CONVERSATION_FONT_FAMILY_DEFAULT,+ fontSize: AI_CONVERSATION_FONT_SIZE_DEFAULT,+ });+ expect(aiConversationTypographyCssVariables(undefined)).toEqual({+ "--dbx-ai-content-font-size": "12px",+ "--dbx-ai-code-font-size": "12px",+ "--dbx-ai-inline-code-font-size": "11px",+ });+ });++ it("sanitizes font families and clamps invalid sizes", () => {+ expect(normalizeAiConversationFontFamily(null)).toBe("");+ expect(normalizeAiConversationFontFamily(" 'Atkinson Hyperlegible', sans-serif\n")).toBe("'Atkinson Hyperlegible', sans-serif");+ expect(aiConversationFontFamilyForName("Reader's Choice")).toBe("'Reader\\'s Choice', sans-serif");+ expect(normalizeAiConversationFontFamilyInput("Atkinson Hyperlegible")).toBe("'Atkinson Hyperlegible', sans-serif");+ expect(normalizeAiConversationFontFamilyInput("Georgia, serif")).toBe("Georgia, serif");+ expect(normalizeAiConversationFontSize(Number.NaN)).toBe(AI_CONVERSATION_FONT_SIZE_DEFAULT);+ expect(normalizeAiConversationFontSize("18")).toBe(AI_CONVERSATION_FONT_SIZE_DEFAULT);+ expect(normalizeAiConversationFontSize(1)).toBe(AI_CONVERSATION_FONT_SIZE_MIN);+ expect(normalizeAiConversationFontSize(99)).toBe(AI_CONVERSATION_FONT_SIZE_MAX);+ expect(normalizeAiConversationFontSize(15.6)).toBe(16);+ });++ it("creates scoped prose and monospace code sizes from a custom preference", () => {+ expect(aiConversationTypographyCssVariables({ fontFamily: "Georgia, serif", fontSize: 18 })).toEqual({+ "--dbx-ai-content-font-family": "Georgia, serif",+ "--dbx-ai-content-font-size": "18px",+ "--dbx-ai-code-font-size": "18px",+ "--dbx-ai-inline-code-font-size": "17px",+ });+ });+});diff --git a/apps/desktop/src/lib/ai/aiTypography.ts b/apps/desktop/src/lib/ai/aiTypography.tsnew file mode 100644index 0000000000..810735ccb9--- /dev/null+++ b/apps/desktop/src/lib/ai/aiTypography.ts@@ -0,0 +1,50 @@+export const AI_CONVERSATION_FONT_FAMILY_DEFAULT = "";+export const AI_CONVERSATION_FONT_SIZE_DEFAULT = 12;+export const AI_CONVERSATION_FONT_SIZE_MIN = 10;+export const AI_CONVERSATION_FONT_SIZE_MAX = 24;++const AI_CONVERSATION_FONT_FAMILY_MAX_LENGTH = 512;+const AI_CODE_FONT_SIZE_MIN = 11;++export interface AiConversationTypography {+ fontFamily: string;+ fontSize: number;+}++export function normalizeAiConversationFontFamily(value: unknown): string {+ if (typeof value !== "string") return AI_CONVERSATION_FONT_FAMILY_DEFAULT;+ return value.trim().slice(0, AI_CONVERSATION_FONT_FAMILY_MAX_LENGTH);+}++export function aiConversationFontFamilyForName(name: string): string {+ return `'${name.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}', sans-serif`;+}++export function normalizeAiConversationFontFamilyInput(value: string): string {+ const normalized = normalizeAiConversationFontFamily(value);+ if (!normalized || normalized.includes(",") || normalized.includes("'") || normalized.includes('"')) return normalized;+ return aiConversationFontFamilyForName(normalized);+}++export function normalizeAiConversationFontSize(value: unknown): number {+ if (typeof value !== "number" || !Number.isFinite(value)) return AI_CONVERSATION_FONT_SIZE_DEFAULT;+ return Math.min(AI_CONVERSATION_FONT_SIZE_MAX, Math.max(AI_CONVERSATION_FONT_SIZE_MIN, Math.round(value)));+}++export function normalizeAiConversationTypography(value: Partial<AiConversationTypography> | null | undefined): AiConversationTypography {+ return {+ fontFamily: normalizeAiConversationFontFamily(value?.fontFamily),+ fontSize: normalizeAiConversationFontSize(value?.fontSize),+ };+}++export function aiConversationTypographyCssVariables(value: Partial<AiConversationTypography> | null | undefined): Record<string, string> {+ const typography = normalizeAiConversationTypography(value);+ const variables: Record<string, string> = {+ "--dbx-ai-content-font-size": `${typography.fontSize}px`,+ "--dbx-ai-code-font-size": `${Math.max(AI_CODE_FONT_SIZE_MIN, typography.fontSize)}px`,+ "--dbx-ai-inline-code-font-size": `${Math.max(AI_CODE_FONT_SIZE_MIN, typography.fontSize - 1)}px`,+ };+ if (typography.fontFamily) variables["--dbx-ai-content-font-family"] = typography.fontFamily;+ return variables;+}diff --git a/apps/desktop/src/lib/settings/settingsSearch.ts b/apps/desktop/src/lib/settings/settingsSearch.tsindex f9b6f10774..69d1eebe69 100644--- a/apps/desktop/src/lib/settings/settingsSearch.ts+++ b/apps/desktop/src/lib/settings/settingsSearch.ts@@ -276,6 +276,8 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] ={ id: "sync-secrets", category: "sync", titleKey: "settings.syncSecrets", targetId: "sync" },{ id: "sync-secrets-passphrase", category: "sync", titleKey: "settings.syncSecretsPassphrase", targetId: "sync" },{ id: "ai-config", category: "ai", titleKey: "ai.configList", targetId: "ai" },+ { id: "ai-conversation-font-family", category: "ai", titleKey: "ai.conversationFontFamily", descriptionKey: "ai.conversationTypographyDescription", targetId: "ai-typography" },+ { id: "ai-conversation-font-size", category: "ai", titleKey: "ai.conversationFontSize", descriptionKey: "ai.conversationTypographyDescription", targetId: "ai-typography" },{ id: "ai-prompts", category: "ai", titleKey: "ai.promptTemplates", descriptionKey: "ai.promptTemplatesDescription", targetId: "ai" },{ id: "ai-default-mode", category: "ai", titleKey: "ai.defaultAiMode", descriptionKey: "ai.defaultAiModeDescription", targetId: "ai" },{ id: "ai-default-auto-routing", category: "ai", titleKey: "ai.defaultAutoRouting", descriptionKey: "ai.defaultAutoRoutingDescription", targetId: "ai" },diff --git a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts b/apps/desktop/src/stores/__tests__/settingsStore.spec.tsindex a3198a742b..8384ca1553 100644--- a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts+++ b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts@@ -20,6 +20,25 @@ import type { AiConfigItem } from "@/types/ai";import { DATA_GRID_EXTRACTOR_OPTIONS_MIGRATION_VERSION } from "@/lib/dataGrid/dataGridCopyExtractor";describe("normalizeEditorSettings", () => {+ it("defaults and sanitizes AI conversation typography independently", () => {+ expect(normalizeEditorSettings({})).toMatchObject({ aiFontFamily: "", aiFontSize: 12 });+ expect(+ normalizeEditorSettings({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ aiFontFamily: " 'Atkinson Hyperlegible', sans-serif\n",+ aiFontSize: 17.6,+ }),+ ).toMatchObject({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ aiFontFamily: "'Atkinson Hyperlegible', sans-serif",+ aiFontSize: 18,+ });+ expect(normalizeEditorSettings({ aiFontFamily: null, aiFontSize: 999 } as any)).toMatchObject({ aiFontFamily: "", aiFontSize: 24 });+ expect(normalizeEditorSettings({ aiFontSize: "18" } as any).aiFontSize).toBe(12);+ });+it("defaults DDL viewing to a dialog and preserves the selected open mode", () => {expect(DEFAULT_EDITOR_SETTINGS.ddlOpenMode).toBe("dialog");expect(normalizeEditorSettings({}).ddlOpenMode).toBe("dialog");@@ -1157,6 +1176,49 @@ describe("settingsStore persisted settings initialization", () => {expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ tableCompletionSchemaQualification: "always" }));});+ it("persists and resets AI typography without changing editor or interface fonts", async () => {+ const loadEditorSettings = vi.fn().mockResolvedValue({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ });+ const saveEditorSettings = vi.fn().mockResolvedValue(undefined);+ vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));++ const { useSettingsStore } = await import("@/stores/settingsStore");+ const store = useSettingsStore();+ await store.initEditorSettings();+ saveEditorSettings.mockClear();++ await store.updateEditorSettingsAndPersist({ aiFontFamily: " Georgia, serif ", aiFontSize: 18 });++ expect(store.editorSettings).toMatchObject({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ aiFontFamily: "Georgia, serif",+ aiFontSize: 18,+ });+ expect(saveEditorSettings).toHaveBeenLastCalledWith(+ expect.objectContaining({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ aiFontFamily: "Georgia, serif",+ aiFontSize: 18,+ }),+ );++ await store.updateEditorSettingsAndPersist({+ aiFontFamily: DEFAULT_EDITOR_SETTINGS.aiFontFamily,+ aiFontSize: DEFAULT_EDITOR_SETTINGS.aiFontSize,+ });++ expect(store.editorSettings).toMatchObject({+ fontFamily: "SQL editor font",+ uiFontFamily: "Interface font",+ aiFontFamily: "",+ aiFontSize: 12,+ });+ });+it("loads and persists the substitution switch without discarding syntax overrides", async () => {const loadEditorSettings = vi.fn().mockResolvedValue({sqlVariableSubstitutionEnabled: false,diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.tsindex 8c1e409d02..2b179f6735 100644--- a/apps/desktop/src/stores/settingsStore.ts+++ b/apps/desktop/src/stores/settingsStore.ts@@ -2,6 +2,7 @@ import { normalizePluginShortcutSettings, type PluginShortcutSettings } from "@/import { defineStore } from "pinia";import { computed, ref } from "vue";import { aiConfigToItem, generateId, getConfigKey } from "@/lib/ai/aiConfigList";+import { AI_CONVERSATION_FONT_FAMILY_DEFAULT, AI_CONVERSATION_FONT_SIZE_DEFAULT, normalizeAiConversationFontFamily, normalizeAiConversationFontSize } from "@/lib/ai/aiTypography";import { DEFAULT_DATA_GRID_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY } from "@/lib/app/appFonts";import { emitAlwaysOnTopToolbarVisibilityChanged } from "@/lib/app/windowAlwaysOnTop";import { defaultBackgroundImageSettings, normalizeBackgroundImageSettings, type BackgroundImageSettings } from "@/lib/app/appBackgroundImage";@@ -827,6 +828,8 @@ export interface EditorSettings {fontFamily: string;fontSize: number;uiFontFamily: string;+ aiFontFamily: string;+ aiFontSize: number;uiScale: number;theme: EditorTheme;backgroundImage: BackgroundImageSettings;@@ -1113,6 +1116,8 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {fontFamily: "'Fira Code', 'Cascadia Code', 'Cascadia Mono', 'JetBrains Mono', monospace",fontSize: 13,uiFontFamily: DEFAULT_UI_FONT_FAMILY,+ aiFontFamily: AI_CONVERSATION_FONT_FAMILY_DEFAULT,+ aiFontSize: AI_CONVERSATION_FONT_SIZE_DEFAULT,uiScale: 1,theme: "app",backgroundImage: defaultBackgroundImageSettings(),@@ -1642,6 +1647,8 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, existfontFamily: normalizeFontFamily(settings.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily),fontSize: settings.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,uiFontFamily: normalizeFontFamily(settings.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily),+ aiFontFamily: normalizeAiConversationFontFamily(settings.aiFontFamily),+ aiFontSize: normalizeAiConversationFontSize(settings.aiFontSize),uiScale: normalizeUiScale(settings.uiScale),theme: settings.theme && EDITOR_THEME_VALUES.has(settings.theme) ? settings.theme : DEFAULT_EDITOR_SETTINGS.theme,customThemeColors: {@@ -2486,6 +2493,8 @@ export const useSettingsStore = defineStore("settings", () => {if (partial.fontFamily !== undefined) editorSettings.value.fontFamily = normalizeFontFamily(partial.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily);if (partial.fontSize !== undefined) editorSettings.value.fontSize = partial.fontSize;if (partial.uiFontFamily !== undefined) editorSettings.value.uiFontFamily = normalizeFontFamily(partial.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily);+ if (partial.aiFontFamily !== undefined) editorSettings.value.aiFontFamily = normalizeAiConversationFontFamily(partial.aiFontFamily);+ if (partial.aiFontSize !== undefined) editorSettings.value.aiFontSize = normalizeAiConversationFontSize(partial.aiFontSize);if (partial.uiScale !== undefined) editorSettings.value.uiScale = normalizeUiScale(partial.uiScale);if (partial.backgroundImage !== undefined) editorSettings.value.backgroundImage = normalizeBackgroundImageSettings(partial.backgroundImage);if (partial.theme !== undefined) editorSettings.value.theme = partial.theme;