feat: enable hotkey collapse right panel (#3019)
This commit is contained in:
parent
cf8f401dab
commit
44536ec929
@ -8,7 +8,11 @@ import { MainViewState } from '@/constants/screens'
|
|||||||
|
|
||||||
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
||||||
|
|
||||||
import { mainViewStateAtom, showLeftPanelAtom } from '@/helpers/atoms/App.atom'
|
import {
|
||||||
|
mainViewStateAtom,
|
||||||
|
showLeftPanelAtom,
|
||||||
|
showRightPanelAtom,
|
||||||
|
} from '@/helpers/atoms/App.atom'
|
||||||
import { assistantsAtom } from '@/helpers/atoms/Assistant.atom'
|
import { assistantsAtom } from '@/helpers/atoms/Assistant.atom'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -17,6 +21,7 @@ type Props = {
|
|||||||
|
|
||||||
export default function KeyListener({ children }: Props) {
|
export default function KeyListener({ children }: Props) {
|
||||||
const setShowLeftPanel = useSetAtom(showLeftPanelAtom)
|
const setShowLeftPanel = useSetAtom(showLeftPanelAtom)
|
||||||
|
const setShowRightPanel = useSetAtom(showRightPanelAtom)
|
||||||
const setMainViewState = useSetAtom(mainViewStateAtom)
|
const setMainViewState = useSetAtom(mainViewStateAtom)
|
||||||
const { requestCreateNewThread } = useCreateNewThread()
|
const { requestCreateNewThread } = useCreateNewThread()
|
||||||
const assistants = useAtomValue(assistantsAtom)
|
const assistants = useAtomValue(assistantsAtom)
|
||||||
@ -25,6 +30,11 @@ export default function KeyListener({ children }: Props) {
|
|||||||
const onKeyDown = (e: KeyboardEvent) => {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
const prefixKey = isMac ? e.metaKey : e.ctrlKey
|
const prefixKey = isMac ? e.metaKey : e.ctrlKey
|
||||||
|
|
||||||
|
if (e.key === 'b' && prefixKey && e.shiftKey) {
|
||||||
|
setShowRightPanel((showRightideBar) => !showRightideBar)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (e.key === 'n' && prefixKey) {
|
if (e.key === 'n' && prefixKey) {
|
||||||
requestCreateNewThread(assistants[0])
|
requestCreateNewThread(assistants[0])
|
||||||
setMainViewState(MainViewState.Thread)
|
setMainViewState(MainViewState.Thread)
|
||||||
@ -43,7 +53,13 @@ export default function KeyListener({ children }: Props) {
|
|||||||
}
|
}
|
||||||
document.addEventListener('keydown', onKeyDown)
|
document.addEventListener('keydown', onKeyDown)
|
||||||
return () => document.removeEventListener('keydown', onKeyDown)
|
return () => document.removeEventListener('keydown', onKeyDown)
|
||||||
}, [assistants, requestCreateNewThread, setMainViewState, setShowLeftPanel])
|
}, [
|
||||||
|
assistants,
|
||||||
|
requestCreateNewThread,
|
||||||
|
setMainViewState,
|
||||||
|
setShowLeftPanel,
|
||||||
|
setShowRightPanel,
|
||||||
|
])
|
||||||
|
|
||||||
return <Fragment>{children}</Fragment>
|
return <Fragment>{children}</Fragment>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,11 @@ const availableHotkeys = [
|
|||||||
modifierKeys: [isMac ? '⌘' : 'Ctrl'],
|
modifierKeys: [isMac ? '⌘' : 'Ctrl'],
|
||||||
description: 'Toggle collapsible left panel',
|
description: 'Toggle collapsible left panel',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
combination: 'Shift B',
|
||||||
|
modifierKeys: [isMac ? '⌘' : 'Ctrl'],
|
||||||
|
description: 'Toggle collapsible right panel',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
combination: ',',
|
combination: ',',
|
||||||
modifierKeys: [isMac ? '⌘' : 'Ctrl'],
|
modifierKeys: [isMac ? '⌘' : 'Ctrl'],
|
||||||
@ -21,7 +26,7 @@ const availableHotkeys = [
|
|||||||
description: 'Send a message',
|
description: 'Send a message',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
combination: 'Shift + Enter',
|
combination: 'Shift Enter',
|
||||||
description: 'Insert new line in input box',
|
description: 'Insert new line in input box',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user