diff --git a/pkg/api/handlers/assistants.go b/pkg/api/handlers/assistants.go index 889039432..a9f45db66 100644 --- a/pkg/api/handlers/assistants.go +++ b/pkg/api/handlers/assistants.go @@ -176,7 +176,9 @@ func convertAssistant(agent v1.Agent) types.Assistant { IntroductionMessage: agent.Spec.Manifest.IntroductionMessage, Icons: icons, } - assistant.ID = agent.Spec.Manifest.Alias + if agent.Spec.Manifest.Alias != "" { + assistant.ID = agent.Spec.Manifest.Alias + } return assistant } diff --git a/ui/user/src/lib/components/Thread.svelte b/ui/user/src/lib/components/Thread.svelte index ba8c02363..807a165b1 100644 --- a/ui/user/src/lib/components/Thread.svelte +++ b/ui/user/src/lib/components/Thread.svelte @@ -6,31 +6,23 @@ import Message from '$lib/components/messages/Message.svelte'; import { fade } from 'svelte/transition'; import { onDestroy } from 'svelte'; - import { currentAssistant, assistants } from '$lib/stores'; import { toHTMLFromMarkdown } from '$lib/markdown'; interface Props { - assistant?: string; + assistant?: Assistant; } - let { assistant = '' }: Props = $props(); + let { assistant }: Props = $props(); let messages: Messages = $state({ messages: [], inProgress: false }); let thread: Thread | undefined = $state(); let messagesDiv = $state(); - let current = $derived.by(() => { - let a = $assistants.find((a) => a.id === assistant); - if (!a && $currentAssistant.id === assistant) { - a = $currentAssistant; - } - return a; - }); $effect(() => { - if (!assistant || thread) { + if (!assistant?.id || thread) { return; } - const newThread = new Thread(assistant, { + const newThread = new Thread(assistant.id, { onError: () => { // ignore errors they are rendered as messages } @@ -49,7 +41,7 @@ function onLoadFile(filename: string) { if (assistant) { - EditorService.load(assistant, filename); + EditorService.load(assistant.id, filename); } } @@ -64,12 +56,12 @@
{#if messages.messages.length < 7}
- {#if current?.introductionMessage} - {@html toHTMLFromMarkdown(current.introductionMessage)} + {#if assistant?.introductionMessage} + {@html toHTMLFromMarkdown(assistant.introductionMessage)} {/if}
- {#each current?.starterMessages ?? [] as msg} + {#each assistant?.starterMessages ?? [] as msg}