The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
perf(desktop): keep relational style invalidation out of unrelated panes
brooklyn!fa148ce1b7de
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.tsx b/apps/desktop/src/app/chat/sidebar/session-row.tsxindex 803f1239636..7ef1a09d141 100644--- a/apps/desktop/src/app/chat/sidebar/session-row.tsx+++ b/apps/desktop/src/app/chat/sidebar/session-row.tsx@@ -110,8 +110,8 @@ function disarmMarquee(event: React.PointerEvent<HTMLElement>) {// and is never narrower than the button that has to cover it. A PR chip is the// exception while the pointer is on it: it's a link, and the kebab sits// absolute over this space, so it has to stop taking clicks too, not just fade.-const TAIL_HIDES = 'min-w-5 transition-opacity group-hover:opacity-0 group-has-[[data-pr-link]:hover]:opacity-100'-const KEBAB_YIELDS = 'group-has-[[data-pr-link]:hover]:pointer-events-none group-has-[[data-pr-link]:hover]:opacity-0'+const TAIL_HIDES = 'session-row-tail min-w-5 transition-opacity group-hover:opacity-0'+const KEBAB_YIELDS = 'session-row-kebab'function formatAge(seconds: number, r: Translations['sidebar']['row']): string {const { unit, value } = coarseElapsed(Date.now() - seconds * 1000)diff --git a/apps/desktop/src/app/hud/glass.test.tsx b/apps/desktop/src/app/hud/glass.test.tsxindex 49d529f9c49..0bfcd8d3c8c 100644--- a/apps/desktop/src/app/hud/glass.test.tsx+++ b/apps/desktop/src/app/hud/glass.test.tsx@@ -47,11 +47,14 @@ describe('useHudGlass', () => {const { container } = render(<Harness backing />)const input = container.querySelector('input')!+ const shell = container.querySelector('[data-hud-shell]')!act(() => input.focus())expect(frostState()).toBe(true)+ expect(shell.hasAttribute('data-hud-typing')).toBe(true)act(() => input.blur())expect(frostState()).toBe(false)+ expect(shell.hasAttribute('data-hud-typing')).toBe(false)})it('stays off while the band is not covering the window, however engaged', () => {@@ -72,5 +75,10 @@ describe('useHudGlass', () => {await nextFrame()expect(frostState()).toBe(false)+ expect(container.querySelector('[data-hud-shell]')?.hasAttribute('data-hud-drawer')).toBe(true)+ rerender(<Harness backing />)+ await nextFrame()+ expect(container.querySelector('[data-hud-shell]')?.hasAttribute('data-hud-drawer')).toBe(false)+ expect(frostState()).toBe(true)})})diff --git a/apps/desktop/src/app/hud/glass.ts b/apps/desktop/src/app/hud/glass.tsindex 7225c6cc45b..55f909efffe 100644--- a/apps/desktop/src/app/hud/glass.ts+++ b/apps/desktop/src/app/hud/glass.ts@@ -1,6 +1,6 @@import { type RefObject, useEffect } from 'react'-/** The caret is in the composer — see the `:has()` rules in styles.css. */+/** Match native focus, including window deactivation. */const TYPING_SELECTOR = '[data-slot="composer-rich-input"]:focus'/** An open completion list owns the surface; the band falls back behind it. */@@ -65,19 +65,22 @@ export function useHudGlass(rootRef: RefObject<HTMLElement | null>, backing: booconst root = rootRef.currentconst setFrost = window.hermesDesktop?.hud?.setFrost- if (!root || !setFrost) {+ if (!root) {return}let on: boolean | null = nullconst apply = () => {- const next =- backing && root.querySelector(DRAWER_SELECTOR) === null && root.querySelector(TYPING_SELECTOR) !== null+ const typing = root.querySelector(TYPING_SELECTOR) !== null+ const drawer = root.querySelector(DRAWER_SELECTOR) !== null+ root.toggleAttribute('data-hud-typing', typing)+ root.toggleAttribute('data-hud-drawer', drawer)+ const next = backing && !drawer && typingif (on !== next) {on = next- void setFrost(next)+ void setFrost?.(next)}}@@ -112,7 +115,9 @@ export function useHudGlass(rootRef: RefObject<HTMLElement | null>, backing: boowindow.addEventListener('focus', schedule)return () => {- void setFrost(false)+ void setFrost?.(false)+ root.removeAttribute('data-hud-typing')+ root.removeAttribute('data-hud-drawer')observer.disconnect()if (frame !== null) {diff --git a/apps/desktop/src/app/hud/hud-shell.tsx b/apps/desktop/src/app/hud/hud-shell.tsxindex 1cdbc89ae83..5ac276fadf4 100644--- a/apps/desktop/src/app/hud/hud-shell.tsx+++ b/apps/desktop/src/app/hud/hud-shell.tsx@@ -312,8 +312,12 @@ export function HudShell() {const style = document.createElement('style')style.textContent = 'html,body,#root{background:transparent !important;}'document.head.appendChild(style)+ document.documentElement.setAttribute('data-hud-window', '')- return () => style.remove()+ return () => {+ style.remove()+ document.documentElement.removeAttribute('data-hud-window')+ }}, [])return (diff --git a/apps/desktop/src/components/pane-shell/tree/tab-key-hints.test.tsx b/apps/desktop/src/components/pane-shell/tree/tab-key-hints.test.tsxindex 437189913d0..26f070290f7 100644--- a/apps/desktop/src/components/pane-shell/tree/tab-key-hints.test.tsx+++ b/apps/desktop/src/components/pane-shell/tree/tab-key-hints.test.tsx@@ -71,9 +71,9 @@ it('reveals only the shortcut target after a hold and clears on release, blur or})expect(container.querySelector('[data-tab-key-hint]')).toBeNull()act(() => vi.advanceTimersByTime(1))- expect(container.querySelector('[data-tab-key-hint]')?.parentElement?.textContent).toBe('right dot1')+ expect(container.querySelector('[data-tab-key-hint]')?.nextElementSibling?.textContent).toBe('right dot')act(() => $hoveredTreeGroup.set(null))- expect(container.querySelector('[data-tab-key-hint]')?.parentElement?.textContent).toBe('left dot1')+ expect(container.querySelector('[data-tab-key-hint]')?.nextElementSibling?.textContent).toBe('left dot')const originalBindings = $bindings.get()act(() => $bindings.set({ ...originalBindings, 'profile.switch.1': [] }))diff --git a/apps/desktop/src/components/pane-shell/tree/tab-key-hints.tsx b/apps/desktop/src/components/pane-shell/tree/tab-key-hints.tsxindex bb3fbe8242b..e8acc85b61b 100644--- a/apps/desktop/src/components/pane-shell/tree/tab-key-hints.tsx+++ b/apps/desktop/src/components/pane-shell/tree/tab-key-hints.tsx@@ -12,9 +12,9 @@ export function TabKeyHint({ children, groupId, slot }: { children: ReactNode; gconst held = useStore($heldTabModifier)return (- <span className="relative flex shrink-0 items-center [&:has([data-tab-key-hint])>span:first-child]:invisible">- <span className="flex items-center">{children}</span>+ <span className="relative flex shrink-0 items-center">{held && <HeldTabKeyHint groupId={groupId} slot={slot} />}+ <span className="tab-key-hint-icon flex items-center">{children}</span></span>)}diff --git a/apps/desktop/src/components/ui/sidebar.tsx b/apps/desktop/src/components/ui/sidebar.tsxindex 049b5b53d91..658293b5bfc 100644--- a/apps/desktop/src/components/ui/sidebar.tsx+++ b/apps/desktop/src/components/ui/sidebar.tsx@@ -440,7 +440,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {}const sidebarMenuButtonVariants = cva(- 'peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent focus-visible:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',+ 'peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent focus-visible:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',{variants: {variant: {diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex b35125faf64..98d1c138320 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -994,6 +994,25 @@}@layer utilities {+ /* Keep relational selectors on their owning row, not inside a universal+ group-has descendant match: that invalidates unrelated chat panes. */+ .row-hover:has([data-pr-link]:hover) .session-row-tail {+ opacity: 1;+ }++ .row-hover:has([data-pr-link]:hover) .session-row-kebab {+ pointer-events: none;+ opacity: 0;+ }++ [data-sidebar='menu-item']:has(> [data-sidebar='menu-action']) > [data-sidebar='menu-button'] {+ padding-right: calc(var(--spacing) * 8);+ }++ [data-tab-key-hint] + .tab-key-hint-icon {+ visibility: hidden;+ }+[class*='rounded-full'],[class*=':rounded-full'] {border-radius: calc(var(--radius-scalar) * 9999rem);@@ -2814,7 +2833,7 @@ button[data-slot='aui_msg-reactions'] svg {the tinted sheet is the thing that reads as a desktop window parked on theaction, and it is most of the HUD's rectangle. Streaming shows words on thegame; sitting down to read promotes the surface. */-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-hud-glass] {+[data-hud-shell][data-hud-typing] [data-hud-glass] {translate: none;opacity: 1;transition-duration: var(--hud-reveal);@@ -2866,7 +2885,7 @@ button[data-slot='aui_msg-reactions'] svg {/* Engaged, the field steps up the same way the docked thread's does — butnever below the resting tint, so a high lever cannot make focusing thecomposer paint MORE transparent than glancing at it. */-:root[data-hermes-glass-on] [data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-hud-glass] {+:root[data-hermes-glass-on] [data-hud-shell][data-hud-typing] [data-hud-glass] {background: rgb(12 14 18 / 0.72);}@@ -2876,7 +2895,7 @@ button[data-slot='aui_msg-reactions'] svg {to use it, and the transcript flew open every time it was moved. Hit-testingbelow stays on :focus-within — being permissive about what can be clicked isharmless, being permissive about what lights up is not. */-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-hud-glass] {+[data-hud-shell][data-hud-typing] [data-hud-glass] {background: rgb(12 14 18 / 0.82);}@@ -2910,7 +2929,7 @@ button[data-slot='aui_msg-reactions'] svg {so an interactive band IS a dead zone over the action). Sitting down in thecomposer is the deliberate act that makes the transcript a surface you canscroll and click links in. */-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-slot='composer-bounds'] {+[data-hud-shell][data-hud-typing] [data-slot='composer-bounds'] {pointer-events: auto;}@@ -3053,7 +3072,7 @@ button[data-slot='aui_msg-reactions'] svg {color: var(--hud-overlay-ink-user) !important;}-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-slot='composer-bounds'] {+[data-hud-shell][data-hud-typing] [data-slot='composer-bounds'] {opacity: 1;translate: none;transition-duration: var(--hud-reveal);@@ -3066,7 +3085,7 @@ button[data-slot='aui_msg-reactions'] svg {goes fully opaque and the band falls back behind it: dimmer, fractionallysmaller, slightly out of focus. Scaled from the bar's edge, so it reads asdepth rather than as the panel shrinking. */-[data-hud-shell]:has([data-slot='composer-completion-drawer']) :is([data-slot='composer-bounds'], [data-hud-glass]) {+[data-hud-shell][data-hud-drawer] :is([data-slot='composer-bounds'], [data-hud-glass]) {opacity: 0.25 !important;scale: 0.97;filter: blur(1.5px);@@ -3099,7 +3118,7 @@ button[data-slot='aui_msg-reactions'] svg {/* No bubble in the HUD, ever. The band's ink already distinguishes the twovoices (white agent / gold yours), and a light card behind gold text is theone thing in here that fights the overlay's own contrast. */-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) {+[data-hud-shell][data-hud-typing] {--hud-bubble-fill: transparent;--hud-bubble-stroke: transparent;}@@ -3408,7 +3427,7 @@ button[data-slot='aui_msg-reactions'] svg {shadow is sawn off by the window before any CSS can shape it, and paying forthe clearance moves the bar. Recolouring what is already drawn costs nospace, cannot be clipped, and leaves the working arc as the only ring. */-[data-hud-shell]:has([data-slot='composer-rich-input']:focus) [data-slot='composer-surface'] {+[data-hud-shell][data-hud-typing] [data-slot='composer-surface'] {border-color: var(--dt-primary) !important;}@@ -3561,16 +3580,16 @@ button[data-slot='aui_msg-reactions'] svg {(1) is ours to fix in CSS; inner scrollers yield to the window instead oftheir own floor. (2) is why the menus are compact here rather than roomy —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-'] {+html[data-hud-window] [data-slot='dropdown-menu-content'] [class*='max-h-'],+html[data-hud-window] [data-slot='popover-content'] [class*='max-h-'] {max-height: max(5rem, calc(100dvh - 9rem)) !important;}/* The menu panels themselves: never taller than the window minus the bar.Portalled out of the shell, they must still take the pointer — the HUDdefaults to none and a right-click menu that cannot be clicked is dead. */-html:has([data-hud-shell]) [data-slot='dropdown-menu-content'],-html:has([data-hud-shell]) [data-slot='popover-content'] {+html[data-hud-window] [data-slot='dropdown-menu-content'],+html[data-hud-window] [data-slot='popover-content'] {max-height: calc(100dvh - 4.5rem) !important;overflow-y: auto;pointer-events: auto;