From 9519d1c643c2dd545e00a3e6a203e8a5464a711c Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 16 Oct 2025 20:43:04 +0800 Subject: [PATCH] fix(ai): only close ai panel when focused and floating style Signed-off-by: Innei --- .../src/modules/ai-chat/hooks/useAIShortcut.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 index ba410de1e..ba8cd9dac 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAIShortcut.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAIShortcut.ts @@ -2,7 +2,12 @@ import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focus import { useEffect } from "react" import { tinykeys } from "tinykeys" -import { setAIPanelVisibility } from "~/atoms/settings/ai" +import { + AIChatPanelStyle, + getAIPanelVisibility, + getAISettings, + setAIPanelVisibility, +} from "~/atoms/settings/ai" import { FocusablePresets } from "~/components/common/Focusable" import { useChatActions } from "../store/hooks" @@ -20,9 +25,11 @@ export const useAIShortcut = () => { chatActions.newChat() }, "$mod+w": (e) => { - e.preventDefault() - // close AI chat - setAIPanelVisibility(false) + if (getAISettings().panelStyle === AIChatPanelStyle.Floating && getAIPanelVisibility()) { + e.preventDefault() + // close AI chat + setAIPanelVisibility(false) + } }, }) }, [chatActions, isFocus])