From 6d84f3ff1a8d91a2cd4f4c91dc8647c3eb58d7c1 Mon Sep 17 00:00:00 2001 From: Illia Panasenko Date: Sun, 26 Jul 2026 14:24:20 +0200 Subject: [PATCH] fix(web): persist the Settled shelf's collapsed state Collapsing Settled in Sidebar V2 read as a lasting preference but was component state, so every relaunch brought the history back. Move it to the useLocalStorage hook used for other client-only UI prefs, defaulting to expanded so nothing changes for anyone who hasn't collapsed it. --- apps/web/src/components/SidebarV2.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx index 8c5891ebe7e..2b05b7aec05 100644 --- a/apps/web/src/components/SidebarV2.tsx +++ b/apps/web/src/components/SidebarV2.tsx @@ -1,4 +1,5 @@ import { autoAnimate } from "@formkit/auto-animate"; +import * as Schema from "effect/Schema"; import { useAtomValue } from "@effect/atom-react"; import { canSnooze, @@ -87,6 +88,7 @@ import { openCommandPalette } from "../commandPaletteBus"; import { startNewThreadFromContext } from "../lib/chatThreadActions"; import { useClientSettings, useUpdateClientSettings } from "../hooks/useSettings"; import { useCopyToClipboard } from "../hooks/useCopyToClipboard"; +import { useLocalStorage } from "../hooks/useLocalStorage"; import { useNowMinute } from "../hooks/useNowMinute"; import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments"; import { useProjects, useThreadShells } from "../state/entities"; @@ -158,6 +160,9 @@ import { useComposerDraftStore } from "../composerDraftStore"; // stays behind an explicit Show more. const SETTLED_TAIL_INITIAL_COUNT = 10; const SETTLED_TAIL_PAGE_COUNT = 25; +// Collapsing Settled is a lasting preference — someone who tucks history away +// doesn't want it back on the next launch. +const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar-v2:settled-expanded"; const PROJECT_GROUPING_MODE_LABELS: Record = { repository: "Group by repository", repository_path: "Group by repository path", @@ -1473,8 +1478,15 @@ export default function SidebarV2() { () => setSettledVisibleCount((count) => count + SETTLED_TAIL_PAGE_COUNT), [], ); - const [settledShelfExpanded, setSettledShelfExpanded] = useState(true); - const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []); + const [settledShelfExpanded, setSettledShelfExpanded] = useLocalStorage( + SETTLED_SHELF_EXPANDED_KEY, + true, + Schema.Boolean, + ); + const toggleSettledShelf = useCallback( + () => setSettledShelfExpanded((value) => !value), + [setSettledShelfExpanded], + ); const renderedSettledThreads = useMemo(() => { if (settledShelfExpanded) return visibleSettledThreads; if (routeThreadKey === null) return [];