Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/sim/app/_styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ html.sidebar-resizing .sidebar-shell-inner {
transition: none !important;
}

/* Suppress sidebar transitions during the initial hydration window. The
pre-paint script sets the correct --sidebar-width, but store rehydration
re-applies it a tick later; without this guard that re-apply animates the
rail, reading as a collapse -> expand flash on a fresh page load. Removed
after the first paint (see workspace-chrome.tsx) so user-driven toggles and
the fullscreen slide still animate. */
html.sidebar-booting .sidebar-container,
html.sidebar-booting .sidebar-shell-outer,
html.sidebar-booting .sidebar-shell-inner {
transition: none !important;
}

.panel-container {
width: var(--panel-width);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useEffect, useLayoutEffect } from 'react'
import { useEffect, useLayoutEffect, useRef } from 'react'
import { cn } from '@sim/emcn'
import { usePathname } from 'next/navigation'
import { Sidebar } from '@/app/workspace/[workspaceId]/w/components/sidebar/sidebar'
Expand Down Expand Up @@ -47,6 +47,8 @@ export function WorkspaceChrome({
children,
initialSidebarCollapsed = false,
}: WorkspaceChromeProps) {
const rafRef = useRef(0)

const pathname = usePathname()
const isFullscreen = isFullscreenPath(pathname)

Expand All @@ -66,6 +68,29 @@ export function WorkspaceChrome({
*/
const isCollapsed = hasHydrated ? storeIsCollapsed : initialSidebarCollapsed

/**
* Suppresses sidebar transitions across the initial hydration window. The
* pre-paint script already set the correct `--sidebar-width`, but the store
* rehydration below re-applies it a tick later; without this guard that
* re-apply animates the rail, reading as a collapse -> expand flash on a
* fresh load. Applied before the rehydrate effect so the class is in place
* ahead of the width mutation, then lifted after the first paint so
* user-driven collapse toggles and the fullscreen slide still animate.
*/
useLayoutEffect(() => {
const root = document.documentElement
root.classList.add('sidebar-booting')
const raf1 = requestAnimationFrame(() => {
const raf2 = requestAnimationFrame(() => root.classList.remove('sidebar-booting'))
rafRef.current = raf2
})
rafRef.current = raf1
return () => {
cancelAnimationFrame(rafRef.current)
root.classList.remove('sidebar-booting')
}
}, [])

// Hydrate the persisted width before paint (collapse comes from the cookie/prop).
useLayoutEffect(() => {
void useSidebarStore.persist.rehydrate()
Expand Down
Loading