From 2d5d07662671b90369fbf3c4cccf81855a60c7fb Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 11 Nov 2025 20:02:23 +0800 Subject: [PATCH] feat: implement timeline summarization feature and update related UI components --- .../layer/renderer/src/atoms/settings/ai.ts | 3 +- .../components/3d-models/AISplineLoader.tsx | 2 +- .../components/layouts/ChatInterface.tsx | 3 - .../hooks/useAutoTimelineSummaryShortcut.ts | 329 ------------------ .../ai-chat/hooks/useSummarizeTimeline.ts | 158 +++++++++ .../AIEnhancedTimelineLayout.tsx | 18 +- .../entry-content/EntryContentPlaceholder.tsx | 5 +- .../entry-column/layouts/EntryListHeader.tsx | 20 +- .../components/EntryPlaceholderLogo.tsx | 42 ++- .../src/modules/settings/tabs/plan.tsx | 2 +- locales/app/en.json | 1 + locales/app/ja.json | 1 + locales/app/zh-CN.json | 1 + locales/app/zh-TW.json | 1 + 14 files changed, 230 insertions(+), 356 deletions(-) delete mode 100644 apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut.ts create mode 100644 apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSummarizeTimeline.ts diff --git a/apps/desktop/layer/renderer/src/atoms/settings/ai.ts b/apps/desktop/layer/renderer/src/atoms/settings/ai.ts index 06be487f9..bd814bfc2 100644 --- a/apps/desktop/layer/renderer/src/atoms/settings/ai.ts +++ b/apps/desktop/layer/renderer/src/atoms/settings/ai.ts @@ -111,7 +111,7 @@ export const isServerShortcut = (shortcut: AIShortcut) => !!shortcut.defaultProm export const createDefaultSettings = (): WebAISettings => ({ ...defaultAISettings, shortcuts: normalizeShortcuts(defaultAISettings.shortcuts), - panelStyle: AIChatPanelStyle.Fixed, + panelStyle: AIChatPanelStyle.Floating, showSplineButton: true, }) @@ -224,5 +224,4 @@ export const removeMCPService = (id: string) => { //// Enhance Init Ai Settings export const initializeDefaultAISettings = () => { initializeDefaultSettings() - if (getAISettings().panelStyle === AIChatPanelStyle.Fixed) setAIPanelVisibility(true) } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx index 0bb9a8a00..235ee3b14 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx @@ -109,7 +109,7 @@ export const AISplineLoader = ({ className }: { className?: string }) => { ) return ( -
+
) 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 b191da62f..a776ab7fd 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 @@ -19,7 +19,6 @@ import { useActionLanguage } from "~/atoms/settings/general" import { ROUTE_FEED_IN_FOLDER } from "~/constants" import { getRouteParams } from "~/hooks/biz/useRouteParams" import { useAutoScroll } from "~/modules/ai-chat/hooks/useAutoScroll" -import { useAutoTimelineSummaryShortcut } from "~/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut" import { useLoadMessages } from "~/modules/ai-chat/hooks/useLoadMessages" import { useMainEntryId } from "~/modules/ai-chat/hooks/useMainEntryId" import { @@ -51,8 +50,6 @@ const ChatInterfaceContent = ({ centerInputOnEmpty }: ChatInterfaceProps) => { const error = useChatError() const messages = useMessages() - useAutoTimelineSummaryShortcut() - const isFocusWithIn = useFocusable() const aiPanelRefs = use(AIPanelRefsContext) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut.ts deleted file mode 100644 index 3322fcfbe..000000000 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useAutoTimelineSummaryShortcut.ts +++ /dev/null @@ -1,329 +0,0 @@ -import { convertLexicalToMarkdown } from "@follow/components/ui/lexical-rich-editor/utils.js" -import { FeedViewType } from "@follow/constants" -import { DEFAULT_SUMMARIZE_TIMELINE_SHORTCUT_ID } from "@follow/shared/settings/defaults" -import { getCategoryFeedIds } from "@follow/store/subscription/getter" -import { asyncableNextFrame } from "@follow/utils" -import type { LexicalEditor } from "lexical" -import { $createParagraphNode, $getRoot, createEditor } from "lexical" -import { nanoid } from "nanoid" -import { useEffect, useMemo, useRef } from "react" - -import { useIsInMASReview } from "~/atoms/server-configs" -import { getShortcutEffectivePrompt, useAISettingValue } from "~/atoms/settings/ai" -import { useGeneralSettingKey } from "~/atoms/settings/general" -import { ROUTE_FEED_IN_FOLDER, ROUTE_FEED_PENDING } from "~/constants" -import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" - -import { AI_CHAT_SPECIAL_ID_PREFIX } from "../constants" -import { LexicalAIEditorNodes, ShortcutNode } from "../editor" -import { AIPersistService } from "../services" -import { useAIChatStore } from "../store/AIChatContext" -import { useBlockActions, useChatActions, useCurrentChatId } from "../store/hooks" -import { BlockSliceAction } from "../store/slices/block.slice" -import type { AIChatContextBlock, SendingUIMessage } from "../store/types" -import { isTimelineSummaryAutoContext } from "./useTimelineSummaryAutoContext" - -const INTERVAL = 5 * 60 * 60 * 1000 - -const buildSummaryMessage = ( - editor: LexicalEditor, - contextBlocks: AIChatContextBlock[], - messageId: string, -): SendingUIMessage => { - const parts: SendingUIMessage["parts"] = [] - - if (contextBlocks.length > 0) { - parts.push({ - type: "data-block", - data: contextBlocks, - }) - } - - parts.push({ - type: "data-rich-text", - data: { - state: JSON.stringify(editor.getEditorState().toJSON()), - text: convertLexicalToMarkdown(editor), - }, - }) - - return { - id: messageId, - role: "user", - parts, - } -} - -const buildTimelineSummaryChatId = ({ - view, - feedId, - timelineId, - unreadOnly, - seed, -}: { - view: number - feedId: string - timelineId?: string | null - unreadOnly: boolean - seed: string -}) => { - const normalizedTimelineId = timelineId ?? "all" - const unreadSegment = unreadOnly ? "unread" : "all" - const prefix = AI_CHAT_SPECIAL_ID_PREFIX.TIMELINE_SUMMARY - return `${prefix}${view}:${feedId}:${normalizedTimelineId}:${unreadSegment}:${seed}` -} - -export const useAutoTimelineSummaryShortcut = () => { - const aiSettings = useAISettingValue() - const unreadOnly = useGeneralSettingKey("unreadOnly") - const isInMASReview = useIsInMASReview() - - const { view, feedId, entryId, timelineId } = useRouteParamsSelector((params) => ({ - view: params.view, - feedId: params.feedId, - entryId: params.entryId, - timelineId: params.timelineId, - })) - - const chatActions = useChatActions() - const blockActions = useBlockActions() - const currentChatId = useCurrentChatId() - const timelineSummaryManualOverride = useAIChatStore()( - (state) => state.timelineSummaryManualOverride, - ) - const timelineSummaryWasInAutoContext = useAIChatStore()( - (state) => state.timelineSummaryWasInAutoContext, - ) - const setTimelineSummaryWasInAutoContext = useAIChatStore()( - (state) => state.chatActions.setTimelineSummaryWasInAutoContext, - ) - - const automationStateRef = useRef<{ - contextKey: string | null - promise: Promise | null - failed: boolean - }>({ - contextKey: null, - promise: null, - failed: false, - }) - const previousContextKeyRef = useRef(null) - - const isAllTimeline = isTimelineSummaryAutoContext({ entryId }) - - const defaultShortcut = useMemo(() => { - const shortcuts = aiSettings.shortcuts ?? [] - return shortcuts.find( - (shortcut) => shortcut.id === DEFAULT_SUMMARIZE_TIMELINE_SHORTCUT_ID && shortcut.enabled, - ) - }, [aiSettings.shortcuts]) - - const normalizedFeedId = feedId ?? ROUTE_FEED_PENDING - - const contextKey = useMemo(() => { - if (!isAllTimeline) return null - const keyParts = [ - `timeline:${timelineId ?? "all"}`, - `feed:${normalizedFeedId}`, - `unread:${unreadOnly ? "1" : "0"}`, - ] - return keyParts.join("|") - }, [isAllTimeline, timelineId, normalizedFeedId, unreadOnly]) - - useEffect(() => { - if (previousContextKeyRef.current !== contextKey) { - chatActions.setTimelineSummaryManualOverride(false) - previousContextKeyRef.current = contextKey - } - }, [chatActions, contextKey]) - - useEffect(() => { - if ( - timelineSummaryWasInAutoContext && - !isAllTimeline && - currentChatId && - currentChatId.startsWith(AI_CHAT_SPECIAL_ID_PREFIX.TIMELINE_SUMMARY) - ) { - blockActions.clearBlocks({ keepSpecialTypes: true }) - chatActions.newChat() - } - setTimelineSummaryWasInAutoContext(isAllTimeline) - }, [ - blockActions, - chatActions, - currentChatId, - isAllTimeline, - setTimelineSummaryWasInAutoContext, - timelineSummaryWasInAutoContext, - ]) - - const contextBlocks = useMemo(() => { - if (!isAllTimeline) return [] - - const blocks: AIChatContextBlock[] = [] - - if (typeof view === "number") { - blocks.push({ - id: BlockSliceAction.SPECIAL_TYPES.mainView, - type: "mainView", - value: `${view}`, - }) - } - - if (normalizedFeedId && normalizedFeedId !== ROUTE_FEED_PENDING) { - let value = normalizedFeedId - if (normalizedFeedId.startsWith(ROUTE_FEED_IN_FOLDER)) { - const categoryName = normalizedFeedId.slice(ROUTE_FEED_IN_FOLDER.length) - const ids = getCategoryFeedIds(categoryName, FeedViewType.All) - if (ids.length > 0) { - value = ids.join(",") - } - } - - blocks.push({ - id: BlockSliceAction.SPECIAL_TYPES.mainFeed, - type: "mainFeed", - value, - }) - } - - if (unreadOnly) { - blocks.push({ - id: BlockSliceAction.SPECIAL_TYPES.unreadOnly, - type: "unreadOnly", - value: "true", - }) - } - - return blocks - }, [isAllTimeline, normalizedFeedId, unreadOnly, view]) - - useEffect(() => { - if (isInMASReview) { - return - } - - if (!contextKey || !defaultShortcut) { - if (!contextKey) { - automationStateRef.current = { contextKey: null, promise: null, failed: false } - } - return - } - - if (automationStateRef.current.contextKey !== contextKey) { - automationStateRef.current = { - contextKey, - promise: null, - failed: false, - } - } else { - if (automationStateRef.current.promise) { - return - } - if (automationStateRef.current.failed) { - return - } - } - - if (timelineSummaryManualOverride) { - return - } - - const run = async () => { - try { - const prompt = getShortcutEffectivePrompt(defaultShortcut) - const { id, name } = defaultShortcut - - const existingSession = await AIPersistService.findTimelineSummarySession({ - view, - feedId: normalizedFeedId, - timelineId: timelineId ?? null, - unreadOnly, - }) - const now = Date.now() - - if (existingSession) { - const lastUpdatedAt = existingSession.updatedAt?.getTime?.() ?? existingSession.updatedAt - if (typeof lastUpdatedAt === "number" && now - lastUpdatedAt < INTERVAL) { - if (currentChatId !== existingSession.chatId) { - await chatActions.switchToChat(existingSession.chatId) - } - automationStateRef.current.failed = false - return - } - } - - const timelineSummaryChatId = buildTimelineSummaryChatId({ - view, - feedId: normalizedFeedId, - timelineId: timelineId ?? null, - unreadOnly, - seed: nanoid(6), - }) - - await AIPersistService.ensureSession(timelineSummaryChatId, { - title: "Timeline Summary", - }) - - await chatActions.switchToChat(timelineSummaryChatId) - - await asyncableNextFrame(async () => { - // wait switch to chat completed - if (chatActions.get().chatId !== timelineSummaryChatId) { - return - } - blockActions.clearBlocks({ keepSpecialTypes: true }) - - const tempEditor = createEditor({ - nodes: LexicalAIEditorNodes, - }) - - tempEditor.update( - () => { - const root = $getRoot() - root.clear() - const paragraph = $createParagraphNode() - const shortcutNode = new ShortcutNode({ id, name, prompt }) - paragraph.append(shortcutNode) - root.append(paragraph) - }, - { - discrete: true, - }, - ) - - const message = buildSummaryMessage(tempEditor, contextBlocks, nanoid()) - - await chatActions.sendMessage(message, { - body: { scene: "general" }, - }) - - automationStateRef.current.failed = false - }) - } catch (error) { - automationStateRef.current.failed = true - console.error("[AI Chat] Failed to auto-run timeline summary shortcut:", error) - } finally { - if (automationStateRef.current.contextKey === contextKey) { - automationStateRef.current.promise = null - } - } - } - - const promise = run() - automationStateRef.current.promise = promise - }, [ - blockActions, - chatActions, - contextBlocks, - contextKey, - currentChatId, - defaultShortcut, - normalizedFeedId, - timelineId, - unreadOnly, - view, - timelineSummaryManualOverride, - isInMASReview, - ]) -} diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSummarizeTimeline.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSummarizeTimeline.ts new file mode 100644 index 000000000..d40c7b137 --- /dev/null +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSummarizeTimeline.ts @@ -0,0 +1,158 @@ +import { convertLexicalToMarkdown } from "@follow/components/ui/lexical-rich-editor/utils.js" +import { DEFAULT_SUMMARIZE_TIMELINE_SHORTCUT_ID } from "@follow/shared/settings/defaults" +import { getCategoryFeedIds } from "@follow/store/subscription/getter" +import type { EditorState } from "lexical" +import { $createParagraphNode, $getRoot, createEditor } from "lexical" +import { nanoid } from "nanoid" +import { useCallback, useMemo } from "react" + +import { + getShortcutEffectivePrompt, + setAIPanelVisibility, + useAISettingKey, +} from "~/atoms/settings/ai" +import { ROUTE_FEED_IN_FOLDER } from "~/constants" +import { getRouteParams } from "~/hooks/biz/useRouteParams" +import type { ShortcutData } from "~/modules/ai-chat/editor" +import { LexicalAIEditorNodes, ShortcutNode } from "~/modules/ai-chat/editor" +import { useBlockActions, useChatActions } from "~/modules/ai-chat/store/hooks" +import type { AIChatContextBlock, SendingUIMessage } from "~/modules/ai-chat/store/types" + +export const useSummarizeTimeline = () => { + const shortcuts = useAISettingKey("shortcuts") + const chatActions = useChatActions() + const blockActions = useBlockActions() + + const defaultSummarizeShortcut = useMemo(() => { + const allShortcuts = shortcuts ?? [] + const shortcut = allShortcuts.find( + (item) => item.id === DEFAULT_SUMMARIZE_TIMELINE_SHORTCUT_ID && item.enabled, + ) + + if (!shortcut) { + return null + } + + const prompt = getShortcutEffectivePrompt(shortcut).trim() + if (!prompt) { + return null + } + + return { + id: shortcut.id, + name: shortcut.name || "Summarize timeline", + prompt, + hotkey: shortcut.hotkey, + displayTargets: shortcut.displayTargets, + } + }, [shortcuts]) + + const staticEditor = useMemo(() => { + return createEditor({ + nodes: LexicalAIEditorNodes, + }) + }, []) + + const createShortcutEditorState = useCallback((shortcutData: ShortcutData): EditorState => { + const tempEditor = createEditor({ + nodes: LexicalAIEditorNodes, + }) + + tempEditor.update( + () => { + const root = $getRoot() + root.clear() + const paragraph = $createParagraphNode() + const shortcutNode = new ShortcutNode(shortcutData) + paragraph.append(shortcutNode) + root.append(paragraph) + }, + { + discrete: true, + }, + ) + + return tempEditor.getEditorState() + }, []) + + const buildContextBlocks = useCallback((): AIChatContextBlock[] => { + const blocks: AIChatContextBlock[] = [] + + for (const block of blockActions.getBlocks()) { + if (block.type === "fileAttachment" && block.attachment.serverUrl) { + blocks.push({ + ...block, + attachment: { + id: block.attachment.id, + name: block.attachment.name, + type: block.attachment.type, + size: block.attachment.size, + serverUrl: block.attachment.serverUrl, + }, + }) + } else if (block.type === "mainFeed" && block.value.startsWith(ROUTE_FEED_IN_FOLDER)) { + const categoryName = block.value.slice(ROUTE_FEED_IN_FOLDER.length) + const { view } = getRouteParams() + const feedIds = getCategoryFeedIds(categoryName, view) + blocks.push({ + ...block, + value: feedIds.join(","), + }) + } else { + blocks.push(block) + } + } + + return blocks.filter((block) => !block.disabled) + }, [blockActions]) + + const sendShortcutMessage = useCallback( + (editorState: EditorState) => { + const contextBlocks = buildContextBlocks() + + staticEditor.setEditorState(editorState) + + const parts: SendingUIMessage["parts"] = [ + { + type: "data-block", + data: contextBlocks, + }, + { + type: "data-rich-text", + data: { + state: JSON.stringify(editorState.toJSON()), + text: convertLexicalToMarkdown(staticEditor), + }, + }, + ] + + const message: SendingUIMessage = { + parts, + role: "user", + id: nanoid(), + } + + void chatActions.sendMessage(message) + }, + [buildContextBlocks, chatActions, staticEditor], + ) + + const summarizeTimeline = useCallback(() => { + setAIPanelVisibility(true) + + if (!defaultSummarizeShortcut) { + return + } + + void (async () => { + await chatActions.newChat() + const editorState = createShortcutEditorState(defaultSummarizeShortcut) + sendShortcutMessage(editorState) + })() + }, [chatActions, createShortcutEditorState, defaultSummarizeShortcut, sendShortcutMessage]) + + return { + summarizeTimeline, + hasSummarizeShortcut: !!defaultSummarizeShortcut, + } +} 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 d932fff49..8a5a318e7 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,12 +9,7 @@ import type { CSSProperties } from "react" import { memo, useCallback, useEffect, useMemo, useRef } from "react" import { useResizable } from "react-resizable-layout" -import { - AIChatPanelStyle, - setAIPanelVisibility, - useAIChatPanelStyle, - useAIPanelVisibility, -} from "~/atoms/settings/ai" +import { AIChatPanelStyle, 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" @@ -122,16 +117,9 @@ 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 = effectivePanelStyle === AIChatPanelStyle.Fixed - const shouldShowFixedAI = isAllView || (isFixedPanelStyle && isAIPanelVisible) + const isFixedPanelStyle = aiPanelStyle === AIChatPanelStyle.Fixed + const shouldShowFixedAI = isFixedPanelStyle && isAIPanelVisible const showEntryContentOnLeft = !showEntryDetailsColumn && hasSelectedEntry const shouldRenderRightColumn = showEntryDetailsColumn || shouldShowFixedAI diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryContentPlaceholder.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryContentPlaceholder.tsx index 22a521915..0cda5d4f3 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryContentPlaceholder.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryContentPlaceholder.tsx @@ -1,8 +1,11 @@ import { AnimatePresence, LayoutGroup, m } from "motion/react" +import { useSummarizeTimeline } from "~/modules/ai-chat/hooks/useSummarizeTimeline" import { EntryPlaceholderLogo } from "~/modules/entry-content/components/EntryPlaceholderLogo" export const EntryContentPlaceholder = () => { + const { summarizeTimeline } = useSummarizeTimeline() + return ( @@ -11,7 +14,7 @@ export const EntryContentPlaceholder = () => { initial={{ opacity: 0.01, y: 300 }} animate={{ opacity: 1, y: 0 }} > - + diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx index 8a58c221f..ad36ddd3c 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx @@ -18,8 +18,10 @@ import { previewBackPath } from "~/atoms/preview" import { useGeneralSettingKey } from "~/atoms/settings/general" import { useSubscriptionColumnShow } from "~/atoms/sidebar" import { ROUTE_ENTRY_PENDING } from "~/constants" +import { useFeature } from "~/hooks/biz/useFeature" import { useFollow } from "~/hooks/biz/useFollow" import { getRouteParams, useRouteParams } from "~/hooks/biz/useRouteParams" +import { useSummarizeTimeline } from "~/modules/ai-chat/hooks/useSummarizeTimeline" import { COMMAND_ID } from "~/modules/command/commands/id" import { useRunCommandFn } from "~/modules/command/hooks/use-command" import { useCommandShortcut } from "~/modules/command/hooks/use-command-binding" @@ -43,9 +45,11 @@ export const EntryListHeader: FC<{ const { t } = useTranslation() const unreadOnly = useGeneralSettingKey("unreadOnly") + const aiEnabled = useFeature("ai") const { feedId, entryId, view, isCollection } = routerParams const isPreview = useIsPreviewFeed() + const isWideMode = !!getView(view)?.wideMode const headerTitle = useFeedHeaderTitle() const feedIcon = useFeedHeaderIcon() @@ -86,6 +90,10 @@ export const EntryListHeader: FC<{ const { isScrolledBeyondThreshold } = useEntryRootState() const isScrolledBeyondThresholdValue = useAtomValue(isScrolledBeyondThreshold) + const { summarizeTimeline } = useSummarizeTimeline() + const showEntryHeader = isWideMode && !!entryId && entryId !== ROUTE_ENTRY_PENDING + const showTimelineSummaryButton = isWideMode && aiEnabled + return (
- {getView(view)?.wideMode && entryId && entryId !== ROUTE_ENTRY_PENDING && ( + {isWideMode && (showEntryHeader || showTimelineSummaryButton) && ( <> - + {showEntryHeader && } + {showTimelineSummaryButton && ( + + + + )} )} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryPlaceholderLogo.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryPlaceholderLogo.tsx index 8fe456dc8..07f432dd8 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryPlaceholderLogo.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryPlaceholderLogo.tsx @@ -1,10 +1,28 @@ import { Logo } from "@follow/components/icons/logo.jsx" +import { MotionButtonBase } from "@follow/components/ui/button/index.js" import { stopPropagation } from "@follow/utils/dom" +import { cn } from "@follow/utils/utils" +import { setAIPanelVisibility } from "~/atoms/settings/ai" +import { useFeature } from "~/hooks/biz/useFeature" import { useFeedHeaderTitle } from "~/store/feed/hooks" -export const EntryPlaceholderLogo = () => { +interface EntryPlaceholderLogoProps { + onAskAI?: () => void +} + +export const EntryPlaceholderLogo = ({ onAskAI }: EntryPlaceholderLogoProps) => { const title = useFeedHeaderTitle() + const aiEnabled = useFeature("ai") + + const handleAskAI = () => { + if (onAskAI) { + onAskAI() + return + } + + setAIPanelVisibility(true) + } return (
{ "flex w-full min-w-0 flex-col items-center justify-center gap-2 px-12 pb-6 text-center text-lg font-medium text-text-secondary duration-500" } > - +
{title}
+ + {aiEnabled && ( + + + Summarize the current timeline + + )}
) } diff --git a/apps/desktop/layer/renderer/src/modules/settings/tabs/plan.tsx b/apps/desktop/layer/renderer/src/modules/settings/tabs/plan.tsx index 8ecfc6296..47bfaf210 100644 --- a/apps/desktop/layer/renderer/src/modules/settings/tabs/plan.tsx +++ b/apps/desktop/layer/renderer/src/modules/settings/tabs/plan.tsx @@ -481,7 +481,7 @@ const PlanComparisonTable = ({ plans }: { plans: PaymentPlan[] }) => { - {plans.map((plan) => ( diff --git a/locales/app/en.json b/locales/app/en.json index 2e654106b..e39873793 100644 --- a/locales/app/en.json +++ b/locales/app/en.json @@ -187,6 +187,7 @@ "entry_list_header.refresh": "Refresh", "entry_list_header.show_all": "Show all", "entry_list_header.show_unread_only": "Show unread Only", + "entry_list_header.timeline_summary": "Summarize timeline", "entry_list_header.unread": "unread", "feed.actions.follow": "Follow", "feed.actions.followed": "Followed", diff --git a/locales/app/ja.json b/locales/app/ja.json index bf862fc25..ec3c670b1 100644 --- a/locales/app/ja.json +++ b/locales/app/ja.json @@ -186,6 +186,7 @@ "entry_list_header.refresh": "更新", "entry_list_header.show_all": "すべて表示", "entry_list_header.show_unread_only": "未読のみ表示", + "entry_list_header.timeline_summary": "タイムラインを要約", "entry_list_header.unread": "未読", "feed.actions.follow": "フォロー", "feed.actions.followed": "フォロー済み", diff --git a/locales/app/zh-CN.json b/locales/app/zh-CN.json index 2078a9b8c..8b7a274cc 100644 --- a/locales/app/zh-CN.json +++ b/locales/app/zh-CN.json @@ -186,6 +186,7 @@ "entry_list_header.refresh": "刷新", "entry_list_header.show_all": "显示全部", "entry_list_header.show_unread_only": "仅显示未读", + "entry_list_header.timeline_summary": "总结时间线", "entry_list_header.unread": "未读", "feed.actions.follow": "订阅", "feed.actions.followed": "已订阅", diff --git a/locales/app/zh-TW.json b/locales/app/zh-TW.json index 283c652f2..a9f5e301b 100644 --- a/locales/app/zh-TW.json +++ b/locales/app/zh-TW.json @@ -184,6 +184,7 @@ "entry_list_header.refresh": "重新整理", "entry_list_header.show_all": "顯示全部", "entry_list_header.show_unread_only": "僅顯示未讀", + "entry_list_header.timeline_summary": "摘要時間線", "entry_list_header.unread": "未讀", "feed.actions.follow": "跟隨", "feed.actions.followed": "已跟隨",
+ Features