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 <tukon479@gmail.com>
This commit is contained in:
parent
0a42795377
commit
9cc55c8765
|
|
@ -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 (
|
||||
<ChatHeaderLayout
|
||||
isFloating={isFloating}
|
||||
|
|
@ -123,6 +127,7 @@ export const ChatHeader: FC<{ isFloating: boolean }> = ({ isFloating }) => {
|
|||
<TaskReportDropdown />
|
||||
|
||||
<ChatMoreDropdown
|
||||
canClosePanel={!isAllView}
|
||||
triggerElement={
|
||||
<ActionButton tooltip="More">
|
||||
<i className="i-mingcute-more-1-fill size-5 text-text-secondary" />
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue