From 0e260b3c8c8fa89e775e48e9ac101f2909e4f1b2 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 8 Aug 2026 02:09:58 -0500 Subject: [PATCH] fix(desktop): grow the HUD band smoothly, and flip on the visible panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sheet is sized to the transcript, so it changed height on every reply with no transition — the panel twitched to each new size instead of growing into it. Animated on the reveal timing. The edge flip was reading the window, which stopped being the same thing as the HUD once the sheet started sizing itself: a tall window's top edge reaches the screen top while the visible bar is still well down the display, so it flipped far too early. It now measures the visible panel, against a threshold proportional to the display rather than an exact-flush rule — the HUD hugs its bar, so its visible top can never actually touch the screen edge and a zero-tolerance test would never fire at all. --- apps/desktop/src/app/hud/hud-shell.tsx | 46 ++++++++++++++++++-------- apps/desktop/src/styles.css | 9 +++-- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsx index edd9613bd7281..c8b9dc76e3243 100644 --- a/apps/desktop/src/app/hud/hud-shell.tsx +++ b/apps/desktop/src/app/hud/hud-shell.tsx @@ -24,6 +24,11 @@ const HUD_REVEAL_MS = 150 const HUD_FADE_DELAY_MS = 3_000 const HUD_FADE_MS = 1_200 +/** Breathing room the sheet keeps above the first row, so the fade has + * somewhere to land. Published to CSS, and used here to work out how much of + * the window the HUD actually occupies. */ +const HUD_SHEET_OVERHANG_PX = 12 + /** * True for a hold window after any conversation activity (a message landing, * a stream flushing, a turn starting or ending). The CSS uses it — alongside @@ -100,25 +105,36 @@ export function HudShell() { // EDGE-tight, not a midpoint rule: the first cut compared topGap('bottom') + // How much of the window the HUD actually occupies. The sheet is sized to the + // transcript, so a tall window can be mostly empty above it — the flip has to + // measure the visible panel, not a window edge that reached the screen top + // long before the bar looked anywhere near it. + const visibleHeightRef = useRef(0) useEffect(() => { - // ZERO tolerance by explicit request: top-mode only when the window is - // flush against the usable top (gap 0 — macOS won't let it overlap the - // menu bar, so flush IS availTop). Tiny FLIP_OFF so the 300ms poll can't - // flutter on sub-pixel jitter while parked. - const FLIP_ON = 0 - const FLIP_OFF = 4 + // ZERO tolerance by explicit request: top-mode only when the HUD is flush + // against the usable top (gap 0 — macOS won't let it overlap the menu bar, + // so flush IS availTop). Tiny FLIP_OFF so the 300ms poll can't flutter on + // sub-pixel jitter while parked. + // Proportional to the display, not an absolute pixel count. The HUD hugs + // its bar, so its visible top can never actually reach the screen edge — + // an exact-flush rule would simply never fire. "Parked at the top" is a + // band near the top instead, with hysteresis so dragging along the line + // can't flutter the layout. + const usableHeight = (window.screen as { availHeight?: number }).availHeight || window.screen.height || 1 + const FLIP_ON = usableHeight * 0.12 + const FLIP_OFF = usableHeight * 0.18 const measure = () => { // availTop ≈ menu bar / notch inset on macOS; screenY is in full-screen // coordinates, so "parked at the top" means screenY ≈ availTop, not 0. const availTop = (window.screen as { availTop?: number }).availTop ?? 0 - const topGap = window.screenY - availTop + const visibleTop = window.screenY + Math.max(0, window.innerHeight - visibleHeightRef.current) + const topGap = visibleTop - availTop setEdge(prev => (topGap <= FLIP_ON ? 'top' : topGap >= FLIP_OFF ? 'bottom' : prev)) } @@ -194,11 +210,14 @@ export function HudShell() { // to the root estimate and reserved ~20px more than the bar occupies — // a visible hole under the last message. const bar = root.querySelector('[data-slot="composer-dock"]') + const barHeight = bar?.getBoundingClientRect().height ?? 0 if (bar) { ro.observe(bar) - root.style.setProperty('--hud-bar-height', `${Math.round(bar.getBoundingClientRect().height)}px`) + root.style.setProperty('--hud-bar-height', `${Math.round(barHeight)}px`) } + + void barHeight } // The viewport mounts async (lazy chat surface); poll briefly until it @@ -241,7 +260,8 @@ export function HudShell() { { '--hud-fade-delay': `${HUD_FADE_DELAY_MS}ms`, '--hud-fade': `${HUD_FADE_MS}ms`, - '--hud-reveal': `${HUD_REVEAL_MS}ms` + '--hud-reveal': `${HUD_REVEAL_MS}ms`, + '--hud-sheet-overhang': `${HUD_SHEET_OVERHANG_PX}px` } as CSSProperties } > diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css index 89c9d196d68a4..418419fc4a7eb 100644 --- a/apps/desktop/src/styles.css +++ b/apps/desktop/src/styles.css @@ -2400,13 +2400,18 @@ button[data-slot='aui_msg-reactions'] svg { session measures 0 and the sheet collapses behind the bar, rather than painting a full-height slab with nothing in it. The extra is breathing room above the first row so the fade has somewhere to land. */ - height: min(100%, calc(var(--hud-band-height, 0px) + 0.75rem)); + height: min(100%, calc(var(--hud-band-height, 0px) + var(--hud-sheet-overhang, 0.75rem))); z-index: 0; pointer-events: none; border-radius: 0.75rem 0.75rem 0 0; background: color-mix(in srgb, var(--dt-background) 62%, transparent); opacity: 0; - transition: opacity var(--hud-fade) ease var(--hud-fade-delay); + /* Height is animated because it changes on every reply. Snapping to each new + size reads as the panel twitching; growing into it reads as the transcript + filling up. */ + transition: + opacity var(--hud-fade) ease var(--hud-fade-delay), + height var(--hud-reveal) ease; -webkit-mask-image: var(--hud-thread-mask); mask-image: var(--hud-thread-mask); -webkit-mask-position: bottom;