mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
fix(wui): enable meta+enter submission from all fields in session launcher
Resolves issue #443 where meta+enter keyboard shortcut only worked from the prompt textarea. Now works consistently from title, directory, and prompt fields by moving keyboard handling to the modal level. - Add global meta+enter handler at SessionLauncher modal level - Remove input-specific keyboard handler from CommandInput textarea - Update visual hints to show shortcut on Launch button - Clean up footer hints for consistency
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useRef, useEffect } from 'react'
|
||||
import { useRef, useEffect } from 'react'
|
||||
import { Button } from './ui/button'
|
||||
import { SearchInput } from './FuzzySearchInput'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select'
|
||||
@@ -52,17 +52,6 @@ export default function CommandInput({
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
||||
e.preventDefault()
|
||||
onSubmit()
|
||||
}
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
promptRef.current?.blur()
|
||||
}
|
||||
}
|
||||
|
||||
const getPlatformKey = () => {
|
||||
return navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'
|
||||
}
|
||||
@@ -109,15 +98,13 @@ export default function CommandInput({
|
||||
ref={promptRef}
|
||||
value={value}
|
||||
onChange={e => onChange(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder={placeholder}
|
||||
disabled={isLoading}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
<kbd className="px-1 py-0.5 bg-muted/50 rounded">{getPlatformKey()}+Enter</kbd> to launch
|
||||
session, <kbd className="ml-1 px-1 py-0.5 bg-muted/50 rounded">Enter</kbd> for new line
|
||||
<kbd className="px-1 py-0.5 bg-muted/50 rounded">Enter</kbd> for new line
|
||||
</p>
|
||||
|
||||
{isLoading && (
|
||||
@@ -159,7 +146,10 @@ export default function CommandInput({
|
||||
Launching...
|
||||
</>
|
||||
) : (
|
||||
'Launch Session'
|
||||
<>
|
||||
Launch Session
|
||||
<kbd className="ml-2 px-1 py-0.5 text-xs bg-muted/50 rounded">{getPlatformKey()}+⏎</kbd>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,21 @@ export function SessionLauncher({ isOpen, onClose }: SessionLauncherProps) {
|
||||
},
|
||||
)
|
||||
|
||||
useHotkeys(
|
||||
'meta+enter, ctrl+enter',
|
||||
e => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
handleSubmit()
|
||||
},
|
||||
{
|
||||
enabled: isOpen,
|
||||
enableOnFormTags: true, // Critical: allows the shortcut to work in form inputs
|
||||
scopes: SessionLauncherHotkeysScope,
|
||||
preventDefault: true,
|
||||
},
|
||||
)
|
||||
|
||||
// Only steal scope when actually open
|
||||
useStealHotkeyScope(SessionLauncherHotkeysScope, isOpen)
|
||||
|
||||
@@ -115,8 +130,7 @@ export function SessionLauncher({ isOpen, onClose }: SessionLauncherProps) {
|
||||
|
||||
<div className="flex items-center justify-end text-xs text-muted-foreground">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>↵ Launch</span>
|
||||
<span>⌘K Close</span>
|
||||
<span>ESC Close</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user