diff --git a/.gitignore b/.gitignore index 33ca901ae..0cd799edb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ Thumbs.db *.swo *~ .vscode/ +.idea/ # GitHub (keep workflows) .github/* diff --git a/src/components/editor/AiAssistant.vue b/src/components/editor/AiAssistant.vue index f6a478bb0..6f87fff58 100644 --- a/src/components/editor/AiAssistant.vue +++ b/src/components/editor/AiAssistant.vue @@ -16,7 +16,6 @@ import { MessageSquarePlus, Replace, Server, - Settings, Play, Square, Trash2, @@ -27,7 +26,6 @@ import { TestTube, } from "lucide-vue-next"; import { Button } from "@/components/ui/button"; -import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { DropdownMenu, @@ -36,10 +34,8 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; import { ScrollArea } from "@/components/ui/scroll-area"; -import { useSettingsStore, type AiProvider, type AiApiStyle } from "@/stores/settingsStore"; +import { useSettingsStore } from "@/stores/settingsStore"; import { useConnectionStore } from "@/stores/connectionStore"; import { connectionIconType } from "@/lib/connectionPresentation"; import DatabaseIcon from "@/components/icons/DatabaseIcon.vue"; @@ -49,7 +45,6 @@ import { buildAiContext, runAiStream, type AiAction } from "@/lib/ai"; import { extractFirstSqlCodeBlock, shouldAttemptAiAutoExecute } from "@/lib/aiSqlExecutionPolicy"; import { Marked } from "marked"; import { - aiTestConnection, aiCancelStream, saveAiConversation, loadAiConversations, @@ -89,7 +84,6 @@ const emit = defineEmits<{ const prompt = ref(""); const messages = ref([]); const isGenerating = ref(false); -const showSettings = ref(false); const scrollRef = ref | null>(null); const activeAction = ref("generate"); const currentSessionId = ref(""); @@ -168,20 +162,6 @@ function changeDatabase(database: string) { queryStore.updateDatabase(tab.id, database); } -const tempProvider = ref(settings.aiConfig.provider); -const tempApiKey = ref(settings.aiConfig.apiKey); -const tempEndpoint = ref(settings.aiConfig.endpoint); -const tempModel = ref(settings.aiConfig.model); -const tempApiStyle = ref(settings.aiConfig.apiStyle || "completions"); -const tempProxyEnabled = ref(!!settings.aiConfig.proxyEnabled); -const tempProxyUrl = ref(settings.aiConfig.proxyUrl || ""); - -const providerDefaults: Record = { - claude: { endpoint: "https://api.anthropic.com/v1/messages", model: "claude-sonnet-4-20250514" }, - openai: { endpoint: "https://api.openai.com/v1/chat/completions", model: "gpt-4o" }, - custom: { endpoint: "", model: "" }, -}; - function appendAssistantDelta(assistantIdx: number, delta: string) { const msg = messages.value[assistantIdx]; if (msg.isThinking) msg.isThinking = false; @@ -209,63 +189,6 @@ function toggleReasoning(index: number) { expandedReasoning.value = next; } -function openSettings() { - tempProvider.value = settings.aiConfig.provider; - tempApiKey.value = settings.aiConfig.apiKey; - tempEndpoint.value = settings.aiConfig.endpoint; - tempModel.value = settings.aiConfig.model; - tempApiStyle.value = settings.aiConfig.apiStyle || "completions"; - tempProxyEnabled.value = !!settings.aiConfig.proxyEnabled; - tempProxyUrl.value = settings.aiConfig.proxyUrl || ""; - showSettings.value = true; -} - -function saveSettings() { - settings.updateAiConfig({ - provider: tempProvider.value, - apiKey: tempApiKey.value, - endpoint: tempEndpoint.value, - model: tempModel.value, - apiStyle: tempApiStyle.value, - proxyEnabled: tempProxyEnabled.value, - proxyUrl: tempProxyUrl.value, - }); - showSettings.value = false; -} - -const testingAi = ref(false); -const testResult = ref<"" | "success" | "error">(""); -const testError = ref(""); - -async function testAiConnection() { - testingAi.value = true; - testResult.value = ""; - testError.value = ""; - try { - await aiTestConnection({ - provider: tempProvider.value, - apiKey: tempApiKey.value, - endpoint: tempEndpoint.value, - model: tempModel.value, - apiStyle: tempApiStyle.value, - proxyEnabled: tempProxyEnabled.value, - proxyUrl: tempProxyUrl.value, - }); - testResult.value = "success"; - } catch (e: any) { - testResult.value = "error"; - testError.value = e?.message || String(e); - } finally { - testingAi.value = false; - } -} - -function selectProvider(provider: AiProvider) { - tempProvider.value = provider; - tempEndpoint.value = providerDefaults[provider].endpoint; - tempModel.value = providerDefaults[provider].model; -} - function scrollToBottom() { nextTick(() => { const root = scrollRef.value?.$el as HTMLElement | undefined; @@ -283,7 +206,7 @@ async function send() { if (!props.connection || !props.tab) return; if (!settings.isConfigured()) { - openSettings(); + toast(t("ai.noConfig")); return; } @@ -531,9 +454,6 @@ function formatInlineText(text: string): string { - @@ -747,107 +667,6 @@ function formatInlineText(text: string): string { - - - - - {{ t("ai.settings") }} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
- - -
-
-
- - -
-
- - -
-
- -
- - {{ t("connection.testSuccess") }} - {{ testError }} -
- -
-
-