mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-06 03:28:12 -05:00
refac
This commit is contained in:
1 parent
376e77cee0
commit
54d1b41fd3
4 files changed
+42
-35
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import DateSeparator from '../common/DateSeparator.svelte';
|
||||
import Loader from '../common/Loader.svelte';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import Grid from '$lib/components/icons/Grid.svelte';
|
||||
import {
|
||||
addReaction,
|
||||
@@ -105,54 +106,46 @@
|
||||
{:else if !thread}
|
||||
<div class="px-4 max-w-full mx-auto">
|
||||
{#if channel}
|
||||
<div class="flex flex-col gap-1.5 pb-4 pt-8">
|
||||
<div class="flex flex-col items-center text-center gap-1 pt-10 pb-4">
|
||||
{#if channel?.type === 'dm'}
|
||||
<div class="flex ml-[0.0625rem] mr-0.5">
|
||||
<div class="flex mb-1.5">
|
||||
{#each channel.users.filter((u) => u.id !== $user?.id).slice(0, 2) as u, index}
|
||||
<img
|
||||
src={`${WEBUI_API_BASE_URL}/users/${u.id}/profile/image`}
|
||||
alt={u.name}
|
||||
class=" size-7 rounded-full object-cover border-2 border-base-0 dark:border-base-900 {index ===
|
||||
alt=""
|
||||
class="size-10 rounded-full object-cover border-2 border-base-0 dark:border-base-900 {index ===
|
||||
1
|
||||
? '-ml-2.5'
|
||||
? '-ml-3'
|
||||
: ''}"
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="text-lg font-medium leading-6">
|
||||
{#if channel?.name}
|
||||
{channel.name}
|
||||
{:else}
|
||||
{channel?.users
|
||||
?.filter((u) => u.id !== $user?.id)
|
||||
.map((u) => u.name)
|
||||
.join(', ')}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="text-xs leading-5 text-base-500 dark:text-base-400">
|
||||
{$i18n.t(
|
||||
'This channel was created on {{createdAt}}. This is the very beginning of the {{channelName}} channel.',
|
||||
{
|
||||
createdAt: dayjs(channel.created_at / 1000000)
|
||||
.locale($i18n.language)
|
||||
.format('MMMM D, YYYY'),
|
||||
channelName: channel.name
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
<Tooltip
|
||||
content={$i18n.t('Created {{date}}', {
|
||||
date: dayjs(channel.created_at / 1000000)
|
||||
.locale($i18n.language)
|
||||
.format('MMMM D, YYYY')
|
||||
})}
|
||||
>
|
||||
<div class="text-sm font-medium line-clamp-1">
|
||||
{#if channel?.name}
|
||||
{channel.name}
|
||||
{:else}
|
||||
{channel?.users
|
||||
?.filter((u) => u.id !== $user?.id)
|
||||
.map((u) => u.name)
|
||||
.join(', ')}
|
||||
{/if}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex justify-center text-xs items-center gap-2 py-5">
|
||||
<div class=" ">{$i18n.t('Start of the channel')}</div>
|
||||
<div class="flex justify-center text-xs text-base-500 dark:text-base-400 py-5">
|
||||
{$i18n.t('Start of the channel')}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if messageList.length > 0}
|
||||
<hr class=" border-base-100/60 dark:border-base-800/40 mb-2 w-full" />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -4594,6 +4594,8 @@
|
||||
$: tabTitleEditor = editingTitle ? renderTitleEditor : undefined;
|
||||
/** A chat's actions on its tab: the Navbar's for the main chat, the chat menu for a side chat. */
|
||||
export let tabActions: import('svelte').Snippet | undefined = undefined;
|
||||
/** The tab bar's actions while this chat is focused: the Navbar's for the main chat, the status for a side chat. */
|
||||
export let tabBarActions: import('svelte').Snippet | undefined = undefined;
|
||||
let showShareModal = false;
|
||||
$: showChatMenu =
|
||||
!loading &&
|
||||
@@ -4607,6 +4609,7 @@
|
||||
$: chatMenu = showChatMenu && !editingTitle ? renderChatMenu : undefined;
|
||||
$: chatStatus = showChatMenu && !$temporaryChat && !isShared ? renderChatStatus : undefined;
|
||||
$: if (embedded && tabbed) tabActions = chatMenu;
|
||||
$: if (embedded && tabbed) tabBarActions = chatStatus;
|
||||
|
||||
export const getOverview = () => ({ history, chatUser: chatOwner, showMessage });
|
||||
|
||||
@@ -4700,8 +4703,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
let tabBarActions: import('svelte').Snippet | undefined;
|
||||
|
||||
let initializedMachineChatId: string | null = null;
|
||||
const initializeMachineDirectory = async (id: string, context: MachineContext | null) => {
|
||||
if (initializedMachineChatId === id) return;
|
||||
|
||||
@@ -256,6 +256,7 @@
|
||||
let chatViews: Record<string, ChatTab> = {};
|
||||
let chatTitleEditors: Record<string, import('svelte').Snippet | undefined> = {};
|
||||
let chatTabActions: Record<string, import('svelte').Snippet | undefined> = {};
|
||||
let chatTabBarActions: Record<string, import('svelte').Snippet | undefined> = {};
|
||||
let chatStreamingStates: Record<string, boolean> = {};
|
||||
// Each chat writes its artifacts here; its artifacts tab reads them.
|
||||
const chatArtifacts: Record<string, Writable<{ type: string; content: string }[]>> = {};
|
||||
@@ -335,6 +336,7 @@
|
||||
chatStreamingStates = {};
|
||||
chatTitleEditors = {};
|
||||
chatTabActions = {};
|
||||
chatTabBarActions = {};
|
||||
queuedArtifactCode = null;
|
||||
}
|
||||
/** Starts a new chat that keeps the open pages; everything else stays with the chat being left. */
|
||||
@@ -353,6 +355,7 @@
|
||||
chatStreamingStates = {};
|
||||
chatTitleEditors = {};
|
||||
chatTabActions = {};
|
||||
chatTabBarActions = {};
|
||||
queuedArtifactCode = null;
|
||||
const entry = chatViewEntry($user.id, null, $temporaryChat);
|
||||
entry.state = {
|
||||
@@ -425,6 +428,7 @@
|
||||
chatStreamingStates = {};
|
||||
chatTitleEditors = {};
|
||||
chatTabActions = {};
|
||||
chatTabBarActions = {};
|
||||
const entry = chatViewEntry($user.id, id, $temporaryChat);
|
||||
const loading: ViewState = { status: 'loading', entry, chatId: id };
|
||||
setView(loading);
|
||||
@@ -527,6 +531,7 @@
|
||||
chatStreamingStates = {};
|
||||
chatTitleEditors = {};
|
||||
chatTabActions = {};
|
||||
chatTabBarActions = {};
|
||||
clearChatViews();
|
||||
}
|
||||
const forgetDraftsForUnreachableMachines = (..._connections: unknown[]) => {
|
||||
@@ -1376,6 +1381,7 @@
|
||||
delete chatStreamingStates[id];
|
||||
delete chatTitleEditors[id];
|
||||
delete chatTabActions[id];
|
||||
delete chatTabBarActions[id];
|
||||
delete artifactSelections[id];
|
||||
if (tab.kind === 'chat') {
|
||||
delete chatArtifacts[id];
|
||||
@@ -2311,6 +2317,7 @@
|
||||
bind:streaming={chatStreamingStates[tab.id]}
|
||||
bind:tabTitleEditor={chatTitleEditors[tab.id]}
|
||||
bind:tabActions={chatTabActions[tab.id]}
|
||||
bind:tabBarActions={chatTabBarActions[tab.id]}
|
||||
artifacts={getChatArtifacts(tab.id)}
|
||||
onOpenArtifacts={(code) => openArtifacts(code, tab.id)}
|
||||
initialView={chatView.transient[`chat:${tab.id}`]}
|
||||
@@ -2793,6 +2800,10 @@
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
{@render tabBarActions?.()}
|
||||
</div>
|
||||
{:else if chatTabBarActions[group.activeId]}
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
{@render chatTabBarActions[group.activeId]?.()}
|
||||
</div>
|
||||
{/if}
|
||||
{#if !fullWidth && (!isLargeScreen || group.id === tabs.groups[0].id)}
|
||||
<button
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
export const getOverview = () => chatView?.getOverview();
|
||||
export let tabTitleEditor: import('svelte').Snippet | undefined = undefined;
|
||||
export let tabActions: import('svelte').Snippet | undefined = undefined;
|
||||
export let tabBarActions: import('svelte').Snippet | undefined = undefined;
|
||||
|
||||
export let initialPrompt = '';
|
||||
export let initialView: any = null;
|
||||
@@ -110,6 +111,7 @@
|
||||
bind:this={chatView}
|
||||
bind:tabTitleEditor
|
||||
bind:tabActions
|
||||
bind:tabBarActions
|
||||
embedded={true}
|
||||
tabbed={true}
|
||||
{parentChatId}
|
||||
|
||||
Reference in new issue
Block a user