From 03a4eb555b0fc27eb28d2e8bc958d8e7f31848d3 Mon Sep 17 00:00:00 2001 From: Brendonovich <14191578+Brendonovich@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:09:19 +0000 Subject: [PATCH] fix(app): leave as much room past the traffic lights as before them --- packages/app/src/shell/sidebar-toggle.tsx | 26 ++++++++++++++++--- .../src/shell/traffic-lights-notch.test.ts | 16 ++++++------ .../app/src/shell/traffic-lights-notch.tsx | 14 ++-------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/packages/app/src/shell/sidebar-toggle.tsx b/packages/app/src/shell/sidebar-toggle.tsx index 231ce1e0f2c..2ad10c6dd46 100644 --- a/packages/app/src/shell/sidebar-toggle.tsx +++ b/packages/app/src/shell/sidebar-toggle.tsx @@ -41,7 +41,25 @@ export function macVerticalTrafficLights(zoom: number) { return { x, y, width: x + macTrafficLightsBaseWidth - 14 } } -const macTrafficLightsGap = 14 +/** + * The window background the content panel bends around to keep clear of the traffic lights, in CSS pixels from the + * window's top-left: the buttons, with as much room past them as they have from the window's start edge. Its corner + * is concentric with the zoom button. + */ +export function macTrafficLightsPocket(zoom: number) { + const lights = macVerticalTrafficLights(zoom) + const room = lights.x / zoom + const size = 14 / zoom + + return { + right: lights.width / zoom + room, + bottom: lights.y / zoom + size + room, + corner: size / 2 + room, + } +} + +// The floating toggle's gap from the pocket. +const macTrafficLightsPocketGap = 4 // The toggle's 28px plus a 4px gap before the header contents. const slotWidth = 32 @@ -151,11 +169,11 @@ function useCollapsedSlot() { return { visible: () => desktop() && !windows() && settings.appearance.tabLayout() !== "horizontal", open: settings.appearance.sidebarOpen, - // Lays the toggle out as if the traffic lights were the header's first control. + // Lays the toggle out just past the traffic lights' pocket. width: () => mac() - ? macVerticalTrafficLights(platform.webviewZoom?.() ?? 1).width / (platform.webviewZoom?.() ?? 1) + - macTrafficLightsGap - + ? macTrafficLightsPocket(platform.webviewZoom?.() ?? 1).right + + macTrafficLightsPocketGap - contentStart + slotWidth : slotWidth, diff --git a/packages/app/src/shell/traffic-lights-notch.test.ts b/packages/app/src/shell/traffic-lights-notch.test.ts index 0f278d020b6..e5d914b4bda 100644 --- a/packages/app/src/shell/traffic-lights-notch.test.ts +++ b/packages/app/src/shell/traffic-lights-notch.test.ts @@ -1,18 +1,18 @@ import { expect, it } from "bun:test" import { trafficLightsPocket } from "./traffic-lights-notch" -it("bends the closed sidebar's content panel around the traffic lights, its corner concentric with the zoom button", () => { - // The buttons span 20–80px across and 25–39px down at 1x. - expect(trafficLightsPocket(0, 1)).toEqual({ left: 8, right: 90, bottom: 49, top: 8, outer: 10, inner: 17 }) +it("bends the closed sidebar's content panel around the traffic lights, leaving as much room past them as before them", () => { + // The buttons span 20–80px across and 25–39px down at 1x, 20px from the window's start edge. + expect(trafficLightsPocket(0, 1)).toEqual({ left: 8, right: 100, bottom: 59, top: 8, outer: 10, inner: 27 }) }) it("flattens the bend into the panel's own corner as the panel's edge reaches the pocket's", () => { const pocket = trafficLightsPocket(70, 1) - expect(pocket?.outer).toBeCloseTo(10 * (12 / 27), 5) - expect(pocket?.inner).toBeCloseTo(17 * (12 / 27), 5) - expect(trafficLightsPocket(81.99, 1)?.outer).toBeCloseTo(0, 2) - expect(trafficLightsPocket(82, 1)).toBeUndefined() + expect(pocket?.outer).toBeCloseTo(10 * (22 / 37), 5) + expect(pocket?.inner).toBeCloseTo(27 * (22 / 37), 5) + expect(trafficLightsPocket(91.99, 1)?.outer).toBeCloseTo(0, 2) + expect(trafficLightsPocket(92, 1)).toBeUndefined() expect(trafficLightsPocket(240, 1)).toBeUndefined() }) @@ -20,7 +20,7 @@ it("stays concentric with the zoom button, which keeps its native size, under re const pocket = trafficLightsPocket(0, 2) // At 2x the buttons are 7px across on an 11.5px pitch, the first still centered 27px across and 32px down. - expect(pocket?.inner).toBe(13.5) + expect(pocket?.inner).toBe(27) expect(pocket && pocket.right - pocket.inner).toBe(27 + 2 * 11.5) expect(pocket && pocket.bottom - pocket.inner).toBe(32) }) diff --git a/packages/app/src/shell/traffic-lights-notch.tsx b/packages/app/src/shell/traffic-lights-notch.tsx index 90281344888..e11dc15adaf 100644 --- a/packages/app/src/shell/traffic-lights-notch.tsx +++ b/packages/app/src/shell/traffic-lights-notch.tsx @@ -1,31 +1,21 @@ -import { macVerticalTrafficLights } from "@/shell/sidebar-toggle" +import { macTrafficLightsPocket } from "@/shell/sidebar-toggle" // The content panels' corner radius and their offset from the window's top and start edges. const panelRadius = 10 const panelInset = 8 -// Room between the traffic lights and the pocket the panel bends around them. -const pocketPadding = 10 - -// The native buttons' size in points; they keep it at every renderer zoom. -const trafficLightSize = 14 - /** * The top-left corner of the content panel once it bends around the traffic lights, in CSS pixels from the window's * top-left. `content` is where the content area starts now. Undefined while the panel is clear of the buttons. */ export function trafficLightsPocket(content: number, zoom: number) { const left = content + panelInset - const lights = macVerticalTrafficLights(zoom) - const right = lights.width / zoom + pocketPadding - const bottom = (lights.y + trafficLightSize) / zoom + pocketPadding + const { right, bottom, corner } = macTrafficLightsPocket(zoom) const width = right - left if (width <= 0) return - // The pocket's corner is concentric with the zoom button. - const corner = trafficLightSize / 2 / zoom + pocketPadding // As the panel's edge reaches the pocket's, its two corners shrink together so the bend flattens into the panel's // own rounded corner. const scale = Math.min(1, width / (panelRadius + corner))