diff --git a/apps/desktop/src/renderer/src/modules/entry-content/AISummary.tsx b/apps/desktop/src/renderer/src/modules/entry-content/AISummary.tsx new file mode 100644 index 000000000..19a3dc06a --- /dev/null +++ b/apps/desktop/src/renderer/src/modules/entry-content/AISummary.tsx @@ -0,0 +1,120 @@ +import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js" +import { cn } from "@follow/utils/utils" +import { useTranslation } from "react-i18next" + +import { useShowAISummary } from "~/atoms/ai-summary" +import { useActionLanguage } from "~/atoms/settings/general" +import { CopyButton } from "~/components/ui/button/CopyButton" +import { useAuthQuery } from "~/hooks/common" +import { Queries } from "~/queries" +import { useEntry } from "~/store/entry" + +export function AISummary({ entryId }: { entryId: string }) { + const { t } = useTranslation() + const entry = useEntry(entryId) + const showAISummary = useShowAISummary(entry) + const actionLanguage = useActionLanguage() + const summary = useAuthQuery( + Queries.ai.summary({ + entryId, + language: actionLanguage, + }), + { + enabled: showAISummary, + refetchOnMount: false, + refetchOnWindowFocus: false, + meta: { + persist: true, + }, + }, + ) + + if (!showAISummary || (!summary.isLoading && !summary.data)) { + return null + } + + return ( +
+
+ +
+
+ {/* Glowing AI icon */} +
+ +
+
+ + {t("entry_content.ai_summary")} + +
+ + {summary.data && ( + + )} +
+ + + {summary.isLoading ? ( +
+
+
+
+
+ ) : ( +
{summary.data}
+ )} + +
+ ) +} diff --git a/apps/desktop/src/renderer/src/modules/entry-content/index.electron.tsx b/apps/desktop/src/renderer/src/modules/entry-content/index.electron.tsx index 22e94eaa0..e260e1651 100644 --- a/apps/desktop/src/renderer/src/modules/entry-content/index.electron.tsx +++ b/apps/desktop/src/renderer/src/modules/entry-content/index.electron.tsx @@ -23,6 +23,7 @@ import { useFeedById } from "~/store/feed" import { useInboxById } from "~/store/inbox" import { EntryContentHTMLRenderer } from "../renderer/html" +import { AISummary } from "./AISummary" import { EntryTimelineSidebar } from "./components/EntryTimelineSidebar" import { EntryTitle } from "./components/EntryTitle" import { SourceContentPanel } from "./components/SourceContentView" @@ -31,7 +32,6 @@ import { EntryHeader } from "./header" import { useFocusEntryContainerSubscriptions } from "./hooks" import type { EntryContentProps } from "./index.shared" import { - AISummary, ContainerToc, NoContent, ReadabilityAutoToggleEffect, diff --git a/apps/desktop/src/renderer/src/modules/entry-content/index.mobile.tsx b/apps/desktop/src/renderer/src/modules/entry-content/index.mobile.tsx index 44f71442d..3f52f3321 100644 --- a/apps/desktop/src/renderer/src/modules/entry-content/index.mobile.tsx +++ b/apps/desktop/src/renderer/src/modules/entry-content/index.mobile.tsx @@ -22,11 +22,12 @@ import { useInboxById } from "~/store/inbox" import { CornerPlayer } from "../player/corner-player" import { EntryContentHTMLRenderer } from "../renderer/html" +import { AISummary } from "./AISummary" import { EntryReadHistory } from "./components/EntryReadHistory" import { EntryTitle } from "./components/EntryTitle" import { SupportCreator } from "./components/SupportCreator" import { EntryHeader } from "./header" -import { AISummary, NoContent, RenderError, TitleMetaHandler } from "./index.shared" +import { NoContent, RenderError, TitleMetaHandler } from "./index.shared" import { EntryContentLoading } from "./loading" export interface EntryContentClassNames { diff --git a/apps/desktop/src/renderer/src/modules/entry-content/index.shared.tsx b/apps/desktop/src/renderer/src/modules/entry-content/index.shared.tsx index 6f6a76db1..22be07ce4 100644 --- a/apps/desktop/src/renderer/src/modules/entry-content/index.shared.tsx +++ b/apps/desktop/src/renderer/src/modules/entry-content/index.shared.tsx @@ -1,6 +1,5 @@ import { getViewport } from "@follow/components/hooks/useViewport.js" import { CircleProgress } from "@follow/components/icons/Progress.js" -import { AutoResizeHeight } from "@follow/components/ui/auto-resize-height/index.js" import { Button, MotionButtonBase } from "@follow/components/ui/button/index.js" import { LoadingWithIcon } from "@follow/components/ui/loading/index.jsx" import { RootPortal } from "@follow/components/ui/portal/index.jsx" @@ -14,27 +13,22 @@ import type { FC } from "react" import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react" import { useTranslation } from "react-i18next" -import { useShowAISummary } from "~/atoms/ai-summary" import { ReadabilityStatus, setReadabilityStatus, useEntryInReadabilityStatus, useEntryReadabilityContent, } from "~/atoms/readability" -import { useActionLanguage } from "~/atoms/settings/general" import { enableShowSourceContent } from "~/atoms/source-content" -import { CopyButton } from "~/components/ui/button/CopyButton" import { Toc } from "~/components/ui/markdown/components/Toc" import { useEntryReadabilityToggle } from "~/hooks/biz/useEntryActions" import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" -import { useAuthQuery } from "~/hooks/common/useBizQuery" import { getNewIssueUrl } from "~/lib/issues" import { useIsSoFWrappedElement, useWrappedElement, useWrappedElementSize, } from "~/providers/wrapped-element-provider" -import { Queries } from "~/queries" import { useEntry } from "~/store/entry" import { useFeedById } from "~/store/feed" import { useInboxById } from "~/store/inbox" @@ -314,76 +308,3 @@ const BackTopIndicator: Component = memo(({ className }) => { ) }) - -export function AISummary({ entryId }: { entryId: string }) { - const { t } = useTranslation() - const entry = useEntry(entryId) - const showAISummary = useShowAISummary(entry) - const actionLanguage = useActionLanguage() - const summary = useAuthQuery( - Queries.ai.summary({ - entryId, - language: actionLanguage, - }), - { - enabled: showAISummary, - refetchOnMount: false, - refetchOnWindowFocus: false, - meta: { - persist: true, - }, - }, - ) - - if (!showAISummary || (!summary.isLoading && !summary.data)) { - return null - } - - return ( -
- {/* Ambient gradient background effect */} -
- -
-
- {/* Glowing AI icon */} -
- -
-
- - {t("entry_content.ai_summary")} - -
- - {summary.data && ( - - )} -
- - - {summary.isLoading ? ( -
-
-
-
-
- ) : ( -
{summary.data}
- )} - -
- ) -} diff --git a/apps/desktop/tailwind.config.ts b/apps/desktop/tailwind.config.ts index 7b36d6606..cec2b1fe4 100644 --- a/apps/desktop/tailwind.config.ts +++ b/apps/desktop/tailwind.config.ts @@ -21,6 +21,12 @@ export default resolveConfig({ }, theme: { ...baseTwConfig.theme, + keyframes: { + glow: { + "0%, 100%": { opacity: "0.5" }, + "50%": { opacity: "0.7" }, + }, + }, extend: { ...baseTwConfig.theme?.extend, spacing: {