diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatRoot.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatRoot.tsx index 7a8a55b84..dc9ece230 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatRoot.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatRoot.tsx @@ -5,6 +5,7 @@ import { useEffect, useMemo, useRef } from "react" import { Focusable } from "~/components/common/Focusable" import { HotkeyScope } from "~/constants" +import { useAIShortcut } from "../../hooks/useAIShortcut" import type { AIPanelRefs } from "../../store/AIChatContext" import { AIChatStoreContext, @@ -34,7 +35,7 @@ const AIChatRootInner: FC = ({ children, chatId: externalChatId const panelRef = useRef(null!) const inputRef = useRef(null!) const refsContext = useMemo(() => ({ panelRef, inputRef }), [panelRef, inputRef]) - + useAIShortcut() if (!currentChatId) { return (
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAIShortcut.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAIShortcut.ts new file mode 100644 index 000000000..ba410de1e --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAIShortcut.ts @@ -0,0 +1,29 @@ +import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js" +import { useEffect } from "react" +import { tinykeys } from "tinykeys" + +import { setAIPanelVisibility } from "~/atoms/settings/ai" +import { FocusablePresets } from "~/components/common/Focusable" + +import { useChatActions } from "../store/hooks" + +export const useAIShortcut = () => { + const isFocus = useGlobalFocusableScopeSelector(FocusablePresets.isAIChat) + + const chatActions = useChatActions() + useEffect(() => { + if (!isFocus) return + return tinykeys(document.documentElement, { + "$mod+n": (e) => { + e.preventDefault() + // New chat + chatActions.newChat() + }, + "$mod+w": (e) => { + e.preventDefault() + // close AI chat + setAIPanelVisibility(false) + }, + }) + }, [chatActions, isFocus]) +} diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/Items/all-item.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/Items/all-item.tsx index 4d21bb6a5..de308c1db 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/Items/all-item.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/Items/all-item.tsx @@ -442,8 +442,8 @@ export const AllItem: EntryListItemFC = ({ entryId, entryPreview, translation }) )}
-
-
+
+
-
- - {dayjs - .duration(dayjs(entry.publishedAt).diff(dayjs(), "minute"), "minute") - .humanize()} - {t("space")} - {t("words.ago")} - -
+ + {dayjs.duration(dayjs(entry.publishedAt).diff(dayjs(), "minute"), "minute").humanize()} + {t("space")} + {t("words.ago")} +