Skip to content

The agent that grows with you

fix(desktop): stop the HUD painting sheet over empty space

Brooklyn Nicholson4424a5a60fbd
diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsx
index 19266893b0c..25c247ec4a2 100644
--- a/apps/desktop/src/app/hud/hud-shell.tsx
+++ b/apps/desktop/src/app/hud/hud-shell.tsx
@@ -46,6 +46,15 @@ const HUD_COLLAPSE_MS = Math.round(HUD_FADE_MS * 0.66)
* so an empty transcript measures a true zero instead of a 12px strip. */
const HUD_SHEET_OVERHANG_PX = 12
+/** Ceiling on the transcript band, which still auto-sizes up from 0. It reads
+ * over another app, so it is a glance rather than a panel: whichever of these
+ * is smaller wins, so a tall HUD doesn't turn the band into a second window
+ * and a short one doesn't get swallowed by it. */
+const HUD_BAND_MAX_PX = 152
+const HUD_BAND_MAX_FRACTION = 0.42
+
+const hudBandMaxPx = () => Math.min(window.innerHeight * HUD_BAND_MAX_FRACTION, HUD_BAND_MAX_PX)
+
/** Composer on top, transcript always hanging below it — Spotlight's shape,
* rather than flipping to follow the screen edge the HUD is parked against. */
const HUD_THREAD_ALWAYS_BELOW = true
@@ -216,11 +225,7 @@ export function HudShell() {
}
}, [])
- // Whether the thread actually overflows its band. Gates the band's no-drag
- // carve-out (styles.css): a band with nothing to scroll stays part of the
- // window's drag region, so a short conversation never blocks moving the HUD.
- const [scrollable, setScrollable] = useState(false)
- // Whether the sheet reaches the top of the window. Gates the frost, which is
+ // Whether bar + band actually cover the window. Gates the frost, which is
// native vibrancy and therefore the WINDOW's content view — it fills the whole
// rectangle and nothing in the page can clip it to the sheet. Whenever the
// sheet is shorter than the window, the difference is frost over empty space:
@@ -255,33 +260,25 @@ export function HudShell() {
}
}
- setScrollable(Boolean(el && el.scrollHeight > el.clientHeight + 4))
-
- // How tall the band actually needs to be. The transcript is packed to the
- // bottom, so this is the distance from the topmost visible row down to the
- // bar — which is 0 on a fresh session, and the glass then collapses behind
- // the bar instead of painting an empty slab over the whole window.
- //
- // Written straight to the element rather than through state: it changes on
- // every stream flush, and the sheet resizing must not re-render the tree.
+ // How tall the band actually needs to be — the tight bbox of the message
+ // rows only. Measuring to the viewport edge counted the full-window scroll
+ // container (min-height: 100%) as transcript and painted a empty slab almost
+ // the size of the HUD.
const rows = el?.querySelectorAll<HTMLElement>('[data-slot="aui_thread-content"] > *:not([data-slot])')
- const box = el?.getBoundingClientRect()
-
- // Measured from the bar outward, so it flips with the layout: parked at
- // the bottom the transcript grows up from the bar, parked at the top it
- // hangs down from it.
- const span =
- !rows?.length || !box
- ? 0
- : HUD_SHEET_OVERHANG_PX +
- (root.dataset.hudEdge === 'top'
- ? rows[rows.length - 1].getBoundingClientRect().bottom - box.top
- : box.bottom - rows[0].getBoundingClientRect().top)
-
- root.style.setProperty('--hud-band-height', `${Math.max(0, Math.round(span))}px`)
- // The sheet is capped at the window (`min(100%, …)`), so reaching the
- // window's height is the same question as covering it.
- setFilled(span >= window.innerHeight)
+
+ // Zero-height rows are not a transcript. A fresh thread still renders
+ // scaffolding inside the content box (clearance, empty state), so
+ // counting rows alone paid the overhang for nothing and left a sliver of
+ // sheet hanging under the bar with no text in it.
+ const text = !rows?.length
+ ? 0
+ : Math.max(0, rows[rows.length - 1].getBoundingClientRect().bottom - rows[0].getBoundingClientRect().top)
+
+ const contentSpan = text < 1 ? 0 : text + HUD_SHEET_OVERHANG_PX
+
+ const visible = Math.min(hudBandMaxPx(), Math.max(0, Math.round(contentSpan)))
+
+ root.style.setProperty('--hud-band-height', `${visible}px`)
// …and the bar's real height, which is what the thread has to clear.
// --composer-measured-height would be the obvious source, but it is a
@@ -296,7 +293,7 @@ export function HudShell() {
root.style.setProperty('--hud-bar-height', `${Math.round(barHeight)}px`)
}
- void barHeight
+ setFilled(barHeight + visible >= window.innerHeight - 1)
}
// The viewport mounts async (lazy chat surface); poll briefly until it
@@ -310,9 +307,9 @@ export function HudShell() {
}
}, [])
- useHudThreadFocus(rootRef)
useHudGlass(rootRef, recent || held, filled)
useHudClickThrough(rootRef)
+ useHudThreadFocus(rootRef)
// Force the HOST layers transparent. index.html's pre-paint script writes an
// opaque themed background onto <html> as an INLINE style (the anti-white-
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css
index 74d6bfe1427..93f4eeb552d 100644
--- a/apps/desktop/src/styles.css
+++ b/apps/desktop/src/styles.css
@@ -2266,6 +2266,11 @@ button[data-slot='aui_msg-reactions'] svg {
/* The scrollback — the chat BAND, straight from the nous-viz2d chat (which is
the reference for this whole surface): a fixed-height smoked strip hugging
the input, tinted from the theme, with the text simply sitting in it.
+ /* The band is narrower than the bar, centred under it, so the bar's corner
+ controls sit clear of the sheet's edge instead of on top of it. */
+ --hud-band-inset: 0.5rem;
+ /* Clear space above the composer for the exit chip. */
+ --hud-chip-strip: 1.625rem;
- viz2d: `bg-black/20` at rest → `bg-black/60` on hover / focus-within /
pending. Same mechanism here, theme-aware: the tint is the theme's own
@@ -2310,7 +2315,9 @@ button[data-slot='aui_msg-reactions'] svg {
short transcript — the whole window on a fresh thread. Hit-testing honours
clip-path, so clipping to the sheet bounds the surface the same way #81920
bounded the frost. */
- clip-path: inset(calc(100% - min(100%, var(--hud-band-height, 0px))) 0 0 0);
+ clip-path: inset(
+ calc(100% - var(--hud-band-height, 0px)) var(--hud-band-inset) 0 var(--hud-band-inset)
+ );
background: transparent !important;
/* Three opacity states: gone at rest, half strength when a turn is recent or
you've just let go of the composer (there to glance at, not to demand
@@ -2349,9 +2356,9 @@ button[data-slot='aui_msg-reactions'] svg {
transcript. */
anchor-name: --hud-band;
position: absolute;
- right: 0;
+ right: var(--hud-band-inset);
bottom: 0;
- left: 0;
+ left: var(--hud-band-inset);
z-index: 0;
pointer-events: none;
border-radius: 0.75rem 0.75rem 0 0;
@@ -2366,7 +2373,7 @@ button[data-slot='aui_msg-reactions'] svg {
The height below still tracks the transcript; only the offset animates on
exit, and it finishes ahead of the fade so the panel has left while the last
of the text is still going. */
- height: min(100%, var(--hud-band-height, 0px));
+ height: var(--hud-band-height, 0px);
translate: 0 var(--hud-exit-shift, 2.5rem);
opacity: 0;
transition:
@@ -2397,7 +2404,7 @@ button[data-slot='aui_msg-reactions'] svg {
/* Flipped, the sheet hangs from the bar instead of standing on it. */
[data-hud-shell][data-hud-edge='top'] [data-hud-glass] {
- top: 0;
+ top: var(--hud-bar-height, var(--composer-fallback-height));
bottom: auto;
--hud-exit-shift: -2.5rem;
border-radius: 0 0 0.75rem 0.75rem;
@@ -2534,7 +2541,17 @@ button[data-slot='aui_msg-reactions'] svg {
[data-hud-shell][data-hud-edge='top'] [data-slot='composer-bounds'] {
border-radius: 0 0 0.75rem 0.75rem;
- clip-path: inset(0 0 calc(100% - min(100%, var(--hud-band-height, 0px))) 0);
+ /* Band hangs below the bar — not from the window's top edge. Bottom inset is
+ clamped so an oversized measure cannot invert the clip and paint the whole
+ HUD as one empty slab. */
+ clip-path: inset(
+ var(--hud-bar-height, var(--composer-fallback-height)) var(--hud-band-inset)
+ max(
+ 0px,
+ calc(100% - var(--hud-bar-height, var(--composer-fallback-height)) - var(--hud-band-height, 0px))
+ )
+ var(--hud-band-inset)
+ );
}
/* Flipped, the bar is at the TOP, so the clearance has to be too — the app's
@@ -2788,6 +2805,13 @@ button[data-slot='aui_msg-reactions'] svg {
a HUD is a small window and a 400px menu cannot fit in it. */
html:has([data-hud-shell]) [data-slot='dropdown-menu-content'] [class*='max-h-'],
html:has([data-hud-shell]) [data-slot='popover-content'] [class*='max-h-'] {
+/* The composer's drop target is a full-window dashed sheet sized for the app's
+ chat column. In the HUD it is a white slab hanging under the bar on a fresh
+ thread, and there is nowhere to drop anything into a bar anyway. */
+[data-hud-shell] [data-slot='chat-drop-overlay'] {
+ display: none !important;
+}
+
max-height: max(5rem, calc(100dvh - 9rem)) !important;
}