From 21e9578f78a099471e1198c09346679ccd67d87c Mon Sep 17 00:00:00 2001 From: zipg Date: Thu, 23 Jul 2026 12:51:19 +0800 Subject: [PATCH] fix(ai): improve connection test diagnostics --- .../editor/EditorSettingsDialog.vue | 27 +- apps/desktop/src/i18n/locales/en.ts | 9 + apps/desktop/src/i18n/locales/es.ts | 9 + apps/desktop/src/i18n/locales/it.ts | 9 + apps/desktop/src/i18n/locales/ja.ts | 9 + apps/desktop/src/i18n/locales/pt-BR.ts | 9 + apps/desktop/src/i18n/locales/zh-CN.ts | 9 + apps/desktop/src/i18n/locales/zh-TW.ts | 9 + crates/dbx-core/src/ai.rs | 487 +++++++++++++++--- 9 files changed, 495 insertions(+), 82 deletions(-) diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue index 8d0ac9417d..e2775c85f0 100644 --- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue +++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue @@ -2195,6 +2195,24 @@ const aiTestResult = ref<"" | "success" | "error">(""); const aiTestError = ref(""); const aiTestLatency = ref(null); const aiTestErrorCopied = ref(false); +const aiTestErrorCategoryKeys: Record = { + auth: "ai.testErrorAuth", + modelNotFound: "ai.testErrorModelNotFound", + rateLimit: "ai.testErrorRateLimit", + timeout: "ai.testErrorTimeout", + tokenLimit: "ai.testErrorTokenLimit", + safety: "ai.testErrorSafety", + emptyResponse: "ai.testErrorEmptyResponse", + network: "ai.testErrorNetwork", + unknown: "ai.testErrorUnknown", +}; +const aiTestErrorPresentation = computed(() => { + const match = aiTestError.value.match(/^\[([^\]]+)]\s*(.*)$/s); + if (!match) return { summary: "", detail: aiTestError.value }; + const key = aiTestErrorCategoryKeys[match[1]]; + return key ? { summary: t(key), detail: match[2] } : { summary: "", detail: aiTestError.value }; +}); +const aiTestErrorDisplay = computed(() => [aiTestErrorPresentation.value.summary, aiTestErrorPresentation.value.detail].filter(Boolean).join(" ")); const aiIsCodexCli = computed(() => aiEditProvider.value === "codex-cli"); const aiIsClaudeCodeCli = computed(() => aiEditProvider.value === "claude-code-cli"); const aiIsCliProvider = computed(() => CLI_AI_PROVIDERS.has(aiEditProvider.value)); @@ -5560,7 +5578,7 @@ onUnmounted(cleanupPreviewEditor);