From e0a2e6c49cc945dcdf89378a2d74e747e3e4c19e Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 6 Nov 2025 21:25:56 +0800 Subject: [PATCH] fix(chat): chat bottom input container calcultion - Removed the rateLimitNoticeRef from ChatInterface, simplifying the height calculation. - Updated RateLimitNotice component to eliminate the ref prop, streamlining its implementation. Signed-off-by: Innei --- .../modules/ai-chat/components/layouts/ChatInterface.tsx | 9 +++------ .../ai-chat/components/layouts/RateLimitNotice.tsx | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx index 3085ef9bd..d730c2826 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInterface.tsx @@ -283,15 +283,12 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => { const [bottomPanelHeight, setBottomPanelHeight] = useState(0) const bottomPanelRef = useRef(null) - const rateLimitNoticeRef = useRef(null) useLayoutEffect(() => { - if (!bottomPanelRef.current || !rateLimitNoticeRef.current) { + if (!bottomPanelRef.current) { return } - setBottomPanelHeight( - (bottomPanelRef.current?.offsetHeight ?? 0) + (rateLimitNoticeRef.current?.offsetHeight ?? 0), - ) + setBottomPanelHeight(bottomPanelRef.current.offsetHeight) const resizeObserver = new ResizeObserver(() => { if (!bottomPanelRef.current) { @@ -416,7 +413,7 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => { "bottom-1/2 translate-y-[calc(100%+1rem)] duration-200", )} > - + { const tempEditor = createEditor({ diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/RateLimitNotice.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/RateLimitNotice.tsx index 1bba1ffcd..9ecf5f6f0 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/RateLimitNotice.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/RateLimitNotice.tsx @@ -8,7 +8,6 @@ import { useSettingModal } from "~/modules/settings/modal/useSettingModal" import { parseAIError } from "../../utils/error" interface RateLimitNoticeProps { - ref?: React.Ref error?: Error chatConfig?: ConfigResponse className?: string @@ -18,7 +17,7 @@ interface RateLimitNoticeProps { * RateLimitNotice component * Displays rate limit information above the input in a subtle, non-alarming way */ -export const RateLimitNotice = ({ ref, error, chatConfig, className }: RateLimitNoticeProps) => { +export const RateLimitNotice = ({ error, chatConfig, className }: RateLimitNoticeProps) => { const message = React.useMemo(() => { if (error) { return buildErrorMessage(error) @@ -40,7 +39,6 @@ export const RateLimitNotice = ({ ref, error, chatConfig, className }: RateLimit return (