From d2dc0ce707a3a622cb0589f582ed3df651d458de Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 8 Aug 2026 18:49:19 -0500 Subject: [PATCH] fix(desktop): hold the HUD band when the window loses focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking away to another app is the commonest way the HUD gets let go of, and it fires no focusout — the composer stays document.activeElement while the window is inactive. Chrome stops matching `:focus` on an unfocused window all the same, so the band lost its focus state with no hold running and snapped shut instead of stepping down to the glanceable stage. The sheet also goes heavier than the text in front of it. There is no blur to separate the band from what it lies over, so it is the only thing keeping half-opacity text off someone else's UI. --- apps/desktop/src/app/hud/hud-shell.tsx | 18 ++++++++++++++++-- apps/desktop/src/styles.css | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsx index 105dac7a1b..b16cab73db 100644 --- a/apps/desktop/src/app/hud/hud-shell.tsx +++ b/apps/desktop/src/app/hud/hud-shell.tsx @@ -1,5 +1,5 @@ import { useStore } from '@nanostores/react' -import { type CSSProperties, useEffect, useRef, useState } from 'react' +import { type CSSProperties, useCallback, useEffect, useRef, useState } from 'react' import { useNavigate } from 'react-router' import { Button } from '@/components/ui/button' @@ -144,7 +144,10 @@ function useRecentActivity(): [boolean, () => void] { } }, []) - return [recent, () => bumpRef.current()] + // Stable, so callers can hang listeners off it. + const holdBand = useCallback(() => bumpRef.current(), []) + + return [recent, holdBand] } /** @@ -183,6 +186,17 @@ export function HudShell() { const [recent, holdBand] = useRecentActivity() const held = useHudHeld() + // Clicking away to another APP is the most common way the HUD is let go of, + // and it fires no focusout: the composer stays document.activeElement while + // the window is inactive. Chrome stops matching `:focus` on an unfocused + // window all the same, so the band lost its focus state with no hold running + // and snapped shut instead of stepping down to the glanceable stage. + useEffect(() => { + window.addEventListener('blur', holdBand) + + return () => window.removeEventListener('blur', holdBand) + }, [holdBand]) + // Main holds the session id on this window's behalf, so leaving HUD mode can // hand the app window back whatever conversation ended up here. useReportHudSession() diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css index 51ff68aa10..cd7fa87573 100644 --- a/apps/desktop/src/styles.css +++ b/apps/desktop/src/styles.css @@ -2360,7 +2360,11 @@ button[data-slot='aui_msg-reactions'] svg { z-index: 0; pointer-events: none; border-radius: 0.75rem 0.75rem 0 0; - background: color-mix(in srgb, var(--dt-card) 55%, transparent); + /* Heavier than the text in front of it, deliberately: with no blur to + separate the band from what it lies over, the sheet is the only thing + keeping half-opacity text off someone else's UI. Fade the words, keep the + paper. */ + background: color-mix(in srgb, var(--dt-card) 80%, transparent); /* Slides down behind the bar as it fades. A TRANSFORM, not height: it is composited, so it stays smooth where animating height re-lays-out the panel every frame and looked coarse — and it leaves the box alone, which matters