From 466885fd26b74bd20de67ee0ef0e55a47826cd47 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 10 Nov 2026 11:05:42 +0000 Subject: [PATCH] feat: fold sidebar AI chats and sessions inactive for over a week (#12314) * feat: fold sidebar AI chats and sessions inactive for over a week Co-Authored-By: Claude Opus 5.5 * fix: fold sidebar sessions only when no activity cutoff is picked Co-Authored-By: Claude Opus 5.5 * refactor: render the sidebar show-older row with Button Co-Authored-By: Claude Opus 5.5 * feat: persist the sidebar show-older state Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- .../components/sessions/SessionPicker.svelte | 42 ++++++++++++++++--- .../components/sidebar/AiChatsSection.svelte | 34 ++++++++++++--- .../sidebar/SidebarShowOlder.svelte | 34 +++++++++++++++ 3 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 frontend/src/lib/components/sidebar/SidebarShowOlder.svelte diff --git a/frontend/src/lib/components/sessions/SessionPicker.svelte b/frontend/src/lib/components/sessions/SessionPicker.svelte index b194592809..a6c8ceb630 100644 --- a/frontend/src/lib/components/sessions/SessionPicker.svelte +++ b/frontend/src/lib/components/sessions/SessionPicker.svelte @@ -61,6 +61,9 @@ import UnreadCountBadge from '$lib/components/common/badge/UnreadCountBadge.svelte' import { buildWorkspaceHierarchy } from '$lib/utils/workspaceHierarchy' import MenuButton, { sidebarClasses } from '$lib/components/sidebar/MenuButton.svelte' + import SidebarShowOlder, { + SIDEBAR_RECENT_MS + } from '$lib/components/sidebar/SidebarShowOlder.svelte' import DropdownV2 from '$lib/components/DropdownV2.svelte' import { userStore, userWorkspaces, workspaceStore } from '$lib/stores' import { workspaceIsFork } from '$lib/utils/workspaceHierarchy' @@ -175,10 +178,9 @@ ) } - // Flat list passing the archive + scope filters. Grouping for display happens - // in `sessionGroups`; this flat view drives the runtime effect, the unread - // total, and keyboard navigation. - const visibleSessions = $derived( + // Every session passing the archive + scope filters, the ones folded under "Show older" + // included. + const filteredSessions = $derived( sessionState.sessions.filter((s) => { // A draft Home's composer holds becomes a session when its first send starts, typed // or not. Unsent drafts opened onto an item stay listed: the row is their only way @@ -198,6 +200,25 @@ }) ) + // With no activity cutoff picked, sessions inactive for over a week fold under a "Show older" + // row, except the one on screen. A picked cutoff is the reader's own choice and folds nothing. + const showOlder = useLocalStorageValue('windmill_sessions_show_older', false, 'boolean') + const olderIds = $derived.by(() => { + if (lastActivityDays.val > 0) return new Set() + const cutoff = clock - SIDEBAR_RECENT_MS + return new Set( + filteredSessions + .filter((s) => s.id !== activeRowId && sessionLastActivityAt(s) < cutoff) + .map((s) => s.id) + ) + }) + + // The rows listed. Grouping for display happens in `sessionGroups`; this flat view drives + // the runtime effect, the unread total, and keyboard navigation. + const visibleSessions = $derived( + showOlder.val ? filteredSessions : filteredSessions.filter((s) => !olderIds.has(s.id)) + ) + // Sessions grouped by workspace family for display, each group by its last turn // start or end, latest first. Family order follows its latest session and is NOT tied // to the current workspace: pinning the active family first reshuffled the @@ -384,7 +405,7 @@ // sessions load, the list is empty for every reader, and the fold is a // layout they chose to keep. $effect(() => { - if (sessionState.hydrated && visibleSessions.length === 0 && sectionCollapsed.val) { + if (sessionState.hydrated && filteredSessions.length === 0 && sectionCollapsed.val) { sectionCollapsed.val = false } }) @@ -785,7 +806,7 @@ icon={MessageSquare} folded={sectionCollapsed.val} onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)} - disabled={visibleSessions.length === 0} + disabled={filteredSessions.length === 0} notify={totalUnread > 0} actions={sectionOptions} {isCollapsed} @@ -1132,6 +1153,15 @@ {/each} {/if} + + {#if olderIds.size > 0} + (showOlder.val = !showOlder.val)} + {rail} + /> + {/if} {#if selecting}