Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): align default sidebar and user bar widths
Gener1ba793f5b212
diff --git a/scripts/ci/e2e-shards.mjs b/scripts/ci/e2e-shards.mjsindex 72f8d96d4..36087d4b5 100644--- a/scripts/ci/e2e-shards.mjs+++ b/scripts/ci/e2e-shards.mjs@@ -82,6 +82,7 @@ export const SPEC_SECONDS = {"57-server-delete-navigation-races.spec.ts": 55,"58-system-notifications.spec.ts": 46.600,"59-message-pagination-anchor.spec.ts": 45.600,+ "60-desktop-default-user-bar-width.spec.ts": 83.700,}function walk(directory) {diff --git a/scripts/ci/e2e-shards.test.ts b/scripts/ci/e2e-shards.test.tsindex c93ebbd99..680a47147 100644--- a/scripts/ci/e2e-shards.test.ts+++ b/scripts/ci/e2e-shards.test.ts@@ -75,17 +75,17 @@ describe("planE2eShards", () => {expect(first).toEqual(second)expect(Object.keys(SPEC_SECONDS).sort()).toEqual(specs)- expect(first).toHaveLength(10)+ expect(first).toHaveLength(11)expect([...assigned].sort()).toEqual(specs)expect(new Set(assigned).size).toBe(specs.length)expect(SPEC_SECONDS["55-message-scroll-characterization.spec.ts"]).toBe(109.548)expect(specSeconds).toEqual([- 159.35, 159.401, 159.292, 160.394, 160.366,- 159.32, 160.547, 160.676, 159.332, 160.951,+ 153.053, 151.656, 152.753, 153.443, 151.8, 154.215,+ 154.336, 153.99, 151.817, 154.381, 151.885,])expect(predictedSeconds).toEqual([- 234.35, 234.401, 234.292, 235.394, 235.366,- 234.32, 235.547, 235.676, 234.332, 235.951,+ 228.053, 226.656, 227.753, 228.443, 226.8, 229.215,+ 229.336, 228.99, 226.817, 229.381, 226.885,])expect(first.every((shard) => (shard.fixed_setup_seconds === E2E_FIXED_SETUP_SECONDSdiff --git a/src/web/src/components/community/shell/community-shell-layout.tsx b/src/web/src/components/community/shell/community-shell-layout.tsxindex 99f5d417b..9a1e3f913 100644--- a/src/web/src/components/community/shell/community-shell-layout.tsx+++ b/src/web/src/components/community/shell/community-shell-layout.tsx@@ -2,11 +2,17 @@import {useCallback,+ useInsertionEffect,+ useLayoutEffect,useRef,type CSSProperties,type ReactNode,} from "react"-import { useDefaultLayout, type PanelSize } from "react-resizable-panels"+import {+ useDefaultLayout,+ type PanelImperativeHandle,+ type PanelSize,+} from "react-resizable-panels"import { AppSurface } from "@/components/ui/app-surface"import {ResizableHandle,@@ -18,11 +24,12 @@ import type { CommunitySurface } from "@/lib/community/community-route"import { cn } from "@/lib/utils"import {COMMUNITY_RAIL_WIDTH,- COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE,+ COMMUNITY_SIDEBAR_DEFAULT_WIDTH,COMMUNITY_SIDEBAR_MAX_WIDTH,COMMUNITY_SIDEBAR_MIN_WIDTH,COMMUNITY_USER_BAR_HEIGHT_CSS,- desktopUserBarOverlayCssWidth,+ desktopSidebarRestoreTarget,+ desktopUserBarInitialOverlayCssWidth,desktopUserBarOverlayWidth,} from "./shell-frame-geometry"import { Shell } from "./shell"@@ -52,6 +59,11 @@ type CommunityShellLayoutProps = {preserveHiddenMobileModules?: boolean}+type PendingDesktopRestore = {+ target: number | string+ resizeRequested: boolean+}+/** The single geometry owner for authenticated and session-pending community shells. */export function CommunityShellLayout({breakpoint,@@ -74,18 +86,85 @@ export function CommunityShellLayout({storage: communityLayoutStorage,})const hydratedClient = useHydratedClient()+ const persistedSidebarPercentage = hydratedClient+ ? defaultLayout?.sidebar+ : undefinedconst sidebarPanelRef = useRef<HTMLDivElement>(null)+ const sidebarPanelHandleRef = useRef<PanelImperativeHandle | null>(null)const userBarOverlayRef = useRef<HTMLDivElement>(null)- const syncDesktopUserBarWidth = useCallback((size: PanelSize) => {- const measuredSidebarWidth = sidebarPanelRef.current?.getBoundingClientRect().width- const sidebarWidth = measuredSidebarWidth && measuredSidebarWidth > 0- ? measuredSidebarWidth- : size.inPixels+ const committedBreakpointRef = useRef<Breakpoint>(breakpoint)+ const renderedBreakpointRef = useRef<Breakpoint>(breakpoint)+ const desktopSidebarWidthRef = useRef<number | undefined>(undefined)+ const pendingDesktopRestoreRef = useRef<PendingDesktopRestore | null>(null)++ useInsertionEffect(() => {+ renderedBreakpointRef.current = breakpoint+ if (+ committedBreakpointRef.current === "mobile"+ && breakpoint === "desktop"+ && pendingDesktopRestoreRef.current === null+ ) {+ pendingDesktopRestoreRef.current = {+ target: desktopSidebarRestoreTarget(+ desktopSidebarWidthRef.current,+ persistedSidebarPercentage,+ ),+ resizeRequested: false,+ }+ }+ }, [breakpoint, persistedSidebarPercentage])++ const setDesktopUserBarWidth = useCallback((sidebarWidth: number) => {userBarOverlayRef.current?.style.setProperty("--community-desktop-user-bar-width",`${desktopUserBarOverlayWidth(sidebarWidth)}px`,)}, [])+ const syncDesktopUserBarWidth = useCallback((size: PanelSize) => {+ if (+ renderedBreakpointRef.current !== "desktop"+ || pendingDesktopRestoreRef.current !== null+ ) return+ const measuredSidebarWidth = sidebarPanelRef.current?.getBoundingClientRect().width+ const sidebarWidth = measuredSidebarWidth && measuredSidebarWidth > 0+ ? measuredSidebarWidth+ : size.inPixels+ desktopSidebarWidthRef.current = sidebarWidth+ setDesktopUserBarWidth(sidebarWidth)+ }, [setDesktopUserBarWidth])++ useLayoutEffect(() => {+ committedBreakpointRef.current = breakpoint+ const pendingRestore = pendingDesktopRestoreRef.current+ if (+ breakpoint !== "desktop"+ || pendingRestore === null+ || pendingRestore.resizeRequested+ ) return++ const panelHandle = sidebarPanelHandleRef.current+ if (!panelHandle) return++ pendingRestore.resizeRequested = true+ panelHandle.resize(pendingRestore.target)+ queueMicrotask(() => {+ if (+ pendingDesktopRestoreRef.current !== pendingRestore+ || renderedBreakpointRef.current !== "desktop"+ ) return+ const imperativeWidth = panelHandle.getSize().inPixels+ const measuredWidth = sidebarPanelRef.current?.getBoundingClientRect().width+ const appliedWidth = imperativeWidth > 0+ ? imperativeWidth+ : measuredWidth && measuredWidth > 0+ ? measuredWidth+ : undefined+ if (appliedWidth === undefined) return+ desktopSidebarWidthRef.current = appliedWidth+ setDesktopUserBarWidth(appliedWidth)+ pendingDesktopRestoreRef.current = null+ })+ }, [breakpoint, setDesktopUserBarWidth])const isDesktop = breakpoint === "desktop"const isMobileList = breakpoint === "mobile" && surface === "list"@@ -98,13 +177,9 @@ export function CommunityShellLayout({const mainMobileHidden = isMobileList || (isInitial && surface === "list")const showUserBar = isDesktop || isMobileList || isInitial || preserveHiddenMobileModules- const sidebarPercentage = hydratedClient- ? defaultLayout?.sidebar ?? COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE- : COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGEconst initialUserBarStyle = {- "--community-desktop-user-bar-width": desktopUserBarOverlayCssWidth(- sidebarPercentage,- hydratedClient,+ "--community-desktop-user-bar-width": desktopUserBarInitialOverlayCssWidth(+ persistedSidebarPercentage,),marginLeft: -COMMUNITY_RAIL_WIDTH,} as CSSProperties@@ -159,9 +234,11 @@ export function CommunityShellLayout({><ResizablePanelid="sidebar"- defaultSize={`${COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE}%`}+ panelRef={sidebarPanelHandleRef}+ defaultSize={COMMUNITY_SIDEBAR_DEFAULT_WIDTH}minSize={COMMUNITY_SIDEBAR_MIN_WIDTH}maxSize={COMMUNITY_SIDEBAR_MAX_WIDTH}+ groupResizeBehavior="preserve-pixel-size"onResize={syncDesktopUserBarWidth}hidden={isMobileDetail}data-mobile-active={sidebarMobileActive || undefined}@@ -182,7 +259,7 @@ export function CommunityShellLayout({<ResizableHandle className={cn("bg-transparent", !isDesktop && "hidden")} /><ResizablePanelid="main"- defaultSize="76%"+ groupResizeBehavior="preserve-relative-size"hidden={isMobileList}data-mobile-active={mainMobileActive || undefined}data-mobile-hidden={mainMobileHidden || undefined}diff --git a/src/web/src/components/community/shell/shell-frame-geometry.test.ts b/src/web/src/components/community/shell/shell-frame-geometry.test.tsindex 57060e5ac..082516f3a 100644--- a/src/web/src/components/community/shell/shell-frame-geometry.test.ts+++ b/src/web/src/components/community/shell/shell-frame-geometry.test.ts@@ -1,45 +1,67 @@import { describe, expect, it } from "vitest"import {+ COMMUNITY_COMPOSER_DESKTOP_INSET,COMMUNITY_RAIL_WIDTH,- COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE,+ COMMUNITY_SIDEBAR_DEFAULT_WIDTH,COMMUNITY_SIDEBAR_MAX_WIDTH,COMMUNITY_SIDEBAR_MIN_WIDTH,COMMUNITY_SEPARATOR_WIDTH,- COMMUNITY_SHELL_INSET,COMMUNITY_SURFACE_BORDER_WIDTH,COMMUNITY_USER_BAR_BASE_HEIGHT,+ COMMUNITY_USER_BAR_DESKTOP_INSET,COMMUNITY_USER_BAR_HEIGHT_CSS,+ desktopSidebarRestoreTarget,+ desktopUserBarInitialOverlayCssWidth,desktopUserBarOverlayCssWidth,desktopUserBarOverlayWidth,mobileInboxAvailableHeight,} from "./shell-frame-geometry"describe("desktop community shell geometry", () => {- it("mirrors the user bar and composer around the sidebar boundary", () => {- const sidebarWidth = 240+ it("keeps the user bar at 8px while the Composer remains at 12px", () => {+ const sidebarWidth = 300const mainStart = COMMUNITY_RAIL_WIDTH+ COMMUNITY_SURFACE_BORDER_WIDTH+ sidebarWidth+ COMMUNITY_SEPARATOR_WIDTHconst overlayLeft = COMMUNITY_RAIL_WIDTH - COMMUNITY_RAIL_WIDTHconst userBarRight =- overlayLeft + desktopUserBarOverlayWidth(sidebarWidth) - COMMUNITY_SHELL_INSET- const composerLeft = mainStart + COMMUNITY_SHELL_INSET+ overlayLeft+ + desktopUserBarOverlayWidth(sidebarWidth)+ - COMMUNITY_USER_BAR_DESKTOP_INSET+ const composerLeft = mainStart + COMMUNITY_COMPOSER_DESKTOP_INSET- expect(mainStart - userBarRight).toBe(COMMUNITY_SHELL_INSET)- expect(composerLeft - mainStart).toBe(COMMUNITY_SHELL_INSET)+ expect(mainStart - userBarRight).toBe(COMMUNITY_USER_BAR_DESKTOP_INSET)+ expect(composerLeft - mainStart).toBe(COMMUNITY_COMPOSER_DESKTOP_INSET)})- it("seeds the overlay from the same constrained percentage as the sidebar panel", () => {- expect(desktopUserBarOverlayCssWidth(COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE, true)).toBe(+ it("seeds the unsaved desktop geometry from fixed pixel contracts", () => {+ const overlayWidth = desktopUserBarOverlayWidth(COMMUNITY_SIDEBAR_DEFAULT_WIDTH)++ expect(COMMUNITY_SIDEBAR_DEFAULT_WIDTH).toBe(317)+ expect(COMMUNITY_SIDEBAR_MIN_WIDTH).toBe(300)+ expect(COMMUNITY_SIDEBAR_MAX_WIDTH).toBe(360)+ expect(overlayWidth).toBe(375)+ expect(overlayWidth - (2 * COMMUNITY_USER_BAR_DESKTOP_INSET)).toBe(359)+ expect(desktopUserBarInitialOverlayCssWidth()).toBe("375px")+ })++ it("keeps persisted percentages constrained to the panel bounds", () => {+ expect(desktopUserBarInitialOverlayCssWidth(24)).toBe(`calc(clamp(${COMMUNITY_SIDEBAR_MIN_WIDTH}px, calc(24% - 0.48px), ${COMMUNITY_SIDEBAR_MAX_WIDTH}px) + 58px)`,)- expect(desktopUserBarOverlayCssWidth(COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE, false)).toBe(+ expect(desktopUserBarOverlayCssWidth(24, false)).toBe("calc(calc(24% - 0.24px) + 57px)",)expect(desktopUserBarOverlayCssWidth(-20, false)).toContain("0%")expect(desktopUserBarOverlayCssWidth(120, false)).toContain("100%")})++ it("restores desktop entry from cached pixels, persisted percentage, then the fixed default", () => {+ expect(desktopSidebarRestoreTarget(300.25, 25)).toBe(300.25)+ expect(desktopSidebarRestoreTarget(undefined, 25)).toBe("25%")+ expect(desktopSidebarRestoreTarget()).toBe(317)+ })})describe("mobile Inbox shell geometry", () => {diff --git a/src/web/src/components/community/shell/shell-frame-geometry.ts b/src/web/src/components/community/shell/shell-frame-geometry.tsindex 634a7c430..5dfbea0cc 100644--- a/src/web/src/components/community/shell/shell-frame-geometry.ts+++ b/src/web/src/components/community/shell/shell-frame-geometry.ts@@ -1,9 +1,10 @@export const COMMUNITY_RAIL_WIDTH = 56export const COMMUNITY_SURFACE_BORDER_WIDTH = 1export const COMMUNITY_SEPARATOR_WIDTH = 1-export const COMMUNITY_SHELL_INSET = 12-export const COMMUNITY_SIDEBAR_DEFAULT_PERCENTAGE = 24-export const COMMUNITY_SIDEBAR_MIN_WIDTH = 160+export const COMMUNITY_USER_BAR_DESKTOP_INSET = 8+export const COMMUNITY_COMPOSER_DESKTOP_INSET = 12+export const COMMUNITY_SIDEBAR_DEFAULT_WIDTH = 317+export const COMMUNITY_SIDEBAR_MIN_WIDTH = 300export const COMMUNITY_SIDEBAR_MAX_WIDTH = 360export const COMMUNITY_USER_BAR_BASE_HEIGHT = 60export const COMMUNITY_USER_BAR_HEIGHT_CSS =@@ -49,3 +50,22 @@ export function desktopUserBarOverlayCssWidth(+ (constrainToPanelBounds ? COMMUNITY_SEPARATOR_WIDTH : 0)return `calc(${sidebarWidth} + ${fixedWidth}px)`}++export function desktopUserBarInitialOverlayCssWidth(+ persistedSidebarPercentage?: number,+) {+ return persistedSidebarPercentage === undefined+ ? `${desktopUserBarOverlayWidth(COMMUNITY_SIDEBAR_DEFAULT_WIDTH)}px`+ : desktopUserBarOverlayCssWidth(persistedSidebarPercentage, true)+}++export function desktopSidebarRestoreTarget(+ cachedSidebarWidth?: number,+ persistedSidebarPercentage?: number,+): number | string {+ if (cachedSidebarWidth !== undefined) return cachedSidebarWidth+ if (persistedSidebarPercentage !== undefined) {+ return `${persistedSidebarPercentage}%`+ }+ return COMMUNITY_SIDEBAR_DEFAULT_WIDTH+}diff --git a/src/web/src/components/community/shell/shell-frame-view.dom.test.ts b/src/web/src/components/community/shell/shell-frame-view.dom.test.tsindex 7ec3cf04d..4a780f417 100644--- a/src/web/src/components/community/shell/shell-frame-view.dom.test.ts+++ b/src/web/src/components/community/shell/shell-frame-view.dom.test.ts@@ -1,4 +1,4 @@-import { createElement, useState, type ReactNode } from "react"+import { createElement, useLayoutEffect, useState, type ReactNode } from "react"import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"import { act, render } from "@/test/react-dom-harness"import { ShellFrameView } from "./shell-frame-view"@@ -6,9 +6,16 @@ import type { CommunityCheckpointPlan, CommunitySurface } from "@/lib/community/const mocks = vi.hoisted(() => ({onLayoutChanged: vi.fn(),- defaultLayout: { current: { sidebar: 24, main: 76 } },+ defaultLayout: {+ current: undefined as { sidebar: number; main: number } | undefined,+ },+ defaultLayoutOptions: vi.fn(),groupProps: vi.fn(),panelProps: vi.fn(),+ sidebarPanelHandle: {+ getSize: vi.fn(),+ resize: vi.fn(),+ },railProps: vi.fn(),overlayProps: vi.fn(),pendingProps: vi.fn(),@@ -16,10 +23,13 @@ const mocks = vi.hoisted(() => ({}))vi.mock("react-resizable-panels", () => ({- useDefaultLayout: () => ({- defaultLayout: mocks.defaultLayout.current,- onLayoutChanged: mocks.onLayoutChanged,- }),+ useDefaultLayout: (options: Record<string, unknown>) => {+ mocks.defaultLayoutOptions(options)+ return {+ defaultLayout: mocks.defaultLayout.current,+ onLayoutChanged: mocks.onLayoutChanged,+ }+ },}))vi.mock("@/components/ui/resizable", () => ({ResizablePanelGroup: ({ children, ...props }: Record<string, unknown>) => {@@ -27,6 +37,13 @@ vi.mock("@/components/ui/resizable", () => ({return createElement("div", { "data-panel-group": "", className: props.className }, children as ReactNode)},ResizablePanel: ({ children, ...props }: Record<string, unknown>) => {+ useLayoutEffect(() => {+ if (props.id !== "sidebar") return+ const panelRef = props.panelRef as { current: unknown } | undefined+ if (!panelRef) return+ panelRef.current = mocks.sidebarPanelHandle+ return () => { panelRef.current = null }+ }, [props.id, props.panelRef])mocks.panelProps(props)return createElement("div", {"data-slot": "resizable-panel",@@ -148,11 +165,18 @@ describe("ShellFrameView", () => {vi.unstubAllGlobals()mocks.groupProps.mockClear()mocks.panelProps.mockClear()+ mocks.sidebarPanelHandle.getSize.mockReset()+ mocks.sidebarPanelHandle.getSize.mockReturnValue({+ asPercentage: 24,+ inPixels: 317,+ })+ mocks.sidebarPanelHandle.resize.mockReset()+ mocks.defaultLayoutOptions.mockClear()mocks.railProps.mockClear()mocks.overlayProps.mockClear()mocks.pendingProps.mockClear()mocks.channelSkeletonProps.mockClear()- mocks.defaultLayout.current = { sidebar: 24, main: 76 }+ mocks.defaultLayout.current = undefinedanimateDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "animate")vi.stubGlobal("matchMedia", vi.fn(() => ({ matches: false })))})@@ -250,11 +274,32 @@ describe("ShellFrameView", () => {expect(group.id).toBe("community-shell")expect(group.orientation).toBe("horizontal")expect(group.disabled).toBe(false)+ expect(group.defaultLayout).toBeUndefined()+ expect(group.onLayoutChanged).toBe(mocks.onLayoutChanged)+ const defaultLayoutOptions = latestProps(mocks.defaultLayoutOptions)+ expect(defaultLayoutOptions).toMatchObject({+ id: "community-shell",+ onlySaveAfterUserInteractions: true,+ })+ expect(defaultLayoutOptions.storage).toMatchObject({+ getItem: expect.any(Function),+ setItem: expect.any(Function),+ })const sidebarPanel = latestProps(mocks.panelProps, "sidebar")const mainPanel = latestProps(mocks.panelProps, "main")- expect(sidebarPanel).toMatchObject({ id: "sidebar", defaultSize: "24%", minSize: 160, maxSize: 360 })+ expect(sidebarPanel).toMatchObject({+ id: "sidebar",+ defaultSize: 317,+ minSize: 300,+ maxSize: 360,+ groupResizeBehavior: "preserve-pixel-size",+ })expect(sidebarPanel.className).toContain("pb-15")- expect(mainPanel).toMatchObject({ id: "main", defaultSize: "76%" })+ expect(mainPanel).toMatchObject({+ id: "main",+ groupResizeBehavior: "preserve-relative-size",+ })+ expect(mainPanel.defaultSize).toBeUndefined()expect("profileStatusSeeds" in latestProps(mocks.overlayProps)).toBe(false)expect(sidebar).toHaveBeenCalledWith()const userBarOverlay = renderer.container.querySelector<HTMLElement>(@@ -278,7 +323,7 @@ describe("ShellFrameView", () => {"calc(60px + var(--app-safe-area-bottom))",)expect(userBarOverlay.style.getPropertyValue("--community-desktop-user-bar-width")).toBe(- "calc(clamp(160px, calc(24% - 0.48px), 360px) + 58px)",+ "375px",)await act(async () => {const onResize = latestProps(mocks.panelProps, "sidebar").onResize as (@@ -326,7 +371,7 @@ describe("ShellFrameView", () => {expect(renderer.container.querySelector<HTMLElement>('[data-slot="community-user-bar-overlay"]',)!.style.getPropertyValue("--community-desktop-user-bar-width")).toBe(- "calc(clamp(160px, calc(18.75% - 0.375px), 360px) + 58px)",+ "calc(clamp(300px, calc(18.75% - 0.375px), 360px) + 58px)",)})@@ -597,12 +642,131 @@ describe("ShellFrameView", () => {))expect(latestProps(mocks.panelProps, "sidebar").onResize).toBe(onResize)+ await act(async () => {+ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "desktop" },+ createElement("main-content"),+ ))+ })+ expect(latestProps(mocks.panelProps, "sidebar").onResize).toBe(onResize)++ renderer.unmount()+ })++ it("restores fresh mobile-first desktop entry before accepting resize callbacks", async () => {+ const sidebar = vi.fn(() => createElement("sidebar-content"))+ const common = {+ ...extensionProps,+ checkpoint: committedCheckpoint("/c/me/dm_1", "detail"),+ sidebar,+ cancelPendingNavigation: vi.fn(),+ rail,+ profile,+ inbox,+ }+ mocks.sidebarPanelHandle.getSize+ .mockReturnValueOnce({ asPercentage: 25, inPixels: 316.75 })+ .mockReturnValueOnce({ asPercentage: 25, inPixels: 316.5 })+ mocks.sidebarPanelHandle.resize.mockImplementation(() => {+ const onResize = latestProps(mocks.panelProps, "sidebar").onResize as (+ size: { asPercentage: number; inPixels: number },+ ) => void+ onResize({ asPercentage: 24.5, inPixels: 300 })+ })++ const renderer = render(createElement(+ ShellFrameView,+ { ...common, breakpoint: "mobile" },+ createElement("main-content"),+ ))+ expect(mocks.sidebarPanelHandle.resize).not.toHaveBeenCalled()++ await act(async () => {+ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "desktop" },+ createElement("main-content"),+ ))+ })+ expect(mocks.sidebarPanelHandle.resize).toHaveBeenLastCalledWith(317)+ expect(renderer.container.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-overlay"]',+ )?.style.getPropertyValue("--community-desktop-user-bar-width")).toBe("374.75px")+renderer.rerender(createElement(ShellFrameView,- { ...common, breakpoint: "desktop" },+ { ...common, breakpoint: "mobile" },createElement("main-content"),))- expect(latestProps(mocks.panelProps, "sidebar").onResize).toBe(onResize)+ const mobileOnResize = latestProps(mocks.panelProps, "sidebar").onResize as (+ size: { asPercentage: number; inPixels: number },+ ) => void+ mobileOnResize({ asPercentage: 24.5, inPixels: 300 })+ await act(async () => {+ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "desktop" },+ createElement("main-content"),+ ))+ })+ expect(mocks.sidebarPanelHandle.resize).toHaveBeenLastCalledWith(316.75)+ expect(renderer.container.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-overlay"]',+ )?.style.getPropertyValue("--community-desktop-user-bar-width")).toBe("374.5px")+ expect(mocks.sidebarPanelHandle.resize).toHaveBeenCalledTimes(2)++ renderer.unmount()+ })++ it("restores a saved mobile-first percentage without writing storage", async () => {+ mocks.defaultLayout.current = { sidebar: 25, main: 75 }+ mocks.sidebarPanelHandle.getSize.mockReturnValue({+ asPercentage: 25,+ inPixels: 305.5,+ })+ const storageWrite = vi.spyOn(Storage.prototype, "setItem")+ const common = {+ ...extensionProps,+ checkpoint: committedCheckpoint("/c/me/dm_1", "detail"),+ sidebar: () => createElement("sidebar-content"),+ cancelPendingNavigation: vi.fn(),+ rail,+ profile,+ inbox,+ }+ const renderer = render(createElement(+ ShellFrameView,+ { ...common, breakpoint: "mobile" },+ createElement("main-content"),+ ))++ await act(async () => {+ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "desktop" },+ createElement("main-content"),+ ))+ })+ expect(mocks.sidebarPanelHandle.resize).toHaveBeenLastCalledWith("25%")+ expect(renderer.container.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-overlay"]',+ )?.style.getPropertyValue("--community-desktop-user-bar-width")).toBe("363.5px")++ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "mobile" },+ createElement("main-content"),+ ))+ await act(async () => {+ renderer.rerender(createElement(+ ShellFrameView,+ { ...common, breakpoint: "desktop" },+ createElement("main-content"),+ ))+ })+ expect(mocks.sidebarPanelHandle.resize).toHaveBeenLastCalledWith(305.5)+ expect(storageWrite).not.toHaveBeenCalled()renderer.unmount()})diff --git a/src/web/src/components/community/shell/user-bar.test.ts b/src/web/src/components/community/shell/user-bar.test.tsindex 6f289ab9c..ff9038e3e 100644--- a/src/web/src/components/community/shell/user-bar.test.ts+++ b/src/web/src/components/community/shell/user-bar.test.ts@@ -19,7 +19,7 @@ describe("UserBar", () => {expect(html).toContain("pl-[max(0.75rem,var(--app-safe-area-left))]")expect(html).toContain("pr-[max(0.75rem,var(--app-safe-area-right))]")expect(html).toContain("pb-[calc(0.75rem+var(--app-safe-area-bottom))]")- expect(html).toContain("sm:px-3 sm:pb-3")+ expect(html).toContain("sm:px-2 sm:pb-3")expect(html).toContain("flex h-12 items-center gap-3 border border-border/40 bg-muted px-4")expect(html).not.toContain("ring-1 ring-border/40")expect(html).toContain('class="flex min-w-0 flex-1 items-center gap-2"')@@ -55,7 +55,7 @@ describe("UserBar", () => {expect(html).toContain("pl-[max(0.75rem,var(--app-safe-area-left))]")expect(html).toContain("pr-[max(0.75rem,var(--app-safe-area-right))]")expect(html).toContain("pb-[calc(0.75rem+var(--app-safe-area-bottom))]")- expect(html).toContain("sm:px-3 sm:pb-3")+ expect(html).toContain("sm:px-2 sm:pb-3")expect(html).toContain("flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-4",)diff --git a/src/web/src/components/community/shell/user-bar.tsx b/src/web/src/components/community/shell/user-bar.tsxindex dcc8dd1a2..8400257e6 100644--- a/src/web/src/components/community/shell/user-bar.tsx+++ b/src/web/src/components/community/shell/user-bar.tsx@@ -89,7 +89,7 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,return (<divdata-testid={tid.userBar}- className="w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-3 sm:pb-3"+ className="w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-2 sm:pb-3">{breakpoint === "mobile"? <UserBarExtensionDrawer>{extensionContent}</UserBarExtensionDrawer>@@ -131,7 +131,7 @@ export function UserBarSkeleton() {<divdata-testid={tid.initialUserBarPending}aria-hidden- className="w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-3 sm:pb-3"+ className="w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-2 sm:pb-3"><div className="flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-4"><Skeleton className="size-7 shrink-0 rounded-full" />diff --git a/src/web/src/test/e2e-ui/08-mobile.spec.ts b/src/web/src/test/e2e-ui/08-mobile.spec.tsindex 7c6900a3a..63ac93ad1 100644--- a/src/web/src/test/e2e-ui/08-mobile.spec.ts+++ b/src/web/src/test/e2e-ui/08-mobile.spec.ts@@ -105,7 +105,7 @@ test.describe.serial("mobile layout", () => {expect(groupRect).not.toBeNull()expect(sidebarRect).not.toBeNull()expect(mainRect).not.toBeNull()- expect(sidebarRect!.width).toBeGreaterThanOrEqual(160)+ expect(sidebarRect!.width).toBeGreaterThanOrEqual(300)expect(mainRect!.width).toBeGreaterThan(0)expect(sidebarRect!.width).toBeLessThan(groupRect!.width)expect(mainRect!.width).toBeLessThan(groupRect!.width)diff --git a/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.ts b/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.tsindex 4d5e62fe6..c3a920707 100644--- a/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.ts+++ b/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.ts@@ -79,7 +79,7 @@ test.describe.serial("desktop thread split view", () => {await resizeThreadPanel(page, 520)const savedWidth = Math.round((await thread.boundingBox())?.width ?? 0)- expect(savedWidth).toBe(520)+ expect(Math.abs(savedWidth - 520)).toBeLessThanOrEqual(1)await page.goto(`/c/channels/${serverId}/${textChannelId}`)await expect(page.getByTestId(tid.threadSplitPanel)).toHaveCount(0)diff --git a/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts b/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.tsnew file mode 100644index 000000000..45ade9a48--- /dev/null+++ b/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts@@ -0,0 +1,937 @@+import type { Page, Request, Route, TestInfo } from "@playwright/test"+import { expect, test, userId } from "./_fixtures/community-fixture"+import { gotoAfterUserWsAuth, waitForElementMotion } from "./_fixtures/actions"+import {+ memberInfo,+ seedCancelFriendRequest,+ seedChannel,+ seedJoinServer,+ seedMark,+ seedMessage,+ seedPendingFriendRequest,+ seedServer,+} from "./_fixtures/seed"+import { tid } from "./_fixtures/testids"++const layoutStorageKey = "react-resizable-panels:community-shell"+const expectedDefaultSidebarWidth = 317+const expectedOuterWidth = 375+const expectedVisibleWidth = 359+const geometryEpsilon = 1++const shellPanel = (page: Page, id: "sidebar" | "main") => (+ page.locator(`[data-slot="resizable-panel"][data-testid="${id}"]`)+)++type LayoutSample = {+ sidebar: number+ overlay: number+ viewportWidth: number+ desktopVisible: boolean+}++type ShellGeometry = {+ sidebar: number+ main: number+ overlay: number+ wrapper: number+ base: number+ paddingLeft: number+ paddingRight: number+}++type DesktopResizeSample = ShellGeometry & {+ viewportWidth: number+ documentClientWidth: number+ documentScrollWidth: number+ documentHorizontalOverflow: number+}++type ComposerGeometry = {+ shellLeft: number+ shellRight: number+ baseLeft: number+ baseRight: number+ leftInset: number+ rightInset: number+ outerPaddingLeft: number+ outerPaddingRight: number+}++const outdatedMachine = {+ id: "machine_desktop_width",+ hostname: "studio-mac",+ displayName: "Studio Mac",+ platform: "darwin",+ arch: "arm64",+ osRelease: "26.0",+ daemonVersion: "0.1.7",+ lastSeenAt: null,+ status: "online",+ availableRuntimes: [],+ createdAt: "2026-08-30T00:00:00.000Z",+ updatedAt: "2026-08-30T00:00:00.000Z",+ quota: [],+}++async function installLayoutState(+ page: Page,+ layout: { sidebar: number; main: number } | null,+) {+ await page.addInitScript(({ key, savedLayout, sidebarTestId }) => {+ const initializedKey = `${key}:test-initialized`+ if (!sessionStorage.getItem(initializedKey)) {+ if (savedLayout) localStorage.setItem(key, JSON.stringify(savedLayout))+ else localStorage.removeItem(key)+ sessionStorage.setItem(initializedKey, "true")+ }++ const samples: LayoutSample[] = []+ const storageWrites: string[] = []+ Reflect.set(window, "__desktopWidthSamples", samples)+ Reflect.set(window, "__desktopLayoutWrites", storageWrites)+ const originalSetItem = Storage.prototype.setItem+ Storage.prototype.setItem = function setItem(storageKey, value) {+ if (storageKey === key) storageWrites.push(value)+ return originalSetItem.call(this, storageKey, value)+ }+ const capture = () => {+ const sidebar = document.querySelector<HTMLElement>(+ `[data-slot="resizable-panel"][data-testid="${sidebarTestId}"]`,+ )+ const overlay = document.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-overlay"]',+ )+ if (sidebar && overlay && samples.length < 240) {+ samples.push({+ sidebar: sidebar.getBoundingClientRect().width,+ overlay: overlay.getBoundingClientRect().width,+ viewportWidth: window.innerWidth,+ desktopVisible: getComputedStyle(sidebar).display !== "none"+ && getComputedStyle(overlay).display !== "none",+ })+ }+ requestAnimationFrame(capture)+ }+ requestAnimationFrame(capture)+ }, { key: layoutStorageKey, savedLayout: layout, sidebarTestId: "sidebar" })+}++async function holdSession(page: Page) {+ let release!: () => void+ const gate = new Promise<void>((resolve) => { release = resolve })+ let hits = 0+ const handler = async (route: Route) => {+ hits += 1+ await gate+ await route.continue()+ }+ await page.route("**/api/auth/get-session**", handler)+ return { hits: () => hits, release }+}++async function serveOutdatedMachine(page: Page) {+ await page.route("**/api/community/machines", async (route) => {+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({ machines: [outdatedMachine] }),+ })+ })+}++function captureWrites(page: Page) {+ const writes: string[] = []+ const listener = (request: Request) => {+ if (!["GET", "HEAD", "OPTIONS"].includes(request.method())) {+ writes.push(`${request.method()} ${new URL(request.url()).pathname}`)+ }+ }+ page.on("request", listener)+ return { writes, stop: () => page.off("request", listener) }+}++async function readShellGeometry(page: Page): Promise<ShellGeometry> {+ return page.locator('[data-slot="community-user-bar-overlay"]').evaluate((overlay, ids) => {+ const sidebar = document.querySelector<HTMLElement>(+ `[data-slot="resizable-panel"][data-testid="${ids.sidebar}"]`,+ )+ const main = document.querySelector<HTMLElement>(+ `[data-slot="resizable-panel"][data-testid="${ids.main}"]`,+ )+ const wrapper = document.querySelector<HTMLElement>(+ `[data-testid="${ids.userBar}"]`,+ )+ const base = wrapper?.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-base"]',+ )+ if (!sidebar || !main || !wrapper || !base) {+ throw new Error("missing desktop shell geometry")+ }+ const wrapperStyle = getComputedStyle(wrapper)+ return {+ sidebar: sidebar.getBoundingClientRect().width,+ main: main.getBoundingClientRect().width,+ overlay: overlay.getBoundingClientRect().width,+ wrapper: wrapper.getBoundingClientRect().width,+ base: base.getBoundingClientRect().width,+ paddingLeft: Number.parseFloat(wrapperStyle.paddingLeft),+ paddingRight: Number.parseFloat(wrapperStyle.paddingRight),+ }+ }, { sidebar: "sidebar", main: "main", userBar: tid.userBar })+}++async function expectDesktopGeometry(page: Page, sidebarWidth: number) {+ await expect(page.getByTestId(tid.userBar)).toBeVisible()+ await expect(shellPanel(page, "sidebar")).toBeVisible()+ await expect(page.locator('[data-slot="community-user-bar-overlay"]')).toBeVisible()+ await expect.poll(async () => {+ const geometry = await readShellGeometry(page)+ return {+ sidebar: Math.abs(geometry.sidebar - sidebarWidth) <= geometryEpsilon,+ overlay: Math.abs(geometry.overlay - (sidebarWidth + 58)) <= geometryEpsilon,+ wrapper: Math.abs(geometry.wrapper - (sidebarWidth + 58)) <= geometryEpsilon,+ base: Math.abs(geometry.base - (sidebarWidth + 42)) <= geometryEpsilon,+ paddingLeft: geometry.paddingLeft,+ paddingRight: geometry.paddingRight,+ }+ }).toEqual({+ sidebar: true,+ overlay: true,+ wrapper: true,+ base: true,+ paddingLeft: 8,+ paddingRight: 8,+ })+}++async function readDesktopResizeSample(+ page: Page,+ viewportWidth: number,+): Promise<DesktopResizeSample> {+ const [geometry, documentGeometry] = await Promise.all([+ readShellGeometry(page),+ page.evaluate(() => {+ const documentClientWidth = document.documentElement.clientWidth+ const documentScrollWidth = Math.max(+ document.documentElement.scrollWidth,+ document.body?.scrollWidth ?? 0,+ )+ return {+ documentClientWidth,+ documentScrollWidth,+ documentHorizontalOverflow: Math.max(+ 0,+ documentScrollWidth - documentClientWidth,+ ),+ }+ }),+ ])+ return { viewportWidth, ...geometry, ...documentGeometry }+}++function expectMainAbsorbsViewportDelta(samples: DesktopResizeSample[]) {+ expect(samples.map(({ viewportWidth }) => viewportWidth)).toEqual([1280, 1024, 640])+ const initial = samples[0]+ for (const sample of samples) {+ expect(sample.documentClientWidth).toBe(sample.viewportWidth)+ expect(sample.documentHorizontalOverflow).toBe(0)+ expect(Math.abs(+ (sample.main - initial.main)+ - (sample.viewportWidth - initial.viewportWidth),+ )).toBeLessThanOrEqual(geometryEpsilon)+ }+}++function expectNoTransientDesktopWidth(+ samples: LayoutSample[],+ sidebarWidth: number,+) {+ const visibleSamples = samples.filter(({ desktopVisible, sidebar, overlay }) => (+ desktopVisible && sidebar > 0 && overlay > 0+ ))+ expect(visibleSamples.length).toBeGreaterThan(0)+ const transientSamples = visibleSamples.filter((sample) => (+ Math.abs(sample.sidebar - sidebarWidth) > geometryEpsilon+ || Math.abs(sample.overlay - (sidebarWidth + 58)) > geometryEpsilon+ ))+ expect(transientSamples).toEqual([])+}++async function readComposerGeometry(page: Page): Promise<ComposerGeometry> {+ return page.getByTestId(tid.channelComposerShell).evaluate((shell) => {+ const base = shell.querySelector<HTMLElement>(+ '[data-slot="community-composer-base"]',+ )+ const outer = base?.parentElement+ if (!base || !outer) throw new Error("missing channel Composer geometry")+ const shellRect = shell.getBoundingClientRect()+ const baseRect = base.getBoundingClientRect()+ const outerStyle = getComputedStyle(outer)+ return {+ shellLeft: shellRect.left,+ shellRight: shellRect.right,+ baseLeft: baseRect.left,+ baseRight: baseRect.right,+ leftInset: baseRect.left - shellRect.left,+ rightInset: shellRect.right - baseRect.right,+ outerPaddingLeft: Number.parseFloat(outerStyle.paddingLeft),+ outerPaddingRight: Number.parseFloat(outerStyle.paddingRight),+ }+ })+}++async function expectExtensionGeometry(page: Page) {+ const extension = page.getByTestId(tid.userBarExtension)+ const base = page.getByTestId(tid.userBar).locator(+ '[data-slot="community-user-bar-base"]',+ )+ const [extensionBox, baseBox] = await Promise.all([+ extension.boundingBox(),+ base.boundingBox(),+ ])+ expect(extensionBox).not.toBeNull()+ expect(baseBox).not.toBeNull()+ expect(Math.abs(extensionBox!.width - expectedVisibleWidth)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ expect(Math.abs(baseBox!.width - expectedVisibleWidth)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ expect(Math.abs(extensionBox!.x - baseBox!.x)).toBeLessThanOrEqual(geometryEpsilon)+ expect(Math.abs(extensionBox!.x + extensionBox!.width - baseBox!.x - baseBox!.width))+ .toBeLessThanOrEqual(geometryEpsilon)+}++async function attachScreenshot(page: Page, testInfo: TestInfo, name: string) {+ await testInfo.attach(name, {+ body: await page.screenshot(),+ contentType: "image/png",+ })+}++async function attachJson(testInfo: TestInfo, name: string, value: unknown) {+ await testInfo.attach(name, {+ body: Buffer.from(`${JSON.stringify(value, null, 2)}\n`),+ contentType: "application/json",+ })+}++test.describe.serial("desktop default User Bar width", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ const stamp = Date.now()+ serverId = await seedServer("alice", `Desktop width ${stamp}`)+ channelId = await seedChannel("alice", serverId, `desktop-width-${stamp}`)+ })++ test("keeps unsaved, saved, and user-resized layouts pixel-stable", async ({+ asUser,+ }, testInfo) => {+ test.setTimeout(180_000)++ const fresh = await asUser("alice")+ await fresh.page.setViewportSize({ width: 1280, height: 900 })+ await installLayoutState(fresh.page, null)+ await gotoAfterUserWsAuth(+ fresh.page,+ `/c/channels/${serverId}/${channelId}`,+ )+ await expectDesktopGeometry(fresh.page, expectedDefaultSidebarWidth)+ const unsavedResizeSequence = [+ await readDesktopResizeSample(fresh.page, 1280),+ ]+ const composerGeometry = await readComposerGeometry(fresh.page)+ expect(Math.abs(composerGeometry.leftInset - 12)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ expect(Math.abs(composerGeometry.rightInset - 12)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ expect(composerGeometry.outerPaddingLeft).toBe(12)+ expect(composerGeometry.outerPaddingRight).toBe(12)+ await fresh.page.waitForTimeout(250)+ expect(await fresh.page.evaluate((key) => localStorage.getItem(key), layoutStorageKey))+ .toBeNull()++ const hydrationSamples = await fresh.page.evaluate(() => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ))+ const completeSamples = hydrationSamples.filter(({ sidebar, overlay }) => (+ sidebar > 0 && overlay > 0+ ))+ expect(completeSamples.length).toBeGreaterThan(0)+ for (const sample of completeSamples) {+ expect(Math.abs(sample.sidebar - expectedDefaultSidebarWidth)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ expect(Math.abs(sample.overlay - expectedOuterWidth)).toBeLessThanOrEqual(+ geometryEpsilon,+ )+ }++ for (const width of [1024, 640]) {+ await fresh.page.setViewportSize({ width, height: 768 })+ await expectDesktopGeometry(fresh.page, expectedDefaultSidebarWidth)+ unsavedResizeSequence.push(+ await readDesktopResizeSample(fresh.page, width),+ )+ }+ expectMainAbsorbsViewportDelta(unsavedResizeSequence)+ await fresh.page.setViewportSize({ width: 639, height: 768 })+ await expect(shellPanel(fresh.page, "sidebar")).toBeHidden()+ await expect(shellPanel(fresh.page, "main")).toBeVisible()+ await fresh.page.setViewportSize({ width: 640, height: 768 })+ await expectDesktopGeometry(fresh.page, expectedDefaultSidebarWidth)+ expect(await fresh.page.evaluate((key) => localStorage.getItem(key), layoutStorageKey))+ .toBeNull()+ await fresh.context.close()++ const mobileGeometry: Array<Record<string, unknown>> = []+ for (const viewport of [+ { width: 320, height: 568 },+ { width: 390, height: 844 },+ ]) {+ const mobile = await asUser("alice")+ await mobile.page.setViewportSize(viewport)+ await installLayoutState(mobile.page, null)+ await gotoAfterUserWsAuth(mobile.page, `/c/channels/${serverId}`)+ await expect(mobile.page.locator(+ '[data-community-mobile-surface="list"]',+ )).toBeVisible()+ const wrapper = mobile.page.getByTestId(tid.userBar)+ await expect(wrapper).toBeVisible()+ await mobile.page.evaluate(() => {+ document.documentElement.style.setProperty("--app-safe-area-left", "20px")+ document.documentElement.style.setProperty("--app-safe-area-right", "18px")+ document.documentElement.style.setProperty("--app-safe-area-bottom", "16px")+ })+ const geometry = await wrapper.evaluate((element) => {+ const style = getComputedStyle(element)+ const base = element.querySelector<HTMLElement>(+ '[data-slot="community-user-bar-base"]',+ )+ if (!base) throw new Error("missing mobile User Bar base")+ return {+ wrapperWidth: element.getBoundingClientRect().width,+ baseWidth: base.getBoundingClientRect().width,+ baseHeight: base.getBoundingClientRect().height,+ paddingLeft: Number.parseFloat(style.paddingLeft),+ paddingRight: Number.parseFloat(style.paddingRight),+ paddingBottom: Number.parseFloat(style.paddingBottom),+ }+ })+ expect(geometry).toEqual({+ wrapperWidth: viewport.width,+ baseWidth: viewport.width - 38,+ baseHeight: 48,+ paddingLeft: 20,+ paddingRight: 18,+ paddingBottom: 28,+ })+ expect(await mobile.page.evaluate(+ (key) => localStorage.getItem(key),+ layoutStorageKey,+ )).toBeNull()+ mobileGeometry.push({ viewport, ...geometry })+ await mobile.context.close()+ }++ const seededLayout = { sidebar: 25, main: 75 }+ const seededStorage = JSON.stringify(seededLayout)+ const saved = await asUser("alice")+ await saved.page.setViewportSize({ width: 1280, height: 900 })+ await installLayoutState(saved.page, seededLayout)+ await gotoAfterUserWsAuth(saved.page, `/c/channels/${serverId}/${channelId}`)+ await expect(shellPanel(saved.page, "sidebar")).toBeVisible()+ await expect.poll(async () => (+ Math.abs((await readShellGeometry(saved.page)).sidebar - expectedDefaultSidebarWidth)+ )).toBeGreaterThan(1)+ const restoredWidth = (await readShellGeometry(saved.page)).sidebar+ expect(restoredWidth).toBeGreaterThanOrEqual(300)+ expect(restoredWidth).toBeLessThanOrEqual(360)+ await expectDesktopGeometry(saved.page, restoredWidth)+ const savedResizeSequence = [+ await readDesktopResizeSample(saved.page, 1280),+ ]+ for (const width of [1024, 640]) {+ await saved.page.setViewportSize({ width, height: 768 })+ await expectDesktopGeometry(saved.page, restoredWidth)+ savedResizeSequence.push(+ await readDesktopResizeSample(saved.page, width),+ )+ }+ expectMainAbsorbsViewportDelta(savedResizeSequence)+ await saved.page.setViewportSize({ width: 639, height: 768 })+ await expect(shellPanel(saved.page, "sidebar")).toBeHidden()+ await saved.page.setViewportSize({ width: 640, height: 768 })+ await expectDesktopGeometry(saved.page, restoredWidth)+ expect(await saved.page.evaluate((key) => localStorage.getItem(key), layoutStorageKey))+ .toBe(seededStorage)++ const interaction = await asUser("alice")+ await interaction.page.setViewportSize({ width: 1280, height: 900 })+ await installLayoutState(interaction.page, null)+ await gotoAfterUserWsAuth(+ interaction.page,+ `/c/channels/${serverId}/${channelId}`,+ )+ await expectDesktopGeometry(interaction.page, expectedDefaultSidebarWidth)+ const handle = interaction.page.locator('[data-slot="resizable-handle"]')+ await handle.focus()+ await interaction.page.keyboard.press("ArrowLeft")+ await expect.poll(() => interaction.page.evaluate(+ (key) => localStorage.getItem(key),+ layoutStorageKey,+ )).not.toBeNull()+ const resizedWidth = (await readShellGeometry(interaction.page)).sidebar+ expect(Math.abs(resizedWidth - expectedDefaultSidebarWidth)).toBeGreaterThan(1)+ expect(resizedWidth).toBeGreaterThanOrEqual(300)+ expect(resizedWidth).toBeLessThanOrEqual(360)+ const storedLayout = JSON.parse(await interaction.page.evaluate(+ (key) => localStorage.getItem(key)!,+ layoutStorageKey,+ )) as Record<string, unknown>+ expect(storedLayout).toEqual({+ sidebar: expect.any(Number),+ main: expect.any(Number),+ })+ await interaction.page.reload({ waitUntil: "commit" })+ await expectDesktopGeometry(interaction.page, resizedWidth)+ await attachJson(testInfo, "desktop-width-layout-evidence", {+ hydrationSamples,+ mobileGeometry,+ unsaved: {+ storage: null,+ resizeSequence: unsavedResizeSequence,+ },+ composerGeometry,+ saved: {+ initialStorage: seededStorage,+ finalStorage: await saved.page.evaluate(+ (key) => localStorage.getItem(key),+ layoutStorageKey,+ ),+ restoredWidth,+ resizeSequence: savedResizeSequence,+ },+ resized: {+ storage: storedLayout,+ resizedWidth,+ reloadedWidth: (await readShellGeometry(interaction.page)).sidebar,+ },+ })+ })++ test("keeps a populated Inbox free of horizontal overflow at the 300px floor", async ({+ asUser,+ }, testInfo) => {+ test.setTimeout(120_000)+ const stamp = Date.now()+ const longServerName = `Inbox width with a deliberately long server title ${stamp}`+ const longChannelName = `inbox-width-with-a-deliberately-long-channel-name-${stamp}`+ const floorServerId = await seedServer("alice", longServerName)+ const floorChannelId = await seedChannel(+ "alice",+ floorServerId,+ longChannelName,+ )+ await seedJoinServer("alice", "bob", floorServerId)+ const bobMember = await memberInfo("alice", floorServerId, userId("bob"))+ const friendRequestId = await seedPendingFriendRequest(+ "carol",+ "bob",+ userId("bob"),+ )++ try {+ const markedMessageId = await seedMessage(+ "alice",+ floorChannelId,+ `Marked ${stamp} ${"very-long-row-content ".repeat(12)}`,+ )+ await seedMessage(+ "alice",+ floorChannelId,+ `@${bobMember.name}#${bobMember.discriminator} Mention ${stamp} ${"very-long-mention-content ".repeat(12)}`,+ )+ await seedMark("bob", floorChannelId, markedMessageId)++ const bob = await asUser("bob")+ await bob.page.setViewportSize({ width: 1280, height: 900 })+ await gotoAfterUserWsAuth(bob.page, "/c/me/friends")+ const sidebarPanel = shellPanel(bob.page, "sidebar")+ const handle = bob.page.locator('[data-slot="resizable-handle"]')+ await handle.focus()+ await bob.page.keyboard.press("Home")+ await expect.poll(async () => (+ (await sidebarPanel.boundingBox())?.width ?? 0+ )).toBeCloseTo(300, 0)+ await expectDesktopGeometry(bob.page, 300)++ await bob.page.getByTestId(tid.inboxTrigger).click()+ const extension = bob.page.getByTestId(tid.userBarExtension)+ await expect(extension).toHaveAttribute("data-extension", "inbox")+ await waitForElementMotion(extension)+ expect((await extension.boundingBox())!.width).toBeCloseTo(342, 0)++ const evidence: Array<Record<string, unknown>> = []+ for (const tab of ["Unreads", "Mentions", "Marked"] as const) {+ await bob.page.getByRole("tab", { name: tab }).click()+ const tabKey = tab.toLowerCase() as "unreads" | "mentions" | "marked"+ const activeBody = bob.page.getByTestId(tid.inboxTabScroll(tabKey))+ await expect(activeBody).toBeVisible()+ if (tab === "Unreads") {+ const requestRow = bob.page.getByTestId(tid.inboxFriendRequest(friendRequestId))+ await expect(requestRow).toBeVisible()+ await expect(bob.page.getByTestId(tid.inboxUnreadChannel(floorChannelId))).toBeVisible()+ await requestRow.hover()+ await expect(bob.page.getByTestId(tid.inboxFriendRequestAccept(friendRequestId))).toBeVisible()+ await expect(bob.page.getByTestId(tid.inboxFriendRequestReject(friendRequestId))).toBeVisible()+ } else {+ await expect(activeBody).toContainText(+ tab === "Mentions" ? `Mention ${stamp}` : `Marked ${stamp}`,+ )+ await activeBody.getByRole("button").first().hover()+ await expect(activeBody.getByRole("button", { name: "More" })).toBeVisible()+ }++ const sample = await extension.evaluate((element, ids) => {+ const width = (target: HTMLElement) => ({+ clientWidth: target.clientWidth,+ scrollWidth: target.scrollWidth,+ overflow: Math.max(0, target.scrollWidth - target.clientWidth),+ })+ const tabList = element.querySelector<HTMLElement>(+ `[data-testid="${ids.tabList}"]`,+ )+ const scrollBody = element.querySelector<HTMLElement>(+ `[data-testid="${ids.scrollBody}"]`,+ )+ if (!tabList || !scrollBody) throw new Error("missing active Inbox geometry")+ return {+ extension: width(element as HTMLElement),+ tabList: width(tabList),+ scrollBody: width(scrollBody),+ document: {+ clientWidth: document.documentElement.clientWidth,+ scrollWidth: document.documentElement.scrollWidth,+ overflow: Math.max(+ 0,+ document.documentElement.scrollWidth - document.documentElement.clientWidth,+ ),+ },+ }+ }, {+ tabList: tid.inboxTabList,+ scrollBody: tid.inboxTabScroll(tabKey),+ })+ expect(sample.extension.overflow).toBe(0)+ expect(sample.tabList.overflow).toBe(0)+ expect(sample.scrollBody.overflow).toBe(0)+ expect(sample.document.overflow).toBe(0)+ evidence.push({ tab, ...sample })+ await attachScreenshot(+ bob.page,+ testInfo,+ `inbox-300-${tabKey}-no-horizontal-overflow`,+ )+ }+ await attachJson(testInfo, "inbox-300-no-horizontal-overflow", evidence)+ } finally {+ await seedCancelFriendRequest("carol", friendRequestId)+ }+ })++ test("restores fresh and saved mobile-first desktop entries before paint", async ({+ asUser,+ }, testInfo) => {+ test.setTimeout(240_000)++ const runFreshSequence = async (widths: number[]) => {+ const session = await asUser("alice")+ const page = session.page+ await page.setViewportSize({ width: widths[0], height: 844 })+ await installLayoutState(page, null)+ await gotoAfterUserWsAuth(page, `/c/channels/${serverId}/${channelId}`)+ await expect(page.getByTestId(tid.channelComposerShell)).toBeVisible()+ const desktopPoints: Array<Record<string, unknown>> = []+ let previousWidth = widths[0]++ for (const width of widths.slice(1)) {+ const sampleCursor = await page.evaluate(() => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).length)+ await page.setViewportSize({ width, height: 844 })+ if (width < 640) {+ await expect(shellPanel(page, "sidebar")).toBeHidden()+ previousWidth = width+ continue+ }++ await expectDesktopGeometry(page, expectedDefaultSidebarWidth)+ const [shell, composer, samples, storage, storageWrites] = await Promise.all([+ readDesktopResizeSample(page, width),+ readComposerGeometry(page),+ page.evaluate((cursor) => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).slice(cursor), sampleCursor),+ page.evaluate((key) => localStorage.getItem(key), layoutStorageKey),+ page.evaluate(() => (+ Reflect.get(window, "__desktopLayoutWrites") as string[]+ )),+ ])+ if (previousWidth < 640) {+ expectNoTransientDesktopWidth(samples, expectedDefaultSidebarWidth)+ }+ expect(shell.documentHorizontalOverflow).toBe(0)+ expect(storage).toBeNull()+ expect(storageWrites).toEqual([])+ desktopPoints.push({+ shell,+ composer,+ composerCenter: (composer.shellLeft + composer.shellRight) / 2,+ samples,+ storage,+ storageWrites,+ })+ previousWidth = width+ }++ await session.context.close()+ return { widths, desktopPoints }+ }++ const longFresh = await runFreshSequence([320, 390, 639, 640, 1280])+ const shortFresh = await runFreshSequence([390, 639, 1280])+ const longFresh1280 = longFresh.desktopPoints.find(({ shell }) => (+ (shell as DesktopResizeSample).viewportWidth === 1280+ ))!+ const shortFresh1280 = shortFresh.desktopPoints.find(({ shell }) => (+ (shell as DesktopResizeSample).viewportWidth === 1280+ ))!+ expect(shortFresh1280.composerCenter).toBe(longFresh1280.composerCenter)++ const seededLayout = { sidebar: 25, main: 75 }+ const seededStorage = JSON.stringify(seededLayout)+ const saved = await asUser("alice")+ await saved.page.setViewportSize({ width: 390, height: 844 })+ await installLayoutState(saved.page, seededLayout)+ await gotoAfterUserWsAuth(saved.page, `/c/channels/${serverId}/${channelId}`)+ await expect(saved.page.getByTestId(tid.channelComposerShell)).toBeVisible()+ await saved.page.setViewportSize({ width: 639, height: 844 })+ await expect(shellPanel(saved.page, "sidebar")).toBeHidden()+ const firstSampleCursor = await saved.page.evaluate(() => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).length)+ await saved.page.setViewportSize({ width: 1280, height: 900 })+ await expect(shellPanel(saved.page, "sidebar")).toBeVisible()+ await expect.poll(async () => (+ Math.abs((await readShellGeometry(saved.page)).sidebar - expectedDefaultSidebarWidth)+ )).toBeGreaterThan(1)+ const firstAppliedWidth = (await readShellGeometry(saved.page)).sidebar+ await expectDesktopGeometry(saved.page, firstAppliedWidth)+ const firstDesktopSamples = await saved.page.evaluate((cursor) => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).slice(cursor), firstSampleCursor)+ expectNoTransientDesktopWidth(firstDesktopSamples, firstAppliedWidth)+ expect(await saved.page.evaluate(+ (key) => localStorage.getItem(key),+ layoutStorageKey,+ )).toBe(seededStorage)+ expect(await saved.page.evaluate(() => (+ Reflect.get(window, "__desktopLayoutWrites") as string[]+ ))).toEqual([])++ await saved.page.setViewportSize({ width: 639, height: 844 })+ await expect(shellPanel(saved.page, "sidebar")).toBeHidden()+ const secondSampleCursor = await saved.page.evaluate(() => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).length)+ await saved.page.setViewportSize({ width: 1280, height: 900 })+ await expectDesktopGeometry(saved.page, firstAppliedWidth)+ const secondAppliedWidth = (await readShellGeometry(saved.page)).sidebar+ expect(secondAppliedWidth).toBe(firstAppliedWidth)+ const secondDesktopSamples = await saved.page.evaluate((cursor) => (+ Reflect.get(window, "__desktopWidthSamples") as LayoutSample[]+ ).slice(cursor), secondSampleCursor)+ expectNoTransientDesktopWidth(secondDesktopSamples, firstAppliedWidth)+ const finalStorage = await saved.page.evaluate(+ (key) => localStorage.getItem(key),+ layoutStorageKey,+ )+ const savedStorageWrites = await saved.page.evaluate(() => (+ Reflect.get(window, "__desktopLayoutWrites") as string[]+ ))+ expect(finalStorage).toBe(seededStorage)+ expect(savedStorageWrites).toEqual([])++ await attachJson(testInfo, "mobile-first-desktop-entry-evidence", {+ fresh: { long: longFresh, short: shortFresh },+ saved: {+ seededStorage,+ firstAppliedWidth,+ firstDesktopSamples,+ secondAppliedWidth,+ secondDesktopSamples,+ finalStorage,+ storageWrites: savedStorageWrites,+ },+ })+ await saved.context.close()+ })++ test("captures closed, Inbox, Profile, update, and cold Skeleton parity", async ({+ asUser,+ }, testInfo) => {+ test.setTimeout(240_000)+ const focusRecords: Array<Record<string, unknown>> = []++ for (const width of [1024, 1280] as const) {+ for (const theme of ["light", "dark"] as const) {+ const authenticated = await asUser("alice")+ await authenticated.page.setViewportSize({ width, height: width === 1024 ? 768 : 900 })+ await authenticated.page.emulateMedia({ colorScheme: theme })+ await installLayoutState(authenticated.page, null)+ await serveOutdatedMachine(authenticated.page)+ await gotoAfterUserWsAuth(authenticated.page, "/c/me/friends")+ const writes = captureWrites(authenticated.page)++ await expectDesktopGeometry(authenticated.page, expectedDefaultSidebarWidth)+ const extension = authenticated.page.getByTestId(tid.userBarExtension)+ await expect(extension).toHaveAttribute("data-extension", "update")+ await extension.focus()+ await expect(extension).toBeFocused()+ await waitForElementMotion(extension)+ await expectExtensionGeometry(authenticated.page)+ expect(await extension.evaluate((element) => (+ element.scrollWidth <= element.clientWidth+ ))).toBe(true)+ const updateNotice = authenticated.page.getByTestId(tid.daemonUpdateNotice)+ const updateAction = authenticated.page.getByTestId(tid.daemonUpdateAction)+ const [noticeBox, actionBox] = await Promise.all([+ updateNotice.boundingBox(),+ updateAction.boundingBox(),+ ])+ expect(noticeBox).not.toBeNull()+ expect(actionBox).not.toBeNull()+ expect(actionBox!.x).toBeGreaterThanOrEqual(noticeBox!.x)+ expect(actionBox!.x + actionBox!.width).toBeLessThanOrEqual(+ noticeBox!.x + noticeBox!.width,+ )+ await attachJson(+ testInfo,+ `user-bar-${width}-${theme}-machine-update-geometry`,+ {+ shell: await readShellGeometry(authenticated.page),+ notice: noticeBox,+ action: actionBox,+ extensionFocused: await extension.evaluate(+ (element) => element === document.activeElement,+ ),+ },+ )+ await attachScreenshot(+ authenticated.page,+ testInfo,+ `user-bar-${width}-${theme}-machine-update`,+ )++ await authenticated.page.keyboard.press("Escape")+ await expect(extension).toHaveCount(0)+ const base = authenticated.page.getByTestId(tid.userBar).locator(+ '[data-slot="community-user-bar-base"]',+ )+ await expect(base).toHaveCSS("height", "48px")+ expect(Math.abs((await base.boundingBox())!.width - expectedVisibleWidth))+ .toBeLessThanOrEqual(geometryEpsilon)+ await attachScreenshot(+ authenticated.page,+ testInfo,+ `user-bar-${width}-${theme}-closed`,+ )++ const inboxTrigger = authenticated.page.getByTestId(tid.inboxTrigger)+ await inboxTrigger.focus()+ await authenticated.page.keyboard.press("Enter")+ await expect(extension).toHaveAttribute("data-extension", "inbox")+ await expect(extension).toBeFocused()+ await waitForElementMotion(extension)+ await expectExtensionGeometry(authenticated.page)+ await attachScreenshot(+ authenticated.page,+ testInfo,+ `user-bar-${width}-${theme}-inbox`,+ )+ await authenticated.page.keyboard.press("Escape")+ await expect(inboxTrigger).toBeFocused()+ const inboxRestored = await inboxTrigger.evaluate(+ (element) => element === document.activeElement,+ )++ const profileTrigger = authenticated.page.getByTestId(tid.userBarName).locator("..")+ await profileTrigger.focus()+ await authenticated.page.keyboard.press("Enter")+ await expect(extension).toHaveAttribute("data-extension", "profile")+ await expect(extension).toBeFocused()+ await expect(authenticated.page.getByTestId(tid.profileCard)).toBeVisible()+ await waitForElementMotion(extension)+ await expectExtensionGeometry(authenticated.page)+ await attachScreenshot(+ authenticated.page,+ testInfo,+ `user-bar-${width}-${theme}-profile`,+ )+ await authenticated.page.keyboard.press("Escape")+ await expect(profileTrigger).toBeFocused()+ focusRecords.push({+ width,+ theme,+ inboxRestored,+ profileRestored: await profileTrigger.evaluate(+ (element) => element === document.activeElement,+ ),+ })+ expect(writes.writes).toEqual([])+ writes.stop()+ await authenticated.context.close()++ const pending = await asUser("alice")+ await pending.page.setViewportSize({ width, height: width === 1024 ? 768 : 900 })+ await pending.page.emulateMedia({ colorScheme: theme })+ await installLayoutState(pending.page, null)+ const session = await holdSession(pending.page)+ await pending.page.goto(`/c/channels/${serverId}`, { waitUntil: "commit" })+ await expect.poll(session.hits).toBeGreaterThan(0)+ await expect(pending.page.getByTestId(tid.initialFrame)).toBeVisible()+ await expect(pending.page.getByTestId(tid.initialUserBarPending)).toBeVisible()+ const pendingSidebar = shellPanel(pending.page, "sidebar")+ const pendingOverlay = pending.page.locator('[data-slot="community-user-bar-overlay"]')+ const pendingBase = pending.page.getByTestId(tid.initialUserBarPending).locator(+ ":scope > div",+ )+ await expect.poll(async () => Math.abs(+ ((await pendingSidebar.boundingBox())?.width ?? 0) - expectedDefaultSidebarWidth,+ )).toBeLessThanOrEqual(geometryEpsilon)+ await expect.poll(async () => Math.abs(+ ((await pendingOverlay.boundingBox())?.width ?? 0) - expectedOuterWidth,+ )).toBeLessThanOrEqual(geometryEpsilon)+ expect(Math.abs((await pendingBase.boundingBox())!.width - expectedVisibleWidth))+ .toBeLessThanOrEqual(geometryEpsilon)+ await expect(pendingBase).toHaveCSS("height", "48px")+ await attachScreenshot(+ pending.page,+ testInfo,+ `user-bar-${width}-${theme}-cold-skeleton`,+ )+ expect(await pending.page.evaluate((key) => localStorage.getItem(key), layoutStorageKey))+ .toBeNull()+ session.release()+ await pending.context.close()+ }+ }+ await attachJson(testInfo, "user-bar-focus-records", focusRecords)+ })+})diff --git a/src/web/src/test/e2e-ui/_fixtures/community-loading-geometry.ts b/src/web/src/test/e2e-ui/_fixtures/community-loading-geometry.tsindex 125a62159..a6bd56889 100644--- a/src/web/src/test/e2e-ui/_fixtures/community-loading-geometry.ts+++ b/src/web/src/test/e2e-ui/_fixtures/community-loading-geometry.ts@@ -10,6 +10,8 @@ import { expect, sessionCookie, userId } from "./community-fixture"import {COMMUNITY_RAIL_WIDTH,COMMUNITY_SEPARATOR_WIDTH,+ COMMUNITY_SIDEBAR_DEFAULT_WIDTH,+ COMMUNITY_SIDEBAR_MIN_WIDTH,COMMUNITY_SURFACE_BORDER_WIDTH,} from "@/components/community/shell/shell-frame-geometry"import {@@ -574,10 +576,9 @@ export async function runDesktopPersistedPendingGeometry(`${caseLabel}, frame ${index} separator width: ${JSON.stringify(sample)}`,).toBeLessThanOrEqual(1)}- const expectedSidebarWidth = sidebarWidth ?? Math.min(- 360,- Math.max(160, desktopPanelTrackWidth(viewportWidth) * 0.24),- )+ const expectedSidebarWidth = sidebarWidth === null+ ? COMMUNITY_SIDEBAR_DEFAULT_WIDTH+ : Math.max(COMMUNITY_SIDEBAR_MIN_WIDTH, sidebarWidth)expect(Math.abs(samples.at(-1)!.sidebarWidth - expectedSidebarWidth),`${caseLabel}, final sidebar width: ${JSON.stringify(samples.at(-1))}`,