The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): HUD sizing — empty band, stranded exit chip, early stacking
Brooklyn Nicholson6ada733f9de6
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.tsindex 7353dc102e6..8c09b2f45f8 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-metrics.ts@@ -8,7 +8,6 @@ import {COMPOSER_SURFACE_HEIGHT_VAR,setSurfaceVar} from '@/app/chat/surface-vars'-import { useMediaQuery } from '@/hooks/use-media-query'import { useResizeObserver } from '@/hooks/use-resize-observer'import { COMPOSER_COMPACT_PILL_PX, COMPOSER_SINGLE_LINE_MAX_PX, COMPOSER_STACK_BREAKPOINT_PX } from '../composer-utils'@@ -43,7 +42,6 @@ export function useComposerMetrics({const [tight, setTight] = useState(false)// Wider than `tight`: the pill goes icon-only before the row has to stack.const [compactPill, setCompactPill] = useState(false)- const narrow = useMediaQuery('(max-width: 30rem)')// Edge signals, not the live text: these only re-render when emptiness / the// presence of a non-trailing newline actually flips, so typing within a line@@ -191,7 +189,17 @@ export function useComposerMetrics({}}, [composerRef])- // Pill compacts on real width (tile/pane), OR when stacked for any reason- // (viewport-narrow / wrapped) so the controls row never over-runs.- return { compactPill: compactPill || narrow || tight, stacked: expanded || narrow || tight }+ // Both decisions come from the composer's OWN measured width, never the+ // viewport's. There used to be a `(max-width: 30rem)` media query in here as+ // well, and it quietly outranked everything: any window under 480px stacked+ // the row AND compacted the pill in the same instant, regardless of how much+ // room the composer actually had. That collapsed the whole progressive ladder+ // into one step for small windows — HUD mode is ~470px, so it never saw the+ // ladder at all — and it disagreed with the measured breakpoints (320 to+ // stack) by 160px. The ResizeObserver knows the real width; the viewport is+ // not a proxy for it.+ //+ // The pill still compacts whenever the row stacks, so the controls row can't+ // over-run once it has the width to itself.+ return { compactPill: compactPill || tight, stacked: expanded || tight }}diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsxindex 95a1ae7e81c..edd9613bd72 100644--- a/apps/desktop/src/app/hud/hud-shell.tsx+++ b/apps/desktop/src/app/hud/hud-shell.tsx@@ -174,9 +174,31 @@ export function HudShell() {// 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.const rows = el?.querySelectorAll<HTMLElement>('[data-slot="aui_thread-content"] > *:not([data-slot])')- const top = rows?.length ? rows[0].getBoundingClientRect().top : null- const height = top === null || !el ? 0 : Math.max(0, el.getBoundingClientRect().bottom - top)- root.style.setProperty('--hud-band-height', `${Math.round(height)}px`)+ 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+ : 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`)++ // …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+ // surface var that never lands here, so the clearance silently fell back+ // to the root estimate and reserved ~20px more than the bar occupies —+ // a visible hole under the last message.+ const bar = root.querySelector<HTMLElement>('[data-slot="composer-dock"]')++ if (bar) {+ ro.observe(bar)+ root.style.setProperty('--hud-bar-height', `${Math.round(bar.getBoundingClientRect().height)}px`)+ }}// The viewport mounts async (lazy chat surface); poll briefly until itdiff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex c110ff03d32..1daca630bcd 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -2392,6 +2392,10 @@ button[data-slot='aui_msg-reactions'] svg {getNativeWindowHandle() and buys a cross-dissolve between frosted and sharprather than a true blur-radius ramp. Its own change, not this one. */[data-hud-shell] [data-hud-glass] {+ /* The exit chip rides this box, not the band — the band is the whole window,+ so anchoring there left the chip stranded in empty space above a short+ transcript. */+ anchor-name: --hud-band;position: absolute;right: 0;bottom: 0;@@ -2399,8 +2403,8 @@ button[data-slot='aui_msg-reactions'] svg {/* Grows up from the bar to fit the transcript, capped at the window. An emptysession measures 0 and the sheet collapses behind the bar, rather thanpainting a full-height slab with nothing in it. The extra is breathing room- above the first row so the fade has somewhere to happen. */- height: min(100%, calc(var(--hud-band-height, 0px) + 2rem));+ above the first row so the fade has somewhere to land. */+ height: min(100%, calc(var(--hud-band-height, 0px) + 0.75rem));z-index: 0;pointer-events: none;border-radius: 0.75rem 0.75rem 0 0;@@ -2430,6 +2434,7 @@ button[data-slot='aui_msg-reactions'] svg {interpolates. Blown up and pinned to the bottom, the band only ever shows thegradient's solid end. Reveal-speed both ways, so letting go of the composerbrings the ramp straight back instead of waiting out the fade's hold. */+[data-hud-shell]:focus-within [data-hud-glass],[data-hud-shell]:focus-within [data-slot='aui_thread-viewport'] {-webkit-mask-size: 100% 600%;mask-size: 100% 600%;@@ -2441,6 +2446,8 @@ button[data-slot='aui_msg-reactions'] svg {}[data-hud-shell][data-hud-edge='top'] [data-hud-glass] {+ top: 0;+ bottom: auto;border-radius: 0 0 0.75rem 0.75rem;}@@ -2459,11 +2466,6 @@ button[data-slot='aui_msg-reactions'] svg {transition-delay: 0s;}-/* Typing: the band goes fully solid — viz2d's focus step, taken to its end. */-[data-hud-shell]:focus-within [data-slot='composer-bounds'] {- background: var(--dt-background) !important;-}-/* User messages ride the band like every other line. In the app each stickyuser row paints an OPAQUE chat-surface slab behind it (so a stuck bubble canslide over scrolled text) and the bubble is solid --dt-user-bubble — inside@@ -2574,7 +2576,7 @@ button[data-slot='aui_msg-reactions'] svg {}[data-hud-shell][data-hud-edge='top'] [data-slot='aui_thread-content'] {- padding-block-start: calc(var(--composer-measured-height) + 0.25rem) !important;+ padding-block-start: calc(var(--hud-bar-height, var(--composer-fallback-height)) + 0.25rem) !important;}[data-hud-shell][data-hud-edge='top'] [data-slot='aui_thread-viewport'] {@@ -2641,7 +2643,7 @@ button[data-slot='aui_msg-reactions'] svg {gap between the last message and the composer. */[data-hud-shell] [data-slot='aui_thread-content'] {padding-inline: 0.6rem !important;- padding-block: 0.8rem 0.25rem !important;+ padding-block: 0.35rem 0.25rem !important;/* A chat frame fills from the bottom. The docked thread hangs from the topbecause it is always taller than its content is short; the band is a fewlines tall, so a two-message conversation left a dead gap between the last@@ -2662,7 +2664,7 @@ button[data-slot='aui_msg-reactions'] svg {measured from the live dock, so it tracks the composer growing to two, three,ten rows with no hairline and no hole. */[data-hud-shell] [data-chat-surface] {- --thread-last-message-clearance: var(--composer-measured-height);+ --thread-last-message-clearance: var(--hud-bar-height, var(--composer-fallback-height));}/* Same for the dock's own bottom pad — this var also feeds@@ -2808,9 +2810,6 @@ button[data-slot='aui_msg-reactions'] svg {the corner with its own margin reads as intentional. anchor() to the band:calc()-based attempts drifted because the composer's measured vars areinline-scoped and stale outside [data-chat-surface]. */-[data-hud-shell] [data-slot='composer-bounds'] {- anchor-name: --hud-band;-}[data-hud-shell] [data-hud-exit] {position-anchor: --hud-band;@@ -2839,6 +2838,12 @@ button[data-slot='aui_msg-reactions'] svg {pointer-events: auto;}+/* Flipped, the sheet's top corner is behind the bar — drop the chip clear of+ it so it stays in the transcript rather than under the composer. */+[data-hud-shell][data-hud-edge='top'] [data-hud-exit] {+ top: calc(anchor(top) + var(--hud-bar-height, var(--composer-fallback-height)) + 0.5rem);+}+[data-hud-shell][data-hud-recent] [data-hud-exit],[data-hud-shell]:focus-within [data-hud-exit] {opacity: 0.75;