From 86aac87f839cc264645bb8045253f251504108ad Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 16 Nov 2026 15:42:59 +0900 Subject: [PATCH] refac --- .../automations/AutomationEditor.svelte | 55 +++++++++++++------ src/lib/components/common/Textarea.svelte | 2 + 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/lib/components/automations/AutomationEditor.svelte b/src/lib/components/automations/AutomationEditor.svelte index 64227ef4bc..07d4b61f4e 100644 --- a/src/lib/components/automations/AutomationEditor.svelte +++ b/src/lib/components/automations/AutomationEditor.svelte @@ -37,6 +37,7 @@ import Spinner from '$lib/components/common/Spinner.svelte'; import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; import Switch from '$lib/components/common/Switch.svelte'; + import Textarea from '$lib/components/common/Textarea.svelte'; import Calendar from '$lib/components/icons/Calendar.svelte'; import Sparkles from '$lib/components/icons/Sparkles.svelte'; import Folder from '$lib/components/icons/Folder.svelte'; @@ -66,6 +67,8 @@ // The page is the editor: fields start from the saved automation, Save appears once they differ. let name = ''; let prompt = ''; + // Like the model editor's system prompt: a saved prompt starts collapsed. + let showPrompt = true; let model_id = ''; let folder_id = ''; let target_type: 'chat' | 'channel' = 'chat'; @@ -257,16 +260,6 @@ if (copied) toast.success($i18n.t('Copied link to clipboard')); }; - // The prompt grows with its text instead of scrolling inside a box. - const autosize = (node: HTMLTextAreaElement, _value: string) => { - const fit = () => { - node.style.height = 'auto'; - node.style.height = `${node.scrollHeight}px`; - }; - fit(); - return { update: fit }; - }; - const toggleHandler = async () => { const previousState = automation.is_active; const res = await toggleAutomationById(localStorage.token, automation.id).catch((err) => { @@ -362,6 +355,7 @@ is_active = automation.is_active; await resetFields(automation); + showPrompt = !prompt.trim(); await ensureFolders(); await ensureChannels(); terminalServers = await getTerminalServers(localStorage.token).catch(() => []); @@ -424,14 +418,39 @@ aria-label={$i18n.t('Name')} placeholder={$i18n.t('Automation name')} /> - + {#if showPrompt || !prompt.trim()} +