open-webui/src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte

81 lines
2 KiB
Svelte
Raw Normal View History

2025-09-07 00:21:46 +00:00
<script>
import { getContext } from 'svelte';
const i18n = getContext('i18n');
import StatusItem from './StatusHistory/StatusItem.svelte';
export let statusHistory = [];
2025-09-07 01:09:14 +00:00
export let expand = false;
let showHistory = true;
$: if (expand) {
showHistory = true;
} else {
showHistory = false;
}
2025-09-07 00:21:46 +00:00
2025-09-07 01:06:03 +00:00
let history = [];
let status = null;
2025-09-07 00:21:46 +00:00
2025-09-07 01:06:03 +00:00
$: if (history && history.length > 0) {
status = history.at(-1);
}
2025-09-07 00:21:46 +00:00
2025-09-07 01:06:03 +00:00
$: if (JSON.stringify(statusHistory) !== JSON.stringify(history)) {
history = statusHistory;
}
</script>
2025-09-07 00:21:46 +00:00
2025-09-07 01:06:03 +00:00
{#if history && history.length > 0}
2025-09-07 00:25:52 +00:00
{#if status?.hidden !== true}
<div class="text-sm flex flex-col w-full">
{#if showHistory}
<div class="flex flex-row">
2025-09-07 01:06:03 +00:00
{#if history.length > 1}
2025-09-12 22:27:03 +00:00
<div class="w-1 border-r border-gray-100 dark:border-gray-800 mt-3 -mb-2.5" />
2025-09-07 00:25:52 +00:00
<div class="w-full -translate-x-[7.5px]">
2025-09-07 01:06:03 +00:00
{#each history as status, idx}
{#if idx !== history.length - 1}
2025-09-07 00:25:52 +00:00
<div class="flex items-start gap-2 mb-1">
<div class="pt-3 px-1">
2025-09-12 22:27:03 +00:00
<span class="relative flex size-1.5 rounded-full justify-center items-center">
2025-09-07 00:25:52 +00:00
<span
2025-09-12 22:27:03 +00:00
class="relative inline-flex size-1.5 rounded-full bg-gray-300 dark:bg-gray-600"
2025-09-07 00:25:52 +00:00
></span>
</span>
</div>
<StatusItem {status} done={true} />
2025-09-07 00:21:46 +00:00
</div>
2025-09-07 00:25:52 +00:00
{/if}
{/each}
</div>
{/if}
</div>
{/if}
2025-09-07 00:21:46 +00:00
<button
class="w-full -translate-x-[3.5px]"
on:click={() => {
showHistory = !showHistory;
}}
>
2025-09-07 01:06:03 +00:00
<div class="flex items-start gap-2">
2025-09-07 00:21:46 +00:00
<div class="pt-3 px-1">
2025-09-12 22:27:03 +00:00
<span class="relative flex size-1.5 rounded-full justify-center items-center">
2025-09-07 00:21:46 +00:00
{#if status?.done === false}
<span
2025-09-12 22:27:03 +00:00
class="absolute inline-flex h-full w-full animate-ping rounded-full bg-gray-300 dark:bg-gray-600 opacity-75"
2025-09-07 00:21:46 +00:00
></span>
{/if}
2025-09-12 22:27:03 +00:00
<span class="relative inline-flex size-1.5 rounded-full bg-gray-300 dark:bg-gray-600"
2025-09-07 00:21:46 +00:00
></span>
</span>
</div>
<StatusItem {status} />
</div>
</button>
2025-09-07 00:25:52 +00:00
</div>
{/if}
2025-09-07 00:21:46 +00:00
{/if}