fix(desktop): hold the HUD band when the window loses focus
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user