From 0b1828364a210f58adca668452be287cf02e216a Mon Sep 17 00:00:00 2001 From: Mo Xu <13222516+LikeSundayLikeRain@users.noreply.github.com> Date: Thu, 6 Aug 2026 18:04:56 -0400 Subject: [PATCH] fix(panel): clamp panel window height to screen (#304) A large maxVisibleSessions made the borderless panel window thousands of points tall (99 -> 8970pt). On macOS 26 the WindowServer drops compositing for the huge idle backing store, so the approval/question card renders blank until a mouse event forces a redraw -- looked like the card going invisible ~2s after appearing and reappearing on hover, on Retina/HiDPI displays only. Clamp the window height to the screen's visible height; the content is top-anchored and the session list scrolls internally, so the window never needs to exceed the screen. --- Sources/CodeIsland/PanelWindowController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/CodeIsland/PanelWindowController.swift b/Sources/CodeIsland/PanelWindowController.swift index 34f0dde4..254d7fe1 100644 --- a/Sources/CodeIsland/PanelWindowController.swift +++ b/Sources/CodeIsland/PanelWindowController.swift @@ -126,7 +126,15 @@ class PanelWindowController: NSObject, NSWindowDelegate { private func panelSize(for screen: NSScreen) -> NSSize { let maxSessions = CGFloat(max(2, UserDefaults.standard.integer(forKey: SettingsKey.maxVisibleSessions))) - let maxH = max(300, maxSessions * 90 + 60) + let desiredH = max(300, maxSessions * 90 + 60) + // Clamp to the screen's usable height. A borderless, non-opaque panel with a + // very tall backing store (e.g. maxVisibleSessions=99 → 8970pt, ~18k px tall on + // a Retina display) has its compositing dropped by the macOS 26 WindowServer + // once the surface goes idle — the card renders blank until a mouse event forces + // a redraw, which looked like "invisible after ~2s, reappears on hover" (#304). + // The content is top-anchored and the session list scrolls internally, so the + // window never needs to be taller than the visible screen. + let maxH = min(desiredH, screen.visibleFrame.height) let screenW = screen.frame.width let width = min(620, screenW - 40) return NSSize(width: width, height: maxH)