Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-5842: fix(ui): drop the write-only sidebar_state cookie and align the settings nav trigger (#6621)
Bohan Jiangb15b902d3bc2
diff --git a/packages/ui/components/ui/sidebar.tsx b/packages/ui/components/ui/sidebar.tsxindex 72b10c54c8..7a216c9e3f 100644--- a/packages/ui/components/ui/sidebar.tsx+++ b/packages/ui/components/ui/sidebar.tsx@@ -26,8 +26,6 @@ import {} from "@multica/ui/components/ui/tooltip"import { PanelLeftIcon } from "lucide-react"-const SIDEBAR_COOKIE_NAME = "sidebar_state"-const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7const SIDEBAR_WIDTH_DEFAULT = 256const SIDEBAR_WIDTH_MIN = 200const SIDEBAR_WIDTH_MAX = 360@@ -124,6 +122,15 @@ function SidebarProvider({// This is the internal state of the sidebar.// We use openProp and setOpenProp for control from outside the component.+ //+ // Deliberately not persisted. Upstream shadcn writes a `sidebar_state` cookie+ // here and seeds `defaultOpen` from it on the server; we dropped the write+ // because nothing ever read it, and restoring the pair would be a bug rather+ // than a feature: the auto-collapse below drives `setOpen(false)` from the+ // viewport, so persisting its result would carry a collapse the user never+ // asked for out of the `lg`–`xl` band and into their next session on a wider+ // display. Persisting this needs a source that distinguishes a user toggle+ // from an automated one — not a cookie on this callback.const [_open, _setOpen] = React.useState(defaultOpen)const open = openProp ?? _openconst setOpen = React.useCallback(@@ -134,9 +141,6 @@ function SidebarProvider({} else {_setOpen(openState)}-- // This sets the cookie to keep the sidebar state.- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`},[setOpenProp, open])diff --git a/packages/views/layout/sidebar-auto-collapse.test.tsx b/packages/views/layout/sidebar-auto-collapse.test.tsxindex b928b436a9..d64b73d294 100644--- a/packages/views/layout/sidebar-auto-collapse.test.tsx+++ b/packages/views/layout/sidebar-auto-collapse.test.tsx@@ -170,4 +170,26 @@ describe("sidebar auto-collapse between lg and xl", () => {expect(state()).toBe("expanded");});++ it("never persists the open state, however it changed", () => {+ // The guard for the trap upstream shadcn sets: it writes a `sidebar_state`+ // cookie in `setOpen` and seeds `defaultOpen` from it server-side. Because+ // the auto-collapse above drives `setOpen(false)` from the viewport rather+ // than from the user, wiring that pair back up would carry a collapse+ // nobody asked for out of this band and into the next session on a wider+ // display. Asserted for both paths — a real toggle and a crossing — since+ // it is the crossing that makes persistence wrong here.+ renderWithI18n(+ <SidebarProvider>+ <Probe />+ </SidebarProvider>,+ );++ fireEvent.click(screen.getByTestId("state"));+ expect(document.cookie).not.toContain("sidebar_state");++ setWidth(1100);+ expect(state()).toBe("collapsed");+ expect(document.cookie).not.toContain("sidebar_state");+ });});diff --git a/packages/views/settings/components/settings-page.tsx b/packages/views/settings/components/settings-page.tsxindex e9457bd333..ea49d238eb 100644--- a/packages/views/settings/components/settings-page.tsx+++ b/packages/views/settings/components/settings-page.tsx@@ -161,9 +161,12 @@ export function SettingsPage({ extraAccountTabs }: SettingsPageProps = {}) {{/* This page builds its own chrome instead of a PageHeader, so it hasto supply the nav trigger itself — below `xl` the nav is a sheet orauto-collapsed, and settings has no other way back to it. */}- <div className="flex items-center">+ {/* The gap below this row belongs to the row, not to the heading: with+ `items-center`, a bottom margin on the `h1` is part of the box being+ centred, so it offsets the heading against the trigger beside it. */}+ <div className="flex items-center md:mb-4"><CollapsedNavTrigger />- <h1 className="sr-only text-body font-semibold md:not-sr-only md:mb-4 md:px-2">{t(($) => $.page.title)}</h1>+ <h1 className="sr-only text-body font-semibold md:not-sr-only md:px-2">{t(($) => $.page.title)}</h1></div><TabsListvariant="line"