From 3b117b3c302faaccb2ff0e1e81a2d7a4aeafa62c Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:20:52 +0200 Subject: [PATCH] nit: show disabled message when lang not supported (#5925) * show disabled message when lang not supported * remove open effect --- .../src/lib/components/ScriptEditor.svelte | 6 ------ .../lib/components/copilot/chat/AIChat.svelte | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/components/ScriptEditor.svelte b/frontend/src/lib/components/ScriptEditor.svelte index 5f213f9e2e..801fd5d7af 100644 --- a/frontend/src/lib/components/ScriptEditor.svelte +++ b/frontend/src/lib/components/ScriptEditor.svelte @@ -353,12 +353,6 @@ let testPanelSize = $state(30) let storedTestPanelSize = untrack(() => testPanelSize) - $effect(() => { - if (SUPPORTED_CHAT_SCRIPT_LANGUAGES.includes(lang ?? '') == !aiChatManager.open) { - untrack(() => aiChatManager.toggleOpen()) - } - }) - function toggleTestPanel() { if (testPanelSize > 0) { storedTestPanelSize = testPanelSize diff --git a/frontend/src/lib/components/copilot/chat/AIChat.svelte b/frontend/src/lib/components/copilot/chat/AIChat.svelte index d664c6aa05..0ea7cdebf9 100644 --- a/frontend/src/lib/components/copilot/chat/AIChat.svelte +++ b/frontend/src/lib/components/copilot/chat/AIChat.svelte @@ -12,15 +12,26 @@ import { aiChatManager, AIMode } from './AIChatManager.svelte' import { base } from '$lib/base' import HideButton from '$lib/components/apps/editor/settingsPanel/HideButton.svelte' + import { SUPPORTED_CHAT_SCRIPT_LANGUAGES } from './script/core' const isAdmin = $derived($userStore?.is_admin || $userStore?.is_super_admin) const hasCopilot = $derived($copilotInfo.enabled) + const disabled = $derived( + !hasCopilot || + (aiChatManager.mode === AIMode.SCRIPT && + aiChatManager.scriptEditorOptions?.lang && + !SUPPORTED_CHAT_SCRIPT_LANGUAGES.includes(aiChatManager.scriptEditorOptions.lang)) + ) const disabledMessage = $derived( - hasCopilot - ? '' - : isAdmin + !hasCopilot + ? isAdmin ? `Enable Windmill AI in your [workspace settings](${base}/workspace_settings?tab=ai) to use this chat` : 'Ask an admin to enable Windmill AI in this workspace to use this chat' + : aiChatManager.mode === AIMode.SCRIPT && + aiChatManager.scriptEditorOptions?.lang && + !SUPPORTED_CHAT_SCRIPT_LANGUAGES.includes(aiChatManager.scriptEditorOptions.lang) + ? `Windmill AI does not support the ${aiChatManager.scriptEditorOptions.lang} language yet.` + : '' ) const suggestions = [ @@ -143,7 +154,7 @@ !!aiChatManager.scriptEditorOptions.lastDeployedCode && aiChatManager.scriptEditorOptions.lastDeployedCode !== aiChatManager.scriptEditorOptions.code} diffMode={aiChatManager.scriptEditorOptions?.diffMode ?? false} - disabled={!hasCopilot} + {disabled} {disabledMessage} {suggestions} >