mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
Merge pull request #437 from samdickson22/sam/eng-1934-bypass-permissions-modal-should-submit-on-metaenter-key
feat: add meta+Enter keyboard shortcut to bypass permissions modal
This commit is contained in:
@@ -79,7 +79,8 @@ export function Layout() {
|
||||
const session = sessionResponse.session
|
||||
|
||||
// Always update the session in the sessions list
|
||||
useStore.getState().updateSessionOptimistic(session_id, session)
|
||||
// Use updateSession (not updateSessionOptimistic) since this is data FROM the server
|
||||
useStore.getState().updateSession(session_id, session)
|
||||
|
||||
// Update active session detail if this is the currently viewed session
|
||||
const activeSessionId = useStore.getState().activeSessionDetail?.session?.id
|
||||
|
||||
@@ -60,6 +60,26 @@ const DangerouslySkipPermissionsDialogContent: FC<{
|
||||
},
|
||||
)
|
||||
|
||||
// Add meta+enter to submit
|
||||
useHotkeys(
|
||||
'meta+enter, ctrl+enter',
|
||||
ev => {
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
|
||||
// Only submit if the button would be enabled
|
||||
if (!useTimeout || (timeoutMinutes !== '' && timeoutMinutes !== 0)) {
|
||||
handleConfirm()
|
||||
}
|
||||
},
|
||||
{
|
||||
enabled: isOpen,
|
||||
scopes: DangerouslySkipPermissionsHotkeysScope,
|
||||
preventDefault: true,
|
||||
enableOnFormTags: true,
|
||||
},
|
||||
)
|
||||
|
||||
// Reset to default when component mounts (dialog opens)
|
||||
React.useEffect(() => {
|
||||
setTimeoutMinutes(15)
|
||||
@@ -155,6 +175,11 @@ const DangerouslySkipPermissionsDialogContent: FC<{
|
||||
className="border-[var(--terminal-error)] text-[var(--terminal-error)] hover:bg-[var(--terminal-error)] hover:text-background disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Bypass Permissions
|
||||
{!useTimeout || (timeoutMinutes !== '' && timeoutMinutes !== 0) ? (
|
||||
<kbd className="ml-1 px-1 py-0.5 text-xs bg-muted/50 rounded">
|
||||
{navigator.platform.toLowerCase().includes('mac') ? '⌘' : 'Ctrl'}+⏎
|
||||
</kbd>
|
||||
) : null}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</>
|
||||
|
||||
@@ -577,7 +577,12 @@ function SessionDetail({ session, onClose }: SessionDetailProps) {
|
||||
return
|
||||
}
|
||||
|
||||
if (dangerouslySkipPermissions) {
|
||||
// Get the current value from the store directly to avoid stale closure
|
||||
const currentSessionFromStore = useStore.getState().sessions.find(s => s.id === session.id)
|
||||
const currentDangerouslySkipPermissions =
|
||||
currentSessionFromStore?.dangerouslySkipPermissions ?? false
|
||||
|
||||
if (currentDangerouslySkipPermissions) {
|
||||
// Disable dangerous skip permissions
|
||||
try {
|
||||
await updateSessionOptimistic(session.id, {
|
||||
@@ -597,7 +602,7 @@ function SessionDetail({ session, onClose }: SessionDetailProps) {
|
||||
preventDefault: true,
|
||||
scopes: SessionDetailHotkeysScope,
|
||||
},
|
||||
[session.id, dangerouslySkipPermissions],
|
||||
[session.id], // Remove dangerouslySkipPermissions from deps since we get it fresh each time
|
||||
)
|
||||
|
||||
// Handle dialog confirmation
|
||||
|
||||
Reference in New Issue
Block a user