From c6047efc4e6065fa47d350e52de53c25681d9639 Mon Sep 17 00:00:00 2001 From: Justin Blumencranz <96924014+j15z@users.noreply.github.com> Date: Thu, 13 Aug 2026 20:01:52 -0700 Subject: [PATCH] fix(sidebar): align credits chip with panel toggle and square the collapsed rail (#6691) * fix(sidebar): align credits chip with panel toggle and square the collapsed rail * fix(sidebar): center collapsed rail chips in the rail * fix(sidebar): shrink collapsed rail to 48px so chips center without shifting on toggle --- apps/sim/app/_styles/globals.css | 2 +- apps/sim/app/layout.tsx | 2 +- .../resource-tabs/resource-tab-controls.ts | 13 ++-- .../app/workspace/[workspaceId]/home/home.tsx | 65 +++++++++---------- .../collapsed-sidebar-menu.tsx | 3 +- .../settings-sidebar/settings-sidebar.tsx | 12 +++- .../sidebar-footer/sidebar-footer.tsx | 17 +++-- .../workspace-header/workspace-header.tsx | 3 +- .../w/components/sidebar/constants.ts | 28 ++++++++ .../w/components/sidebar/sidebar.tsx | 22 ++++++- apps/sim/stores/constants.ts | 2 +- 11 files changed, 115 insertions(+), 54 deletions(-) diff --git a/apps/sim/app/_styles/globals.css b/apps/sim/app/_styles/globals.css index 1450812254..ae53a93606 100644 --- a/apps/sim/app/_styles/globals.css +++ b/apps/sim/app/_styles/globals.css @@ -11,7 +11,7 @@ */ :root { --sidebar-width: 0px; /* 0 outside workspace; blocking script always sets actual value on workspace pages */ - --sidebar-collapsed-width: 51px; /* icon rail on web; desktop overrides to 0 before first paint */ + --sidebar-collapsed-width: 48px; /* icon rail on web; desktop overrides to 0 before first paint */ --sidebar-expanded-width: 238px; /* SIDEBAR_WIDTH.DEFAULT; the width to restore to, held even while collapsed */ --desktop-title-bar-height: 0px; /* macOS traffic-light lane; desktop overrides before first paint */ --workspace-content-title-bar-inset: 0px; /* lane the content pane must leave clear; only non-zero when the pane, not the sidebar, sits under it */ diff --git a/apps/sim/app/layout.tsx b/apps/sim/app/layout.tsx index 6f5d5ff570..21688e8470 100644 --- a/apps/sim/app/layout.tsx +++ b/apps/sim/app/layout.tsx @@ -75,7 +75,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) // The macOS desktop shell overlays native traffic lights on the // workspace. Mark it before first paint so the sidebar reserves // its inset title-bar lane without a post-hydration layout shift. - var collapsedSidebarWidth = 51; + var collapsedSidebarWidth = 48; try { if (window.simDesktop && /Mac/i.test(navigator.userAgent)) { document.documentElement.setAttribute('data-sim-desktop-title-bar', 'inset'); diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tab-controls.ts b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tab-controls.ts index cf8f02ac5a..5d5697d7be 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tab-controls.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tab-controls.ts @@ -7,13 +7,18 @@ export const RESOURCE_TAB_ICON_CLASS = 'size-[16px] text-[var(--text-icon)]' /** Shared geometry for the resource header and controls positioned over it. */ export const RESOURCE_HEADER_CLASSES = { layout: - '[--resource-header-controls-height:43px] [--resource-header-end-inset:16px] [--resource-header-fixed-reserve:54px]', + '[--resource-header-controls-height:43px] [--resource-header-end-inset:16px] [--resource-header-fixed-reserve:54px] [--resource-header-toggle-size:30px]', bar: 'h-[calc(var(--resource-header-controls-height)_+_1px)]', - controls: 'h-[var(--resource-header-controls-height)]', - contentTop: 'top-[8.5px]', + overlay: 'absolute top-0 flex h-[var(--resource-header-controls-height)] items-center', startPadding: 'pl-[var(--resource-header-end-inset)]', endPadding: 'pr-[var(--resource-header-fixed-reserve)]', endPosition: 'right-[var(--resource-header-end-inset)]', - adjacentEndPosition: 'right-[var(--resource-header-fixed-reserve)]', + /** + * Sits a control 1px clear of the overlaid 30px collapse toggle — the same + * chip-to-chip gap the sidebar header cluster uses (`gap-[1px]`), so the + * credits chip and the toggle read as one cluster across both surfaces. + */ + adjacentEndPosition: + 'right-[calc(var(--resource-header-end-inset)_+_var(--resource-header-toggle-size)_+_1px)]', emptyAddOffset: '-translate-x-1.5', } as const diff --git a/apps/sim/app/workspace/[workspaceId]/home/home.tsx b/apps/sim/app/workspace/[workspaceId]/home/home.tsx index dd5d02da37..eba97d8274 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/home.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/home.tsx @@ -283,21 +283,32 @@ export function Home({ chatId, userName, userId, tableViewsEnabled }: HomeProps) setIsResourceCollapsed(true) }, [clearWidth]) + const clearResourceActivity = useCallback((resourceId: string) => { + setResourceActivityIds((current) => { + if (!current.has(resourceId)) return current + const next = new Set(current) + next.delete(resourceId) + return next + }) + }, []) + + const expandResource = () => { + userOwnsResourceViewRef.current = true + const activeResourceId = activeResourceParamRef.current + if (activeResourceId) clearResourceActivity(activeResourceId) + setIsResourceCollapsed(false) + } + const selectResourceFromUser = useCallback( (resourceId: string) => { userOwnsResourceViewRef.current = true - setResourceActivityIds((current) => { - if (!current.has(resourceId)) return current - const next = new Set(current) - next.delete(resourceId) - return next - }) + clearResourceActivity(resourceId) if (effectiveActiveResourceIdRef.current === resourceId) return effectiveActiveResourceIdRef.current = resourceId activeResourceParamRef.current = resourceId setActiveResourceId(resourceId) }, - [setActiveResourceId] + [setActiveResourceId, clearResourceActivity] ) const addResourceFromUser = useCallback( @@ -581,9 +592,17 @@ export function Home({ chatId, userName, userId, tableViewsEnabled }: HomeProps) {showEmptyState && (
@@ -690,34 +709,14 @@ export function Home({ chatId, userName, userId, tableViewsEnabled }: HomeProps)
diff --git a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx index 51721d8943..504105afec 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx @@ -31,6 +31,7 @@ import { SIDEBAR_DIVIDER_PAD_ABOVE_CLASS, SIDEBAR_DIVIDER_PAD_BELOW_CLASS, SIDEBAR_ITEM_GAP_CLASS, + SIDEBAR_RAIL_CHIP_CLASS, SIDEBAR_SECTION_GAP_CLASS, } from '@/app/workspace/[workspaceId]/w/components/sidebar/constants' import { SidebarTooltip } from '@/app/workspace/[workspaceId]/w/components/sidebar/sidebar' @@ -305,7 +306,11 @@ export function SettingsSidebar({ )} > -