From 89b2c9d9198514565e6e20003aa55061c043836d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 4 Dec 2026 08:05:29 +0400 Subject: [PATCH] refac --- .../chat/Placeholder/FolderPlaceholder.svelte | 58 ++++++++++++++++--- src/lib/stores/index.ts | 2 + 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/lib/components/chat/Placeholder/FolderPlaceholder.svelte b/src/lib/components/chat/Placeholder/FolderPlaceholder.svelte index e87af59ec6..21e6816809 100644 --- a/src/lib/components/chat/Placeholder/FolderPlaceholder.svelte +++ b/src/lib/components/chat/Placeholder/FolderPlaceholder.svelte @@ -80,6 +80,7 @@ import DropdownSub from '$lib/components/common/DropdownSub.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import Check from '$lib/components/icons/Check.svelte'; + import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte'; import Plus from '$lib/components/icons/Plus.svelte'; import ChevronRight from '$lib/components/icons/ChevronRight.svelte'; import FolderAutomations from './FolderAutomations.svelte'; @@ -233,14 +234,31 @@ knowledge: $i18n.t('Knowledge') } satisfies Record; let sectionTabs: [FolderSection, string][]; - $: sectionTabs = tabOrder - .filter( - (id) => - (id !== 'files' || filesTarget) && - (id !== 'notes' || canUseNotes) && - (id !== 'automations' || canUseAutomations) - ) + // Every tab this folder offers, shown or hidden, for the menu. + $: availableTabs = tabOrder.filter( + (id) => + (id !== 'files' || filesTarget) && + (id !== 'notes' || canUseNotes) && + (id !== 'automations' || canUseAutomations) + ); + // Overview is always shown. + let hiddenTabs: FolderSection[]; + $: hiddenTabs = (($settings?.folderTabHidden ?? []) as FolderSection[]).filter( + (id) => id !== 'overview' + ); + $: sectionTabs = availableTabs + .filter((id) => !hiddenTabs.includes(id)) .map((id) => [id, tabLabels[id]]); + // Hiding the open tab moves to the Overview. + $: if (hiddenTabs.includes(folderSection)) showSection('overview', false); + + const toggleTab = async (id: FolderSection) => { + const next = hiddenTabs.includes(id) + ? hiddenTabs.filter((hidden) => hidden !== id) + : [...hiddenTabs, id]; + settings.set({ ...$settings, folderTabHidden: next }); + await updateUserSettings(localStorage.token, { ui: { folderTabHidden: next } }); + }; const sortableTabs = (node: HTMLElement) => { if ($mobile) return; @@ -1383,6 +1401,32 @@ {/each} + + + + + {#each availableTabs.filter((id) => id !== 'overview') as id (id)} + {@const shown = !hiddenTabs.includes(id)} + + {/each} + + +
{#if folderSection === 'overview'} diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 75e0093161..aaac576783 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -401,6 +401,8 @@ type Settings = { sidebarSectionOrder?: string[]; /** Folder page tab ids ('overview', 'files', 'chats', ...) in display order. */ folderTabOrder?: string[]; + /** Folder page tab ids the user has hidden. */ + folderTabHidden?: string[]; /** Folder ids in display order, by parent folder id ('root' for top-level folders and folderSections). */ folderOrder?: Record; /** Whose top-level folders the sidebar lists. */