From 43a91c200cac8264b0e415fa79eebe1e1041d477 Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 20 Oct 2025 20:44:13 +0800 Subject: [PATCH] chore: adjust ai settings Updated the AISmartSidebar component to utilize CSS animations instead of motion/react for smoother performance. Introduced a new hook to manage prompt visibility based on focusable scope, enhancing user experience. Removed the label from the PersonalizePromptSection for a cleaner UI and updated localization files accordingly. Signed-off-by: Innei --- .../modules/ai-chat/components/layouts/AISmartSidebar.tsx | 7 ++++++- .../modules/settings/tabs/ai/PersonalizePromptSection.tsx | 2 -- locales/ai/en.json | 1 - locales/ai/ja.json | 1 - locales/ai/zh-CN.json | 1 - 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx index 128af2f50..fd653ea0d 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AISmartSidebar.tsx @@ -1,6 +1,7 @@ // Replaced motion/react animations with CSS animations import "./AISmartSidebar.css" +import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js" import { Spring } from "@follow/components/constants/spring.js" import { useMousePosition } from "@follow/components/hooks/useMouse.js" import { KbdCombined } from "@follow/components/ui/kbd/Kbd.js" @@ -9,6 +10,7 @@ import * as React from "react" import { useEffect, useState } from "react" import { setAIPanelVisibility, useAIPanelVisibility } from "~/atoms/settings/ai" +import { FocusablePresets } from "~/components/common/Focusable" import { COMMAND_ID } from "~/modules/command/commands/id" import { useCommandShortcut } from "~/modules/command/hooks/use-command-binding" @@ -18,7 +20,9 @@ const AIAmbientSidebar: React.FC<{ onExpand: () => void }> = ({ onExpand }) => { const isShowPromptRef = React.useRef(false) const mousePosition = useMousePosition() + const canShowPrompt = useGlobalFocusableScopeSelector(FocusablePresets.isNotFloatingLayerScope) useEffect(() => { + if (!canShowPrompt) return const rightEdgeDistance = window.innerWidth - mousePosition.x const maxDistance = 500 const threshold = 80 @@ -47,9 +51,10 @@ const AIAmbientSidebar: React.FC<{ onExpand: () => void }> = ({ onExpand }) => { setShowPrompt(false) isShowPromptRef.current = false } - }, [mousePosition]) + }, [canShowPrompt, mousePosition]) const toggleAIChatShortcut = useCommandShortcut(COMMAND_ID.global.toggleAIChat) + if (!canShowPrompt) return null return ( <>
{ return (
-