Skip to content

The agent that grows with you

fix(desktop): hold the HUD band when the window loses focus

Brooklyn Nicholsond2dc0ce707a3
diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsx
index 105dac7a1b5..b16cab73db2 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 51ff68aa109..cd7fa875732 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