-
[OPIK-6052] [FE] fix: unify sidebar collapse/expand behavior across pages (#6360)
发布于
2026-04-20 10:33:49 +00:00 - [OPIK-6052] [FE] fix: unify sidebar collapse/expand behavior across pages
Three tiers replace the page-dependent logic:
- Phone: always collapsed, no toggle.
- Small-medium: collapsed by default, session-only toggle (useState).
- Big: expanded by default, persisted via localStorage.
Assistant-sidebar width is now seeded synchronously from localStorage,
so the nav sidebar no longer flashes expanded → collapsed on first
paint when Ollie is present. On phones, the assistant panel takes
100vw when open so a previously-resized-wide panel doesn't overflow.Shared constants/helpers extracted to src/constants/assistantSidebar.ts
(single source of truth for the plugin and PageLayout). SideBar now
takes canToggle + onToggle instead of a raw setter. Dropped a stale
ref-based DOM-write pattern.Extra: Prompt playground "Add variant" strip no longer shows a
double-border against the assistant sidebar — border-r replaced with
a non-inset box-shadow that gets clipped by the overflow-x:auto
parent when flush against the edge, and stays visible when a wide
viewport leaves empty space.- Revision: phone assistant as fixed overlay, not flex child
Addresses Baz review: on phones the assistant wrapper was a flex
child at100vwwhich stole all space from theflex-1main content
container, and the--assistant-sidebar-widthCSS var at100vwdrove
.comet-content-inset'scalc(100vw - sidebar - assistant)negative.On
isPhone && isAssistantOpen, render the wrapper asfixed inset-0 z-40so it's out of flex flow, and set the layout CSS var to0px.
Main content flexes with full width; the assistant overlays visually.- Revision 2: centralize assistant-sidebar localStorage writes
handleTogglein plugins/comet/AssistantSidebar.tsx was calling
localStorage.setItem("assistant-sidebar-open", …)while the shared
constants module owned the corresponding reads — two source-of-truth
for the same key.Add a
setAssistantSidebarOpen(open)setter alongside the existing
getters inconstants/assistantSidebar.tsand use it from
handleToggle. Also pulled the key strings into file-local constants
inside the shared module so reads and writes share one token.下载附件