Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import RichContent from './rich-content/rich-content.svelte';
import RcMessage from "./rich-content/rc-message.svelte";
import RcDisclaimer from './rich-content/rc-disclaimer.svelte';
import RcEmbedding from './rich-content/rc-embedding.svelte';
import MessageFileGallery from '$lib/common/files/MessageFileGallery.svelte';
import ChatUtil from './chat-util/chat-util.svelte';
import ChatFileUploader from './chat-util/chat-file-uploader.svelte';
Expand Down Expand Up @@ -2442,6 +2443,17 @@
{:else}
<RcMessage markdownClasses={'markdown-dark cb-md-dark font-libre'} message={message} isStreaming={isStreaming || isThinking} />
{/if}
<!-- Embedded content belongs to the
message that produced it, so it renders inline here rather than in
the trailing <RichContent>, which only ever shows the last bot
message and would drop embeds on intermediate function-call turns. -->
{#if message?.rich_content?.message?.rich_type === RichType.Embedding && editingBotMsgUid !== message.uuid}
<RcEmbedding
url={message?.rich_content?.message?.url}
title={message?.rich_content?.message?.title}
htmlTag={message?.rich_content?.message?.html_tag}
/>
{/if}
{#if !!(message?.rich_content?.message?.text || message?.text) && editingBotMsgUid !== message.uuid}
{@const isLastBotMsg = message?.message_id === lastBotMsg?.message_id && message?.uuid === lastBotMsg?.uuid}
<!-- Suppressed while the last bot message is still streaming, so the timestamp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script>
import { getContext } from 'svelte';
import collapse from 'svelte-collapse';

const collapseDuration = 0.3;
const { autoScrollToBottom } = getContext('chat-window-context');

/**
* @type {{
Expand All @@ -20,16 +18,25 @@

let open = $state(false);

/** @type {HTMLDivElement | null} */
let wrapperEl = $state(null);

function toggleCollapse() {
open = !open;
if (open) {
setTimeout(() => autoScrollToBottom?.(), collapseDuration * 1000);
// Bring the expanded embed into view once the collapse animation has
// settled. `block: 'nearest'` scrolls only as far as needed, so a
// message in the middle of the thread stays put instead of the whole
// pane jumping to the bottom.
setTimeout(() => {
wrapperEl?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
}, collapseDuration * 1000);
}
}
</script>

{#if htmlTag && url}
<div class="rc-embedding-wrapper">
<div class="rc-embedding-wrapper" bind:this={wrapperEl}>
<div class="rc-embedding-toggle-group">
<button type="button" class="rc-embedding-toggle" class:closed={!open} onclick={toggleCollapse}>
<span>{open ? 'Close' : 'Open'}{title ? ` ${title}` : ''}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@

{#if message?.rich_content?.editor === EditorType.File}
<ChatAttachmentOptions options={resolvedOptions.options} disabled={disabled} onConfirm={(title, payload) => handleConfirm(title, payload)} />
{:else if message?.rich_content?.message?.rich_type === RichType.Embedding}
<RcEmbedding url={message?.rich_content?.message?.url} title={message?.rich_content?.message?.title} htmlTag={message?.rich_content?.message?.html_tag} />
{:else if !resolvedOptions.isComplexElement}
<RcPlainOptions options={resolvedOptions.options} isMultiSelect={resolvedOptions.isMultiSelect} disabled={disabled} onConfirm={(title, payload) => handleConfirm(title, payload)} />
{:else}
Expand Down
Loading