nit: show disabled message when lang not supported (#5925)

* show disabled message when lang not supported

* remove open effect
This commit is contained in:
centdix
2025-06-12 16:20:52 +02:00
committed by GitHub
parent 939fc72629
commit 3b117b3c30
2 changed files with 15 additions and 10 deletions
@@ -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
@@ -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}
></AIChatDisplay>