From 54d1b41fd3f5d96b737fbaca170246dc9e1a85d4 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 26 Nov 2026 15:48:48 +0400 Subject: [PATCH] refac --- src/lib/components/channel/Messages.svelte | 59 +++++++++------------ src/lib/components/chat/Chat.svelte | 5 +- src/lib/components/chat/Tabs.svelte | 11 ++++ src/lib/components/chat/Tabs/ChatTab.svelte | 2 + 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/lib/components/channel/Messages.svelte b/src/lib/components/channel/Messages.svelte index c7f988a1f1..f5eecef444 100644 --- a/src/lib/components/channel/Messages.svelte +++ b/src/lib/components/channel/Messages.svelte @@ -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}
{#if channel} -
+
{#if channel?.type === 'dm'} -
+
{#each channel.users.filter((u) => u.id !== $user?.id).slice(0, 2) as u, index} {u.name} {/each}
{/if} -
- {#if channel?.name} - {channel.name} - {:else} - {channel?.users - ?.filter((u) => u.id !== $user?.id) - .map((u) => u.name) - .join(', ')} - {/if} -
- -
- {$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 - } - )} -
+ +
+ {#if channel?.name} + {channel.name} + {:else} + {channel?.users + ?.filter((u) => u.id !== $user?.id) + .map((u) => u.name) + .join(', ')} + {/if} +
+
{:else} -
-
{$i18n.t('Start of the channel')}
+
+ {$i18n.t('Start of the channel')}
{/if} - - {#if messageList.length > 0} -
- {/if}
{/if} diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index dae0ca486b..03f6ea609d 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -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; diff --git a/src/lib/components/chat/Tabs.svelte b/src/lib/components/chat/Tabs.svelte index 4d14814c4f..cb29409e21 100644 --- a/src/lib/components/chat/Tabs.svelte +++ b/src/lib/components/chat/Tabs.svelte @@ -256,6 +256,7 @@ let chatViews: Record = {}; let chatTitleEditors: Record = {}; let chatTabActions: Record = {}; + let chatTabBarActions: Record = {}; let chatStreamingStates: Record = {}; // Each chat writes its artifacts here; its artifacts tab reads them. const chatArtifacts: Record> = {}; @@ -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 @@
{@render tabBarActions?.()}
+ {:else if chatTabBarActions[group.activeId]} +
+ {@render chatTabBarActions[group.activeId]?.()} +
{/if} {#if !fullWidth && (!isLargeScreen || group.id === tabs.groups[0].id)}