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.
This commit is contained in:
parent
62dae268cf
commit
360e6553e5
|
|
@ -64,11 +64,7 @@ export const WelcomeScreen = ({ onSend, centerInputOnEmpty }: WelcomeScreenProps
|
|||
>
|
||||
<AnimatePresence mode="wait">
|
||||
{hasEntryContext ? (
|
||||
<EntrySummaryCard
|
||||
key="entry-summary"
|
||||
entryId={mainEntryId}
|
||||
onSend={(message) => onSend(message, null)}
|
||||
/>
|
||||
<EntrySummaryCard key="entry-summary" entryId={mainEntryId} />
|
||||
) : (
|
||||
<DefaultWelcomeContent
|
||||
key="default-welcome"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { AIShortcutButton } from "@follow/components/ui/ai-shortcut-button/index.js"
|
||||
import { usePrefetchSummary } from "@follow/store/summary/hooks"
|
||||
import { m } from "motion/react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
|
@ -8,19 +7,12 @@ import { useEntryIsInReadabilitySuccess } from "~/atoms/readability"
|
|||
import { useActionLanguage } from "~/atoms/settings/general"
|
||||
import { AISummaryCardBase } from "~/components/ui/ai-summary-card"
|
||||
|
||||
import { useSmartQuickActions } from "../../hooks/useSmartQuickActions"
|
||||
|
||||
interface EntrySummaryCardProps {
|
||||
entryId: string
|
||||
onSend: (message: string) => void
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({
|
||||
entryId,
|
||||
onSend,
|
||||
className,
|
||||
}) => {
|
||||
export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({ entryId, className }) => {
|
||||
const { t } = useTranslation("ai")
|
||||
const actionLanguage = useActionLanguage()
|
||||
const isInReadabilitySuccess = useEntryIsInReadabilitySuccess(entryId)
|
||||
|
|
@ -31,27 +23,6 @@ export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({
|
|||
enabled: true,
|
||||
})
|
||||
|
||||
const quickActions = useSmartQuickActions(summary.data || null, entryId)
|
||||
|
||||
const footerContent = summary.data && quickActions.length > 0 && (
|
||||
<div className="mt-6 space-y-3">
|
||||
<div className="text-text-secondary text-xs font-medium">
|
||||
{t("conversation_starters", { defaultValue: "Conversation starters" })}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{quickActions.map((action, index) => (
|
||||
<AIShortcutButton
|
||||
key={action.id}
|
||||
onClick={() => onSend(action.prompt)}
|
||||
animationDelay={index * 0.1}
|
||||
>
|
||||
{action.label}
|
||||
</AIShortcutButton>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<m.div
|
||||
initial={{ opacity: 0, y: 20, scale: 0.98 }}
|
||||
|
|
@ -64,7 +35,6 @@ export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({
|
|||
isLoading={summary.isLoading}
|
||||
className={className}
|
||||
title={t("ai_summary")}
|
||||
footerContent={footerContent}
|
||||
/>
|
||||
</m.div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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 を削除",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
"analytics.usage_trends": "使用趋势(最近30天)",
|
||||
"clear_chat": "清空对话",
|
||||
"clear_chat_message": "确定要清空所有历史记录吗?此操作将永久删除所有内容,包括所有聊天记录和数据,且无法撤销。",
|
||||
"conversation_starters": "对话建议",
|
||||
"customize_shortcuts": "自定义快捷方式",
|
||||
"customize_shortcuts_title": "自定义 AI 快捷方式",
|
||||
"delete_chat": "删除对话",
|
||||
|
|
|
|||
Loading…
Reference in New Issue