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