From 360e6553e533c5ca1e126bbfccb74778f3201869 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 3 Sep 2025 15:52:51 +0800 Subject: [PATCH] feat(ai): simplify EntrySummaryCard and remove unused quick actions - Removed the `onSend` prop from `EntrySummaryCard` and associated quick actions logic, streamlining the component. - Updated the `WelcomeScreen` to reflect the changes in `EntrySummaryCard`. - Removed the `useSmartQuickActions` hook as it was no longer needed. - Cleaned up localization files by removing the "conversation_starters" key. This refactor enhances the clarity and maintainability of the AI chat components. --- .../components/layouts/WelcomeScreen.tsx | 6 +- .../components/welcome/EntrySummaryCard.tsx | 32 +------ .../ai-chat/hooks/useSmartQuickActions.ts | 88 ------------------- locales/ai/en.json | 1 - locales/ai/ja.json | 1 - locales/ai/zh-CN.json | 1 - 6 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSmartQuickActions.ts diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx index 14d424bd6..5e98d11dc 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx @@ -64,11 +64,7 @@ export const WelcomeScreen = ({ onSend, centerInputOnEmpty }: WelcomeScreenProps > {hasEntryContext ? ( - onSend(message, null)} - /> + ) : ( void className?: string } -export const EntrySummaryCard: React.FC = ({ - entryId, - onSend, - className, -}) => { +export const EntrySummaryCard: React.FC = ({ entryId, className }) => { const { t } = useTranslation("ai") const actionLanguage = useActionLanguage() const isInReadabilitySuccess = useEntryIsInReadabilitySuccess(entryId) @@ -31,27 +23,6 @@ export const EntrySummaryCard: React.FC = ({ enabled: true, }) - const quickActions = useSmartQuickActions(summary.data || null, entryId) - - const footerContent = summary.data && quickActions.length > 0 && ( -
-
- {t("conversation_starters", { defaultValue: "Conversation starters" })} -
-
- {quickActions.map((action, index) => ( - onSend(action.prompt)} - animationDelay={index * 0.1} - > - {action.label} - - ))} -
-
- ) - return ( = ({ isLoading={summary.isLoading} className={className} title={t("ai_summary")} - footerContent={footerContent} /> ) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSmartQuickActions.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSmartQuickActions.ts deleted file mode 100644 index 984e7d368..000000000 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/hooks/useSmartQuickActions.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { useEntry } from "@follow/store/entry/hooks" -import { useMemo } from "react" -import { useTranslation } from "react-i18next" - -interface QuickAction { - id: string - label: string - prompt: string - icon: string - priority: number -} - -const DEFAULT_ENTRY_ACTIONS: QuickAction[] = [ - { - id: "analyze", - label: "Analyze this entry", - prompt: "Can you analyze this entry and tell me what it's about?", - icon: "i-mgc-search-cute-re", - priority: 1, - }, - { - id: "explain", - label: "Explain key points", - prompt: "What are the key points I should understand from this entry?", - icon: "i-mgc-lightbulb-cute-re", - priority: 2, - }, -] - -/** - * Hook to generate contextual conversation starters based on summary content and entry metadata. - * Returns an array of quick actions that provide intelligent prompts for starting AI conversations. - */ -export const useSmartQuickActions = ( - summaryData: string | null, - entryId: string, -): QuickAction[] => { - const entry = useEntry(entryId, (state) => ({ url: state.url })) - const { t } = useTranslation("ai") - - return useMemo(() => { - if (!summaryData || !entry) return DEFAULT_ENTRY_ACTIONS - - const actions: QuickAction[] = [] - - // Content-based actions - if (summaryData.length > 500) { - actions.push({ - id: "simplify", - label: t("quick_actions.simplify") || "Simplify this", - prompt: `Can you simplify this summary in 2-3 sentences? Focus on the main points.`, - icon: "i-mgc-edit-cute-re", - priority: 1, - }) - } - - // Entry type-based actions - if (entry.url) { - actions.push({ - id: "discuss", - label: t("quick_actions.discuss") || "Discuss insights", - prompt: `What are the key insights from this article? What should I know?`, - icon: "i-mgc-chat-cute-re", - priority: 2, - }) - } - - // Always available actions - actions.push( - { - id: "questions", - label: t("quick_actions.questions") || "Ask questions", - prompt: `What questions should I be asking about this content?`, - icon: "i-mgc-question-cute-re", - priority: 3, - }, - { - id: "takeaways", - label: t("quick_actions.takeaways") || "Key takeaways", - prompt: `What are the most important takeaways from this entry?`, - icon: "i-mgc-star-cute-re", - priority: 4, - }, - ) - - return actions.sort((a, b) => a.priority - b.priority).slice(0, 4) - }, [summaryData, entry, t]) -} diff --git a/locales/ai/en.json b/locales/ai/en.json index 9ba7aeaf3..36078312c 100644 --- a/locales/ai/en.json +++ b/locales/ai/en.json @@ -20,7 +20,6 @@ "analytics.usage_trends": "Usage Trends (Last 30 Days)", "clear_chat": "Clear Chat", "clear_chat_message": "Are you sure you want to clear all history? This action will permanently delete all content, including all chat logs and data, and cannot be undone.", - "conversation_starters": "Conversation starters", "customize_shortcuts": "Customize shortcuts", "customize_shortcuts_title": "Customize AI shortcuts", "delete_chat": "Delete Chat", diff --git a/locales/ai/ja.json b/locales/ai/ja.json index 4227ff9cc..ec164ec42 100644 --- a/locales/ai/ja.json +++ b/locales/ai/ja.json @@ -20,7 +20,6 @@ "analytics.usage_trends": "使用傾向(過去30日)", "clear_chat": "Chat をクリア", "clear_chat_message": "本当にすべての履歴をクリアしてもよろしいですか?この操作はすべてのコンテンツ、Chat ログ、データを永久に削除し、元に戻すことはできません。", - "conversation_starters": "会話の始め方", "customize_shortcuts": "ショートカットをカスタマイズ", "customize_shortcuts_title": "AIショートカットをカスタマイズ", "delete_chat": "Chat を削除", diff --git a/locales/ai/zh-CN.json b/locales/ai/zh-CN.json index 711f7b404..3e0090d74 100644 --- a/locales/ai/zh-CN.json +++ b/locales/ai/zh-CN.json @@ -20,7 +20,6 @@ "analytics.usage_trends": "使用趋势(最近30天)", "clear_chat": "清空对话", "clear_chat_message": "确定要清空所有历史记录吗?此操作将永久删除所有内容,包括所有聊天记录和数据,且无法撤销。", - "conversation_starters": "对话建议", "customize_shortcuts": "自定义快捷方式", "customize_shortcuts_title": "自定义 AI 快捷方式", "delete_chat": "删除对话",