Skip to content

The agent that grows with you

fix(desktop): move the Linux HUD with a native compositor drag

Brooklyn Nicholson11f3ebe2302b
diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsx
index 98830fc6726..8f8fec74dce 100644
--- a/apps/desktop/src/app/chat/composer/index.tsx
+++ b/apps/desktop/src/app/chat/composer/index.tsx
@@ -12,6 +12,7 @@ import { PR_COMMENT_URL_RE } from '@/lib/chat-runtime'
import { sanitizeComposerInput } from '@/lib/composer-input-sanitize'
import { DATA_IMAGE_URL_RE } from '@/lib/embedded-images'
import { triggerHaptic } from '@/lib/haptics'
+import { isLinuxPlatform } from '@/lib/platform'
import { cn } from '@/lib/utils'
import { interceptsTypedVoiceStop } from '@/lib/voice-stop-word'
import { sessionCompacting } from '@/store/compaction'
@@ -1006,7 +1007,11 @@ export function ChatBar({
'min-h-[1.625rem] min-h-(--composer-input-min-height) max-h-(--composer-input-max-height) cursor-text overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] bg-transparent pb-1 pr-1 pt-1 leading-normal text-foreground outline-none disabled:cursor-not-allowed',
'**:data-ref-text:cursor-default',
stacked && 'pl-3',
- stacked ? 'w-full' : 'min-w-(--composer-input-inline-min-width) flex-1'
+ stacked ? 'w-full' : 'min-w-(--composer-input-inline-min-width) flex-1',
+ // Inside the Linux HUD drag region: a drag region swallows the page's
+ // mouse input whole, so the input must opt back out or it becomes
+ // unclickable. Buttons are covered by the global no-drag rule.
+ hudMode && isLinuxPlatform() && '[-webkit-app-region:no-drag]'
)}
contentEditable={!inputDisabled}
data-placeholder={placeholder}
@@ -1184,7 +1189,12 @@ export function ChatBar({
className={cn(
'group/composer relative w-full overflow-visible rounded-2xl',
poppedOut && 'bg-transparent',
- dragging && 'cursor-grabbing select-none touch-none'
+ dragging && 'cursor-grabbing select-none touch-none',
+ // Linux HUD: the bar is a native compositor drag handle
+ // (xdg_toplevel.move / _NET_WM_MOVERESIZE). setBounds position
+ // is a no-op on Wayland, so this is the only way to move it
+ // there. pt-4 is the grab band once the input/buttons opt out.
+ hudMode && isLinuxPlatform() && 'hud-native-drag pt-4 [-webkit-app-region:drag]'
)}
data-drag-active={dragActive ? '' : undefined}
data-hud-grabbing={hudGrabbing ? '' : undefined}
diff --git a/apps/desktop/src/app/hud/click-through.ts b/apps/desktop/src/app/hud/click-through.ts
index 669f093fd79..d1d01c7dc3d 100644
--- a/apps/desktop/src/app/hud/click-through.ts
+++ b/apps/desktop/src/app/hud/click-through.ts
@@ -68,10 +68,16 @@ export function hudIgnoresMouse(
* decision, a different courier.
*
* It follows that nothing in HUD mode may declare `-webkit-app-region: drag`
- * at all: a draggable region swallows the page's mouse events, so the moves
- * never arrive and the window is stranded on whatever it last decided —
- * usually transparent, which is also why pressing the handle fell through to
- * the app behind. Dragging is `useHudComposerDrag` instead.
+ * on macOS/Windows: a draggable region swallows the page's mouse events, so
+ * the moves never arrive and the window is stranded on whatever it last
+ * decided — usually transparent, which is also why pressing the handle fell
+ * through to the app behind. Dragging there is `useHudComposerDrag` instead.
+ *
+ * Linux is the exception: the solidity decision is fed from MAIN's cursor
+ * poll (`startHudCursorFeed`), which a drag region cannot starve — so the
+ * HUD composer root declares `-webkit-app-region: drag` (input carved out
+ * as no-drag) and the compositor moves the window natively. That is also
+ * the only move that works on Wayland, where `setBounds` position is a no-op.
*/
export function useHudClickThrough(rootRef: RefObject<HTMLElement | null>): void {
useEffect(() => {
diff --git a/apps/desktop/src/app/hud/composer-drag.ts b/apps/desktop/src/app/hud/composer-drag.ts
index 20e1e5c0450..f549eeff8cb 100644
--- a/apps/desktop/src/app/hud/composer-drag.ts
+++ b/apps/desktop/src/app/hud/composer-drag.ts
@@ -23,11 +23,15 @@ interface PressState {
/**
* HUD-only: press and hold the composer, then drag to move the window.
*
- * The only way to move the HUD. An `-webkit-app-region: drag` handle is the
- * obvious alternative and cannot work here: the window manager takes a drag
- * region's mouse input whole, which starves `useHudClickThrough` of the moves
- * it decides solidity from, so the window is already transparent by the time
- * the press lands and it falls through to the app behind. See click-through.ts.
+ * The way to move the HUD on macOS/Windows. An `-webkit-app-region: drag`
+ * handle is the obvious alternative and cannot work THERE: the window manager
+ * takes a drag region's mouse input whole, which starves `useHudClickThrough`
+ * of the moves it decides solidity from, so the window is already transparent
+ * by the time the press lands and it falls through to the app behind. See
+ * click-through.ts. On Linux the composer bar itself is a native drag region
+ * instead (root drag + input no-drag), so this gesture is only the fallback
+ * for presses that land on the interactive surface — and a no-op for position
+ * on native Wayland, where the compositor owns placement.
*
* Deltas are read in SCREEN coordinates. Client coordinates are relative to the
* window we are moving, so a window that keeps up with the cursor reports the
diff --git a/apps/desktop/src/lib/platform.ts b/apps/desktop/src/lib/platform.ts
index 6bcb7358edd..11fbe3341dc 100644
--- a/apps/desktop/src/lib/platform.ts
+++ b/apps/desktop/src/lib/platform.ts
@@ -17,3 +17,6 @@ export const isMacPlatform = (): boolean =>
// default userAgent. Win32 / Windows NT are the real tokens.
export const isWindowsPlatform = (): boolean =>
typeof navigator !== 'undefined' && /win32|windows/i.test(navigator.platform || navigator.userAgent || '')
+
+export const isLinuxPlatform = (): boolean =>
+ typeof navigator !== 'undefined' && /linux/i.test(navigator.platform || navigator.userAgent || '')
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css
index 98e5a80d9bd..52fbb40a43b 100644
--- a/apps/desktop/src/styles.css
+++ b/apps/desktop/src/styles.css
@@ -3136,15 +3136,37 @@ button[data-slot='aui_msg-reactions'] svg {
--thread-viewport-height: 100%;
}
-/* NOTHING in HUD mode declares `-webkit-app-region: drag`. The window manager
+/* `-webkit-app-region: drag` in HUD mode is LINUX ONLY. The window manager
takes a draggable region's mouse input whole, so the page never sees the
- cursor arrive there — and `useHudClickThrough`, which decides whether the
- window is solid from exactly those moves, has already handed the window away
- by the time you press. Every version of the app-region handle was therefore
- both unusable (the press fell through to the app behind) and the reason the
- HUD stayed solid over dead space once you left it. The two mechanisms cannot
- share a window; click-through wins, and dragging is `useHudComposerDrag` —
- press and hold the bar, then move. */
+ cursor arrive there — on macOS/Windows that starves `useHudClickThrough`,
+ which decides solidity from exactly those moves, so the press falls through
+ to the app behind (every app-region attempt there was therefore unusable,
+ and left the HUD solid over dead space once you left it). On Linux the
+ click-through decision is fed by MAIN's cursor poll (`startHudCursorFeed`),
+ not by page events, so a drag region cannot starve it: the bar stays solid,
+ the compositor takes the press, and the window moves natively
+ (xdg_toplevel.move on Wayland, _NET_WM_MOVERESIZE on X11). The composer's
+ interactive surface opts back out with `-webkit-app-region: no-drag` (input
+ element + the global button rule); the rest of the bar is the handle.
+ macOS/Windows keep dragging on `useHudComposerDrag` — press and hold the
+ bar, then move. */
+
+/* Grip affordance for the Linux drag band: the composer's top padding (pt-4)
+ is the only surface the region owns once the input/buttons are carved out,
+ so make it look like a handle — a centered pill, like a mobile grip. */
+.hud-native-drag::before {
+ content: '';
+ position: absolute;
+ top: 6px;
+ left: 50%;
+ transform: translateX(-50%);
+ width: 40px;
+ height: 4px;
+ border-radius: 9999px;
+ background: color-mix(in srgb, var(--ui-text-tertiary) 55%, transparent);
+ pointer-events: none;
+}
+
[data-hud-shell] [data-slot='composer-dock'] {
/* The one surface that is always there, so the one that always takes the
mouse — everything else in the shell earns it by being on screen. */