Skip to content

Commit

Permalink
bug: fix referencing agent by id
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud authored and cjellick committed Jan 14, 2025
1 parent d569be4 commit 359397e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pkg/api/handlers/assistants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
24 changes: 8 additions & 16 deletions ui/user/src/lib/components/Thread.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<Thread>();
let messagesDiv = $state<HTMLDivElement>();
let current = $derived.by<Assistant | undefined>(() => {
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
}
Expand All @@ -49,7 +41,7 @@
function onLoadFile(filename: string) {
if (assistant) {
EditorService.load(assistant, filename);
EditorService.load(assistant.id, filename);
}
}
</script>
Expand All @@ -64,12 +56,12 @@
<div in:fade|global class="flex flex-col gap-8">
{#if messages.messages.length < 7}
<div class="message-content self-center">
{#if current?.introductionMessage}
{@html toHTMLFromMarkdown(current.introductionMessage)}
{#if assistant?.introductionMessage}
{@html toHTMLFromMarkdown(assistant.introductionMessage)}
{/if}
</div>
<div class="flex gap-2 self-center">
{#each current?.starterMessages ?? [] as msg}
{#each assistant?.starterMessages ?? [] as msg}
<button
class="rounded-3xl border-2 border-blue p-5"
onclick={() => {
Expand Down
2 changes: 1 addition & 1 deletion ui/user/src/routes/[agent]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- these divs suck, but it's so that we have a relative container for the absolute input and the scrollable area is the entire screen and not just
the center content. Plus the screen will auto resize as the editor is resized -->
<div class="relative flex-1 overflow-auto">
<Thread assistant={$currentAssistant.id} />
<Thread assistant={$currentAssistant} />
</div>

{#if $editorVisible || term.open}
Expand Down

0 comments on commit 359397e

Please sign in to comment.