feat(desktop): Esc closes every OverlayView-based overlay

Lift the keyboard handler into the shared OverlayView so Agents, Settings,
Command Center — and anything we build on top of it later — all dismiss on
Esc by default. Nested Radix dialogs stop propagation themselves, so a
modal opened inside an overlay (e.g. model picker inside Settings) still
closes the modal first, not the overlay underneath.

Drop the now-redundant Esc handlers in Settings (kept Cmd/Ctrl+P) and
Command Center.
This commit is contained in:
Brooklyn Nicholson
2026-05-13 17:38:28 -05:00
parent 98d39fc2c4
commit 6746404b0f
3 changed files with 20 additions and 25 deletions
+2 -9
View File
@@ -80,16 +80,9 @@ export function SettingsView({ gateway, onClose, onConfigSaved }: SettingsPagePr
}
}
// OverlayView handles Esc; this just adds Cmd/Ctrl+P → focus search.
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
e.preventDefault()
triggerHaptic('close')
onClose()
return
}
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'p') {
e.preventDefault()
searchInputRef.current?.focus()
@@ -100,7 +93,7 @@ export function SettingsView({ gateway, onClose, onConfigSaved }: SettingsPagePr
window.addEventListener('keydown', onKeyDown)
return () => window.removeEventListener('keydown', onKeyDown)
}, [onClose])
}, [])
return (
<OverlayView