From 9cc55c87656272f9aaa652b0368ce6d3242c8b49 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 8 Nov 2025 16:17:50 +0800 Subject: [PATCH] feat(ai-chat): update ChatHeader and AIEnhancedTimelineLayout for improved panel visibility - Added logic to control AI panel visibility based on the current view in ChatHeader. - Enhanced AIEnhancedTimelineLayout to automatically show the AI panel when in 'All' view. - Refactored imports for better organization and clarity. Signed-off-by: Innei --- .../ai-chat/components/layouts/ChatHeader.tsx | 5 +++++ .../AIEnhancedTimelineLayout.tsx | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx index 4f81bfc6a..5c9ab1ebf 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx @@ -1,11 +1,13 @@ import { ActionButton } from "@follow/components/ui/button/index.js" import { cn } from "@follow/utils" +import { FeedViewType } from "@follow-app/client-sdk" import { useAtomValue } from "jotai" import type { FC, ReactNode } from "react" import { useCallback } from "react" import { useTranslation } from "react-i18next" import { setAIPanelVisibility } from "~/atoms/settings/ai" +import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" import { useTimelineSummaryAutoContext } from "~/modules/ai-chat/hooks/useTimelineSummaryAutoContext" import { useBlockActions, @@ -111,6 +113,8 @@ const ChatHeaderLayout = ({ export const ChatHeader: FC<{ isFloating: boolean }> = ({ isFloating }) => { const { t } = useTranslation("ai") + const view = useRouteParamsSelector((state) => state.view) + const isAllView = view === FeedViewType.All return ( = ({ isFloating }) => { diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx index 8a5a318e7..d932fff49 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx @@ -9,7 +9,12 @@ import type { CSSProperties } from "react" import { memo, useCallback, useEffect, useMemo, useRef } from "react" import { useResizable } from "react-resizable-layout" -import { AIChatPanelStyle, useAIChatPanelStyle, useAIPanelVisibility } from "~/atoms/settings/ai" +import { + AIChatPanelStyle, + setAIPanelVisibility, + useAIChatPanelStyle, + useAIPanelVisibility, +} from "~/atoms/settings/ai" import { getUISettings, setUISetting, useUISettingKey } from "~/atoms/settings/ui" import { m } from "~/components/common/Motion" import { ROUTE_ENTRY_PENDING } from "~/constants" @@ -117,9 +122,16 @@ const AIEnhancedTimelineLayoutImpl = () => { window.dispatchEvent(new Event("resize")) }, [resolvePreferredWidth, setAiPanelWidth]) + useEffect(() => { + if (isAllView && !isAIPanelVisible) { + setAIPanelVisibility(true) + } + }, [isAllView, isAIPanelVisible]) + + const effectivePanelStyle = isAllView ? AIChatPanelStyle.Fixed : aiPanelStyle const showEntryContentOnRight = showEntryDetailsColumn && hasSelectedEntry - const isFixedPanelStyle = aiPanelStyle === AIChatPanelStyle.Fixed - const shouldShowFixedAI = isFixedPanelStyle && isAIPanelVisible + const isFixedPanelStyle = effectivePanelStyle === AIChatPanelStyle.Fixed + const shouldShowFixedAI = isAllView || (isFixedPanelStyle && isAIPanelVisible) const showEntryContentOnLeft = !showEntryDetailsColumn && hasSelectedEntry const shouldRenderRightColumn = showEntryDetailsColumn || shouldShowFixedAI