fix(ai): restore ai summary card shown when chat panel closed
- Updated the modal's close logic to call `readyToClose()` before proceeding with the close action, ensuring that the animation state is properly managed. - This change enhances the user experience by preventing premature closure of the modal during animations. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js"
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { ReactNode } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { CopyButton } from "~/components/ui/button/CopyButton"
|
||||
import { Markdown } from "~/components/ui/markdown/Markdown"
|
||||
|
||||
interface AISummaryCardBaseProps {
|
||||
/** Summary content to display */
|
||||
content?: string | null
|
||||
/** Whether the summary is currently loading */
|
||||
isLoading?: boolean
|
||||
/** Additional className for the container */
|
||||
className?: string
|
||||
/** Custom header content (replaces default AI Summary header) */
|
||||
headerContent?: ReactNode
|
||||
/** Additional content to render below the summary */
|
||||
footerContent?: ReactNode
|
||||
/** Custom loading state component */
|
||||
loadingComponent?: ReactNode
|
||||
/** Custom empty state component */
|
||||
emptyComponent?: ReactNode
|
||||
/** Title text for the AI Summary header */
|
||||
title?: string
|
||||
/** Whether to show the copy button */
|
||||
showCopyButton?: boolean
|
||||
/** Whether to show the Ask AI button when there's content */
|
||||
showAskAIButton?: boolean
|
||||
/** Callback when Ask AI button is clicked */
|
||||
onAskAI?: () => void
|
||||
}
|
||||
|
||||
const DefaultLoadingState = () => (
|
||||
<div className="space-y-2">
|
||||
<div className="bg-material-ultra-thick h-3 w-full animate-pulse rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[92%] animate-pulse rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[85%] animate-pulse rounded-lg" />
|
||||
</div>
|
||||
)
|
||||
|
||||
const DefaultEmptyState = ({ message }: { message: string }) => (
|
||||
<div className="py-4 text-center">
|
||||
<i className="i-mingcute-document-line text-text-tertiary mb-2 text-2xl" />
|
||||
<p className="text-text-secondary text-sm">{message}</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
export const AISummaryCardBase: React.FC<AISummaryCardBaseProps> = ({
|
||||
content,
|
||||
isLoading = false,
|
||||
className,
|
||||
headerContent,
|
||||
footerContent,
|
||||
loadingComponent,
|
||||
emptyComponent,
|
||||
title = "AI Summary",
|
||||
showCopyButton = true,
|
||||
showAskAIButton = false,
|
||||
onAskAI,
|
||||
}) => {
|
||||
const { t } = useTranslation("app")
|
||||
|
||||
const hasContent = !isLoading && content
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"group relative overflow-hidden rounded-2xl border border-neutral-200/50 p-5 backdrop-blur-xl",
|
||||
"bg-gradient-to-b from-neutral-50/80 to-white/40 dark:from-neutral-900/80 dark:to-neutral-900/40",
|
||||
"dark:border-neutral-800/50",
|
||||
"shadow-[0_8px_32px_rgba(0,0,0,0.08)] dark:shadow-[0_8px_32px_rgba(0,0,0,0.3)]",
|
||||
isLoading &&
|
||||
"before:absolute before:inset-0 before:-z-10 before:animate-[pulse_2s_cubic-bezier(0.4,0,0.6,1)_infinite] before:bg-gradient-to-r before:from-purple-100/0 before:via-purple-300/10 before:to-purple-100/0 dark:before:from-purple-900/0 dark:before:via-purple-600/10 dark:before:to-purple-900/0",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{/* Animated background gradient */}
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 -z-10 bg-gradient-to-br opacity-50",
|
||||
"from-purple-100/20 via-transparent to-blue-100/20",
|
||||
"dark:from-purple-900/20 dark:to-blue-900/20",
|
||||
isLoading && "animate-[glow_4s_ease-in-out_infinite]",
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
{headerContent || (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Glowing AI icon */}
|
||||
<div className="center relative">
|
||||
<i
|
||||
className={cn(
|
||||
"i-mgc-ai-cute-re text-lg",
|
||||
isLoading
|
||||
? "text-purple-500/70 dark:text-purple-400/70"
|
||||
: "text-purple-600 dark:text-purple-400",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 rounded-full blur-sm",
|
||||
isLoading
|
||||
? "animate-[pulse_2s_infinite] bg-purple-400/30 dark:bg-purple-500/30"
|
||||
: "animate-pulse bg-purple-400/20 dark:bg-purple-500/20",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={cn(
|
||||
"bg-gradient-to-r bg-clip-text font-medium text-transparent",
|
||||
isLoading
|
||||
? "from-purple-500/70 to-blue-500/70 dark:from-purple-400/70 dark:to-blue-400/70"
|
||||
: "from-purple-600 to-blue-600 dark:from-purple-400 dark:to-blue-400",
|
||||
)}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{showAskAIButton && hasContent && onAskAI && (
|
||||
<MotionButtonBase
|
||||
onClick={onAskAI}
|
||||
className={cn(
|
||||
"flex h-7 items-center gap-1.5 rounded-lg px-3 text-sm font-medium",
|
||||
"bg-gradient-to-r from-purple-500/10 to-blue-500/10",
|
||||
"border border-purple-200/30 dark:border-purple-800/30",
|
||||
"text-purple-600 dark:text-purple-400",
|
||||
"hover:from-purple-500/20 hover:to-blue-500/20",
|
||||
"hover:border-purple-300/50 dark:hover:border-purple-700/50",
|
||||
"transition-all duration-200",
|
||||
"backdrop-blur-sm",
|
||||
"sm:opacity-0 sm:duration-300 sm:group-hover:translate-y-0 sm:group-hover:opacity-100",
|
||||
)}
|
||||
>
|
||||
<i className="i-mingcute-ai-line text-base" />
|
||||
<span>Ask AI</span>
|
||||
</MotionButtonBase>
|
||||
)}
|
||||
|
||||
{showCopyButton && hasContent && (
|
||||
<CopyButton
|
||||
value={content}
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"!bg-white/10 !text-purple-600 dark:!text-purple-400",
|
||||
"hover:!bg-white/20 dark:hover:!bg-neutral-800/30",
|
||||
"!border-purple-200/30 dark:!border-purple-800/30",
|
||||
"sm:opacity-0 sm:duration-300 sm:group-hover:translate-y-0 sm:group-hover:opacity-100",
|
||||
"backdrop-blur-sm",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<AutoResizeHeight className="mt-4 text-sm leading-relaxed text-neutral-700 dark:text-neutral-300">
|
||||
{isLoading ? (
|
||||
loadingComponent || <DefaultLoadingState />
|
||||
) : hasContent ? (
|
||||
<Markdown className="prose-sm prose-p:m-0 max-w-none">{String(content)}</Markdown>
|
||||
) : (
|
||||
emptyComponent || <DefaultEmptyState message={t("ai.summary_not_available")} />
|
||||
)}
|
||||
</AutoResizeHeight>
|
||||
|
||||
{/* Footer */}
|
||||
{footerContent}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { AISummaryCardBase } from "./AISummaryCardBase"
|
||||
@@ -90,15 +90,13 @@ export const ModalInternal = memo(function Modal({
|
||||
const setStack = useSetAtom(modalStackAtom)
|
||||
|
||||
// Animation controls
|
||||
const { animateController, playNoticeAnimation, playExitAnimation, isClosing } = useModalAnimate(
|
||||
!!isTop,
|
||||
item.id,
|
||||
)
|
||||
const { animateController, playNoticeAnimation, playExitAnimation, isClosing, readyToClose } =
|
||||
useModalAnimate(!!isTop, item.id)
|
||||
|
||||
// Simple dismiss logic
|
||||
const close = useEventCallback(async (forceClose = false) => {
|
||||
if (!canClose && !forceClose) return
|
||||
|
||||
readyToClose()
|
||||
try {
|
||||
if (CustomModalComponent) {
|
||||
// Custom modals handle their own animation
|
||||
|
||||
+27
-116
@@ -1,15 +1,12 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { AIShortcutButton } from "@follow/components/ui/ai-shortcut-button/index.js"
|
||||
import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js"
|
||||
import { usePrefetchSummary } from "@follow/store/summary/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { m } from "motion/react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useEntryIsInReadabilitySuccess } from "~/atoms/readability"
|
||||
import { useActionLanguage } from "~/atoms/settings/general"
|
||||
import { CopyButton } from "~/components/ui/button/CopyButton"
|
||||
import { Markdown } from "~/components/ui/markdown/Markdown"
|
||||
import { AISummaryCardBase } from "~/components/ui/ai-summary-card"
|
||||
|
||||
import { useSmartQuickActions } from "../../hooks/useSmartQuickActions"
|
||||
|
||||
@@ -19,14 +16,6 @@ interface EntrySummaryCardProps {
|
||||
className?: string
|
||||
}
|
||||
|
||||
const SummaryLoadingState = () => (
|
||||
<div className="space-y-2">
|
||||
<div className="bg-material-ultra-thick h-3 w-full animate-pulse rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[92%] animate-pulse rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[85%] animate-pulse rounded-lg" />
|
||||
</div>
|
||||
)
|
||||
|
||||
export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({
|
||||
entryId,
|
||||
onSend,
|
||||
@@ -44,117 +33,39 @@ export const EntrySummaryCard: React.FC<EntrySummaryCardProps> = ({
|
||||
|
||||
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 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={Spring.presets.smooth}
|
||||
className={cn(
|
||||
// Reuse AISummary visual patterns but optimized for chat context
|
||||
"group relative w-full max-w-2xl overflow-hidden rounded-2xl border p-6 backdrop-blur-xl",
|
||||
"bg-gradient-to-b from-neutral-50/80 to-white/40 dark:from-neutral-900/80 dark:to-neutral-900/40",
|
||||
"border-neutral-200/50 dark:border-neutral-800/50",
|
||||
"shadow-[0_8px_32px_rgba(0,0,0,0.08)] dark:shadow-[0_8px_32px_rgba(0,0,0,0.3)]",
|
||||
summary.isLoading &&
|
||||
"before:absolute before:inset-0 before:-z-10 before:animate-[pulse_2s_cubic-bezier(0.4,0,0.6,1)_infinite] before:bg-gradient-to-r before:from-purple-100/0 before:via-purple-300/10 before:to-purple-100/0 dark:before:from-purple-900/0 dark:before:via-purple-600/10 dark:before:to-purple-900/0",
|
||||
className,
|
||||
)}
|
||||
className="w-full max-w-2xl"
|
||||
>
|
||||
{/* Animated background gradient */}
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 -z-10 bg-gradient-to-br opacity-50",
|
||||
"from-purple-100/20 via-transparent to-blue-100/20",
|
||||
"dark:from-purple-900/20 dark:to-blue-900/20",
|
||||
summary.isLoading && "animate-[glow_4s_ease-in-out_infinite]",
|
||||
)}
|
||||
<AISummaryCardBase
|
||||
content={summary.data}
|
||||
isLoading={summary.isLoading}
|
||||
className={className}
|
||||
title={t("ai_summary")}
|
||||
footerContent={footerContent}
|
||||
/>
|
||||
|
||||
{/* Header with entry context */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="center relative">
|
||||
<i
|
||||
className={cn(
|
||||
"i-mgc-ai-cute-re text-lg",
|
||||
summary.isLoading
|
||||
? "text-purple-500/70 dark:text-purple-400/70"
|
||||
: "text-purple-600 dark:text-purple-400",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 rounded-full blur-sm",
|
||||
summary.isLoading
|
||||
? "animate-[pulse_2s_infinite] bg-purple-400/30 dark:bg-purple-500/30"
|
||||
: "animate-pulse bg-purple-400/20 dark:bg-purple-500/20",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={cn(
|
||||
"bg-gradient-to-r bg-clip-text font-medium text-transparent",
|
||||
summary.isLoading
|
||||
? "from-purple-500/70 to-blue-500/70 dark:from-purple-400/70 dark:to-blue-400/70"
|
||||
: "from-purple-600 to-blue-600 dark:from-purple-400 dark:to-blue-400",
|
||||
)}
|
||||
>
|
||||
{t("ai_summary", { defaultValue: "AI Summary" })}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{summary.data && (
|
||||
<CopyButton
|
||||
value={summary.data}
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"!bg-white/10 !text-purple-600 dark:!text-purple-400",
|
||||
"hover:!bg-white/20 dark:hover:!bg-neutral-800/30",
|
||||
"!border-purple-200/30 dark:!border-purple-800/30",
|
||||
"sm:opacity-0 sm:duration-300 sm:group-hover:translate-y-0 sm:group-hover:opacity-100",
|
||||
"backdrop-blur-sm",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Summary Content */}
|
||||
<AutoResizeHeight className="mt-4 text-sm leading-relaxed text-neutral-700 dark:text-neutral-300">
|
||||
{summary.isLoading ? (
|
||||
<SummaryLoadingState />
|
||||
) : summary.data ? (
|
||||
<div className="animate-in fade-in-0 duration-500">
|
||||
<Markdown className="prose-sm prose-p:m-0 max-w-none">{String(summary.data)}</Markdown>
|
||||
</div>
|
||||
) : (
|
||||
<div className="py-4 text-center">
|
||||
<i className="i-mgc-document-cute-re text-text-tertiary mb-2 text-2xl" />
|
||||
<p className="text-text-secondary text-sm">
|
||||
{t("summary_not_available", { defaultValue: "Summary not available" })}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</AutoResizeHeight>
|
||||
|
||||
{/* Smart Quick Actions */}
|
||||
{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>
|
||||
)}
|
||||
</m.div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -174,7 +174,6 @@ export const AIEntryLayout = memo(function AIEntryLayout() {
|
||||
return (
|
||||
<AIChatRoot wrapFocusable={false}>
|
||||
<AIEntryLayoutImpl />
|
||||
{/* AI Spline Button - available globally when floating AI chat is closed */}
|
||||
<AISplineButton />
|
||||
</AIChatRoot>
|
||||
)
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js"
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { usePrefetchSummary } from "@follow/store/summary/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useShowAISummary } from "~/atoms/ai-summary"
|
||||
import { useEntryIsInReadabilitySuccess } from "~/atoms/readability"
|
||||
import {
|
||||
AIChatPanelStyle,
|
||||
setAIPanelVisibility,
|
||||
useAIChatPanelStyle,
|
||||
useAIPanelVisibility,
|
||||
} from "~/atoms/settings/ai"
|
||||
import { useActionLanguage } from "~/atoms/settings/general"
|
||||
import { CopyButton } from "~/components/ui/button/CopyButton"
|
||||
import { Markdown } from "~/components/ui/markdown/Markdown"
|
||||
import { AISummaryCardBase } from "~/components/ui/ai-summary-card"
|
||||
|
||||
export function AISummary({ entryId }: { entryId: string }) {
|
||||
const { t } = useTranslation()
|
||||
@@ -16,6 +19,11 @@ export function AISummary({ entryId }: { entryId: string }) {
|
||||
const isInReadabilitySuccess = useEntryIsInReadabilitySuccess(entryId)
|
||||
const showAISummary = useShowAISummary(summarySetting)
|
||||
const actionLanguage = useActionLanguage()
|
||||
|
||||
// AI Chat panel state
|
||||
const aiChatPanelStyle = useAIChatPanelStyle()
|
||||
const isAIPanelVisible = useAIPanelVisibility()
|
||||
|
||||
const summary = usePrefetchSummary({
|
||||
actionLanguage,
|
||||
entryId,
|
||||
@@ -23,92 +31,29 @@ export function AISummary({ entryId }: { entryId: string }) {
|
||||
enabled: showAISummary,
|
||||
})
|
||||
|
||||
// Show Ask AI button when:
|
||||
// 1. Panel style is floating AND panel is not visible
|
||||
// 2. OR panel style is fixed (since fixed panel can be toggled)
|
||||
const shouldShowAskAI =
|
||||
(aiChatPanelStyle === AIChatPanelStyle.Floating && !isAIPanelVisible) ||
|
||||
aiChatPanelStyle === AIChatPanelStyle.Fixed
|
||||
|
||||
const handleAskAI = () => {
|
||||
setAIPanelVisibility(true)
|
||||
}
|
||||
|
||||
if (!showAISummary || (!summary.isLoading && !summary.data)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"group relative my-8 overflow-hidden rounded-2xl border border-neutral-200/50 p-5 backdrop-blur-xl",
|
||||
"bg-gradient-to-b from-neutral-50/80 to-white/40 dark:from-neutral-900/80 dark:to-neutral-900/40",
|
||||
"dark:border-neutral-800/50",
|
||||
|
||||
summary.isLoading &&
|
||||
"before:absolute before:inset-0 before:-z-10 before:animate-[pulse_2s_cubic-bezier(0.4,0,0.6,1)_infinite] before:bg-gradient-to-r before:from-purple-100/0 before:via-purple-300/10 before:to-purple-100/0 dark:before:from-purple-900/0 dark:before:via-purple-600/10 dark:before:to-purple-900/0",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 -z-10 bg-gradient-to-br opacity-50",
|
||||
"from-purple-100/20 via-transparent to-blue-100/20",
|
||||
"dark:from-purple-900/20 dark:to-blue-900/20",
|
||||
|
||||
summary.isLoading && "animate-[glow_4s_ease-in-out_infinite]",
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Glowing AI icon */}
|
||||
<div className="center relative">
|
||||
<i
|
||||
className={cn(
|
||||
"i-mgc-ai-cute-re text-lg",
|
||||
summary.isLoading
|
||||
? "text-purple-500/70 dark:text-purple-400/70"
|
||||
: "text-purple-600 dark:text-purple-400",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 rounded-full blur-sm",
|
||||
summary.isLoading
|
||||
? "animate-[pulse_2s_infinite] bg-purple-400/30 dark:bg-purple-500/30"
|
||||
: "animate-pulse bg-purple-400/20 dark:bg-purple-500/20",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={cn(
|
||||
"bg-gradient-to-r bg-clip-text font-medium text-transparent",
|
||||
summary.isLoading
|
||||
? "from-purple-500/70 to-blue-500/70 dark:from-purple-400/70 dark:to-blue-400/70"
|
||||
: "from-purple-600 to-blue-600 dark:from-purple-400 dark:to-blue-400",
|
||||
)}
|
||||
>
|
||||
{t("entry_content.ai_summary")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{summary.data && (
|
||||
<CopyButton
|
||||
value={summary.data}
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"!bg-white/10 !text-purple-600 dark:!text-purple-400",
|
||||
"hover:!bg-white/20 dark:hover:!bg-neutral-800/30",
|
||||
"!border-purple-200/30 dark:!border-purple-800/30",
|
||||
"sm:opacity-0 sm:duration-300 sm:group-hover:translate-y-0 sm:group-hover:opacity-100",
|
||||
"backdrop-blur-sm",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<AutoResizeHeight className="mt-4 text-sm leading-relaxed text-neutral-700 dark:text-neutral-300">
|
||||
{summary.isLoading ? (
|
||||
<div className="space-y-2">
|
||||
<div className="bg-material-ultra-thick h-3 w-full rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[92%] rounded-lg" />
|
||||
<div className="bg-material-ultra-thick h-3 w-[85%] rounded-lg" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="animate-in fade-in-0 duration-500">
|
||||
<Markdown className="prose-sm prose-p:m-0 max-w-none">{String(summary.data)}</Markdown>
|
||||
</div>
|
||||
)}
|
||||
</AutoResizeHeight>
|
||||
</div>
|
||||
<AISummaryCardBase
|
||||
content={summary.data}
|
||||
isLoading={summary.isLoading}
|
||||
className="my-8"
|
||||
title={t("entry_content.ai_summary")}
|
||||
showAskAIButton={shouldShowAskAI}
|
||||
onAskAI={handleAskAI}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
-2
@@ -203,8 +203,6 @@ const EntryContentImpl: Component<EntryContentProps> = ({
|
||||
</EntryScrollArea>
|
||||
<SourceContentPanel src={safeUrl ?? "#"} />
|
||||
</Focusable>
|
||||
|
||||
{/* <React.Suspense>{!isInPeekModal && <AISmartSidebar entryId={entryId} />}</React.Suspense> */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+7
@@ -7,6 +7,7 @@ import { cn } from "@follow/utils"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import { useCallback, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { AIChatPanelStyle, useAIChatPanelStyle } from "~/atoms/settings/ai"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { ShadowDOM } from "~/components/common/ShadowDOM"
|
||||
import type { TocRef } from "~/components/ui/markdown/components/Toc"
|
||||
@@ -19,6 +20,7 @@ import { BlockSliceAction } from "~/modules/ai-chat/store/slices/block.slice"
|
||||
import { EntryContentHTMLRenderer } from "~/modules/renderer/html"
|
||||
import { WrappedElementProvider } from "~/providers/wrapped-element-provider"
|
||||
|
||||
import { AISummary } from "../../AISummary"
|
||||
import { useEntryContent, useEntryMediaInfo } from "../../hooks"
|
||||
import { ContainerToc } from "../entry-content/accessories/ContainerToc"
|
||||
import { EntryRenderError } from "../entry-content/EntryRenderError"
|
||||
@@ -73,6 +75,9 @@ export const ArticleLayout: React.FC<ArticleLayoutProps> = ({
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.selectedText)
|
||||
}, [removeBlock])
|
||||
|
||||
const aiChatPanelStyle = useAIChatPanelStyle()
|
||||
|
||||
const shouldShowAISummary = aiChatPanelStyle === AIChatPanelStyle.Floating
|
||||
if (!entry) return null
|
||||
|
||||
return (
|
||||
@@ -89,6 +94,8 @@ export const ArticleLayout: React.FC<ArticleLayoutProps> = ({
|
||||
<WrappedElementProvider boundingDetection>
|
||||
<div className="mx-auto mb-32 mt-8 max-w-full cursor-auto text-[0.94rem]">
|
||||
<EntryTitleMetaHandler entryId={entryId} />
|
||||
|
||||
{shouldShowAISummary && <AISummary entryId={entryId} />}
|
||||
<ErrorBoundary fallback={EntryRenderError}>
|
||||
<ReadabilityNotice entryId={entryId} />
|
||||
{showTranscript ? (
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"activation.plan.title": "Upgrade Plan",
|
||||
"activation.plan.upgrade": "Upgrade",
|
||||
"activation.title": "Invitation Code",
|
||||
"ai.summary_not_available": "Summary not available",
|
||||
"app.copy_logo_svg": "Copy Logo SVG",
|
||||
"app.copy_logo_text_svg": "Copy Logo Text SVG",
|
||||
"app.toggle_sidebar": "Toggle Sidebar",
|
||||
|
||||
Reference in New Issue
Block a user