This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-21 22:05:35 +04:00
1 parent b16039bc9a
commit 82ca7733f0
71 files changed
+617 -32

No files matched your search

+20 -8
View File
@@ -3,12 +3,13 @@
import { marked } from 'marked';
import DOMPurify from 'dompurify';
import { config, user } from '$lib/stores';
import { config, user, recentChats, refreshRecentChats } from '$lib/stores';
import { onMount, getContext } from 'svelte';
import { blur, fade } from 'svelte/transition';
import Suggestions from './Suggestions.svelte';
import RecentChats from './RecentChats.svelte';
import { sanitizeResponseContent } from '$lib/utils';
import {
resolveLocalizedModelDescription,
@@ -52,9 +53,15 @@
$: firstName = firstNameOf($user?.name);
$: showGreeting = !!firstName && !selectedModelDescription;
$: greeting = getGreeting((key, options) => $i18n.t(key, options), firstName);
$: selectedSuggestionPrompts =
// The model's own suggestions come first, then recent chats, then the default suggestions.
$: modelSuggestionPrompts =
resolveLocalizedModelPromptSuggestions(atSelectedModel, $i18n.language) ??
resolveLocalizedModelPromptSuggestions(models[selectedModelIdx], $i18n.language) ??
resolveLocalizedModelPromptSuggestions(models[selectedModelIdx], $i18n.language);
$: showRecentChats = !modelSuggestionPrompts?.length && ($recentChats?.length ?? 0) > 0;
// Until recent chats first load, show neither rather than flash the defaults.
$: waitingForRecentChats = !modelSuggestionPrompts?.length && $recentChats === null;
$: selectedSuggestionPrompts =
modelSuggestionPrompts ??
resolveLocalizedPromptSuggestions(
$config?.default_prompt_suggestions,
$config?.default_prompt_suggestions_i18n ?? {},
@@ -64,6 +71,7 @@
onMount(() => {
mounted = true;
refreshRecentChats(localStorage.token);
});
</script>
@@ -172,11 +180,15 @@
</div>
<div class=" w-full" in:fade={{ duration: 200, delay: 300 }}>
<Suggestions
className="grid grid-cols-2"
suggestionPrompts={selectedSuggestionPrompts}
{onSelect}
/>
{#if showRecentChats}
<RecentChats chats={$recentChats} showIdentifier={!selectedSuggestionPrompts?.length} />
{:else if !waitingForRecentChats}
<Suggestions
className="grid grid-cols-2"
suggestionPrompts={selectedSuggestionPrompts}
{onSelect}
/>
{/if}
</div>
</div>
{/key}
+23 -4
View File
@@ -12,7 +12,7 @@
import { updateFolderById } from '$lib/apis/folders';
import { config, user, selectedFolder } from '$lib/stores';
import { config, user, selectedFolder, recentChats, refreshRecentChats } from '$lib/stores';
import { sanitizeResponseContent, extractCurlyBraceWords } from '$lib/utils';
import {
resolveLocalizedModelDescription,
@@ -24,6 +24,7 @@
import { firstNameOf, getGreeting } from '$lib/utils/greeting';
import Suggestions from './Suggestions.svelte';
import RecentChats from './RecentChats.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import EyeSlash from '$lib/components/icons/EyeSlash.svelte';
import MessageInput from './MessageInput.svelte';
@@ -121,9 +122,15 @@
$: firstName = firstNameOf($user?.name);
$: showGreeting = !!firstName && !selectedModelDescription;
$: greeting = getGreeting((key, options) => $i18n.t(key, options), firstName);
$: selectedSuggestionPrompts =
// The model's own suggestions come first, then recent chats, then the default suggestions.
$: modelSuggestionPrompts =
resolveLocalizedModelPromptSuggestions(atSelectedModel, $i18n.language) ??
resolveLocalizedModelPromptSuggestions(models[selectedModelIdx], $i18n.language) ??
resolveLocalizedModelPromptSuggestions(models[selectedModelIdx], $i18n.language);
$: showRecentChats = !modelSuggestionPrompts?.length && ($recentChats?.length ?? 0) > 0;
// Until recent chats first load, show neither rather than flash the defaults.
$: waitingForRecentChats = !modelSuggestionPrompts?.length && $recentChats === null;
$: selectedSuggestionPrompts =
modelSuggestionPrompts ??
resolveLocalizedPromptSuggestions(
$config?.default_prompt_suggestions,
$config?.default_prompt_suggestions_i18n ?? {},
@@ -131,6 +138,10 @@
(key) => $i18n.t(key)
);
onMount(() => {
refreshRecentChats(localStorage.token);
});
// True when viewing a shared folder the current user doesn't own AND lacks write access
$: folderReadOnly =
$selectedFolder != null &&
@@ -374,7 +385,15 @@
<div class="mx-auto max-w-2xl mt-3" in:fade={{ duration: 200, delay: 200 }}>
<div class="mx-5">
<Suggestions suggestionPrompts={selectedSuggestionPrompts} inputValue={prompt} {onSelect} />
{#if showRecentChats}
<RecentChats chats={$recentChats} showIdentifier={!selectedSuggestionPrompts?.length} />
{:else if !waitingForRecentChats}
<Suggestions
suggestionPrompts={selectedSuggestionPrompts}
inputValue={prompt}
{onSelect}
/>
{/if}
</div>
</div>
{/if}
@@ -206,8 +206,8 @@
on:dragstart={(event) => chatDragStartHandler(event, chat)}
on:click={(event) => open(event, chat)}
>
<div class="flex shrink-0 items-center gap-2">
<!-- Status, its time, then priority, kept close together. -->
<!-- Status, its time, priority, then the marker dot a little apart. -->
<div class="flex shrink-0 items-center gap-1">
<div class="flex items-center gap-0.5">
<FolderStatusControl {chat} disabled={!!saving || loading} onChange={onMove} />
{#if showStatusTime}
@@ -192,8 +192,8 @@
{/if}
</div>
{#if chat.pending_approval || chat.active || unread}
<!-- Centered on the title's first line, like the list's marker slot. -->
<span class="flex h-5 w-3 shrink-0 items-center justify-center">
<!-- Centered on the title's first line; same distance from the icons as in the list. -->
<span class="-ml-0.5 flex h-5 w-3 shrink-0 items-center justify-center">
{#if chat.pending_approval}
<span
class="size-1.5 rounded-full bg-yellow-500"
@@ -0,0 +1,85 @@
<script lang="ts">
import { getContext } from 'svelte';
import { WEBUI_NAME } from '$lib/stores';
import { WEBUI_VERSION } from '$lib/constants';
import { formatDateDetails, formatElapsedShort, formatShortDate } from '$lib/utils';
import Spinner from '$lib/components/common/Spinner.svelte';
const i18n: any = getContext('i18n');
type RecentChat = {
id: string;
title?: string;
updated_at?: number;
last_read_at?: number | null;
active?: boolean;
pending_approval?: boolean;
};
export let chats: RecentChat[] = [];
// Shown when there are no suggestions either, as the suggestions list would.
export let showIdentifier = false;
// "45s", "12m", "3h", "5d" for the last week, then a short date.
const formatTime = (seconds: number) =>
Date.now() / 1000 - seconds < 7 * 86400
? formatElapsedShort(seconds)
: formatShortDate(seconds, $i18n.language);
// Same rule as the sidebar: never read, or updated since it was last read.
const isUnread = (chat: RecentChat) =>
!chat.active && (chat.last_read_at == null || (chat.updated_at ?? 0) > chat.last_read_at);
</script>
<div class="w-full text-left">
<h3 id="recent-chats-heading" class="mb-1 -mx-1 text-xs text-base-400 dark:text-base-500">
{$i18n.t('chat.placeholder.recentChats')}
</h3>
<ul aria-labelledby="recent-chats-heading">
{#each chats as chat (chat.id)}
{@const unread = isUnread(chat)}
<li>
<a
href="/c/{chat.id}"
class="group flex items-center gap-2 h-7 -mx-2 px-2 rounded-lg text-sm transition-colors duration-75 hover:bg-base-50 dark:hover:bg-base-850"
title={chat.updated_at ? formatDateDetails(chat.updated_at, $i18n.language) : undefined}
>
{#if chat.pending_approval}
<span
class="size-1.5 shrink-0 rounded-full bg-yellow-500"
role="status"
aria-label={$i18n.t('Waiting for approval')}
></span>
{:else if chat.active}
<span class="shrink-0"><Spinner className="size-3" /></span>
{:else if unread}
<span class="size-1.5 shrink-0 rounded-full bg-sky-500" aria-hidden="true"></span>
{/if}
<span
dir="auto"
class="flex-1 min-w-0 truncate transition-colors duration-75 group-hover:text-base-900 dark:group-hover:text-base-100 {unread
? 'text-base-800 dark:text-base-200'
: 'text-base-500 dark:text-base-400'}"
>
{chat.title}
</span>
{#if chat.updated_at}
<span class="shrink-0 text-xs tabular-nums text-base-400 dark:text-base-600">
{formatTime(chat.updated_at)}
</span>
{/if}
</a>
</li>
{/each}
</ul>
{#if showIdentifier}
<!-- LICENSE covers this Open WebUI footer identifier.
Do not alter, remove, obscure, or replace it except as LICENSE permits:
https://docs.openwebui.com/license. -->
<div class="mt-2 text-xs text-base-600 dark:text-base-400">
{$WEBUI_NAME} ‧ v{WEBUI_VERSION}
</div>
{/if}
</div>