From 6441877c0139d22d65d147c20d8dff39efd363ac Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 2 Nov 2026 12:13:56 +0900 Subject: [PATCH] refac --- src/lib/components/chat/ChatTabs.svelte | 98 ++++++++++++++----------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/lib/components/chat/ChatTabs.svelte b/src/lib/components/chat/ChatTabs.svelte index c2962552a0..3cf4910127 100644 --- a/src/lib/components/chat/ChatTabs.svelte +++ b/src/lib/components/chat/ChatTabs.svelte @@ -482,6 +482,16 @@ { kind: 'comments', label: $i18n.t('Comments'), available: showCommentsTab } ]; + $: showFilesMenuItem = + showFilesTab && + !tabs.tabs.some( + (tab) => tab.id === ($selectedTerminalId ? `files:${$selectedTerminalId}` : 'files') + ); + $: newTabViews = availableViews.filter( + (view) => view.kind !== 'files' && view.kind !== 'voice' && view.available + ); + $: canOpenNewTab = showFilesMenuItem || terminalFilesAvailable || newTabViews.length > 0; + $: directTerminals = ($settings as { terminalServers?: { url: string; key?: string }[] })?.terminalServers ?? []; const terminalAccessible = (selector: string) => { @@ -499,6 +509,7 @@ ); }; const pruneTabs = () => { + const hadTabs = tabs.tabs.length > 0; for (const tab of tabs.tabs) { // An open side chat owns its model and context; changing the parent must not discard it. if (tab.kind === 'side') continue; @@ -511,6 +522,7 @@ delete fileContexts[tab.id]; } } + if (hadTabs && !tabs.tabs.length) showTabs.set(false); }; $: { availableViews; @@ -819,46 +831,50 @@ {/each} - - -
- - {#if showFilesTab && !tabs.tabs.some((tab) => tab.id === ($selectedTerminalId ? `files:${$selectedTerminalId}` : 'files'))} - - {/if} - {#if terminalFilesAvailable}{/if} - {#if terminalEnabled}{/if} - {#if browserEnabled}{/if} - {#if desktopEnabled}{/if} - {#each availableViews.filter((view) => view.kind !== 'files' && view.kind !== 'voice' && view.available) as view} - - {/each} - -
-
+ {#if canOpenNewTab} + + +
+ + {#if showFilesMenuItem} + + {/if} + {#if terminalFilesAvailable}{/if} + {#if terminalEnabled}{/if} + {#if browserEnabled}{/if} + {#if desktopEnabled}{/if} + {#each newTabViews as view} + + {/each} + +
+
+ {/if}