mirror of
https://github.com/open-webui/computer.git
synced 2026-11-20 21:41:54 +03:00
refac
This commit is contained in:
@@ -214,7 +214,12 @@
|
||||
item: any;
|
||||
}
|
||||
|
||||
type DisplayItem = ToolGroup | MessageItem | ArtifactItem;
|
||||
interface ReasoningItem {
|
||||
type: 'reasoning_item';
|
||||
item: any;
|
||||
}
|
||||
|
||||
type DisplayItem = ToolGroup | MessageItem | ArtifactItem | ReasoningItem;
|
||||
|
||||
const outputText = $derived.by((): string => {
|
||||
return (output || [])
|
||||
@@ -263,6 +268,9 @@
|
||||
} else if (item.type === 'artifact') {
|
||||
flushGroup();
|
||||
items.push({ type: 'artifact_item', item });
|
||||
} else if (item.type === 'reasoning') {
|
||||
// Don't flush group — reasoning precedes tool calls
|
||||
items.push({ type: 'reasoning_item', item });
|
||||
}
|
||||
// function_call_output items are handled via outputMap, skip standalone render
|
||||
}
|
||||
@@ -376,6 +384,44 @@
|
||||
<MarkdownRenderer
|
||||
content={displayItem.item.content?.map((c: any) => c.text).join('') || ''}
|
||||
/>
|
||||
{:else if displayItem.type === 'reasoning_item'}
|
||||
{@const reasoningText = (displayItem.item.summary ?? displayItem.item.content ?? [])
|
||||
.filter((p) => 'text' in p)
|
||||
.map((p) => p.text ?? '')
|
||||
.join('')}
|
||||
{#if reasoningText}
|
||||
<div class="w-full min-w-0 flex flex-col my-0.5">
|
||||
<button
|
||||
class="w-full min-w-0 text-left text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition cursor-pointer"
|
||||
aria-label={$t('chat.edit.thought')}
|
||||
aria-expanded={expandedGroups.has(groupIdx)}
|
||||
onclick={() => toggleGroupExpanded(groupIdx)}
|
||||
>
|
||||
<div class="flex items-center gap-1.5 text-sm min-w-0">
|
||||
<div class="text-gray-400 dark:text-gray-500">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.75" stroke="currentColor" class="size-3.5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 0 0-2.455 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0 line-clamp-1">
|
||||
<span class="text-gray-600 dark:text-gray-300">{$t('chat.edit.thought')}</span>
|
||||
</div>
|
||||
<div class="flex shrink-0 self-center text-gray-400 dark:text-gray-500">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3.5" stroke="currentColor" class="size-3 transition-transform duration-200 {expandedGroups.has(groupIdx) ? 'rotate-180' : ''}">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{#if expandedGroups.has(groupIdx)}
|
||||
<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
|
||||
<div class="mt-1 mb-0.5 px-1">
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400 whitespace-pre-wrap">{reasoningText}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{:else if displayItem.type === 'artifact_item'}
|
||||
{@const artifact = displayItem.item}
|
||||
{@const preview = (artifact.content || '')
|
||||
|
||||
Reference in New Issue
Block a user