diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIDisplayAnalyticsPart.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIDisplayAnalyticsPart.tsx deleted file mode 100644 index 45b5282a7..000000000 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/AIDisplayAnalyticsPart.tsx +++ /dev/null @@ -1,283 +0,0 @@ -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@follow/components/ui/card/index.js" -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@follow/components/ui/table/index.js" -import dayjs from "dayjs" - -import type { AIDisplayAnalyticsTool } from "../../store/types" -import { withDisplayStateHandler } from "./share" -import { StatCard } from "./shared" - -type AnalyticsData = AIDisplayAnalyticsTool["output"]["analyticsData"] - -const formatTimeRange = (timeRange: string) => { - const timeRangeMap = { - "7d": "Last 7 days", - "30d": "Last 30 days", - "90d": "Last 90 days", - "1y": "Last year", - all: "All time", - } - return timeRangeMap[timeRange as keyof typeof timeRangeMap] || timeRange -} - -const FeedAnalytics = ({ data }: { data: AnalyticsData["feedData"] }) => { - if (!data) return null - - const { feed, analytics } = data - - return ( -
-
- - - -
- - {analytics && ( -
- - -
- )} -
- ) -} - -const SubscriptionAnalytics = ({ data }: { data: AnalyticsData["subscriptionStats"] }) => { - if (!data?.length) return null - - return ( -
-
- - s.feed).length} emoji="🟢" /> - acc + (s.analytics?.subscriptionCount || 0), 0) / data.length, - )} - emoji="📈" - /> -
- - - - Subscription Details - - - - - - Feed - Category - Subscribers - Updates/Week - - - - {data.slice(0, 10).map((sub) => ( - - {sub.feed?.title || "Unknown Feed"} - {sub.subscription?.category || "No Category"} - {sub.analytics?.subscriptionCount || 0} - {sub.analytics?.updatesPerWeek || 0} - - ))} - -
- {data.length > 10 && ( -
- Showing 10 of {data.length} subscriptions -
- )} -
-
-
- ) -} - -const ReadingAnalytics = ({ data }: { data: AnalyticsData["readingStats"] }) => { - if (!data?.length) return null - - const totalReads = data.reduce((acc, stat) => acc + stat.count, 0) - const averageReads = Math.round(totalReads / data.length) - - return ( -
-
- - - -
- - - - Recent Reading Activity - - - - - - Date - Reads - - - - {data.slice(0, 7).map((stat) => ( - - - {dayjs(stat.date).format("MMM DD, YYYY")} - - {stat.count} - - ))} - -
-
-
-
- ) -} - -const TrendingAnalytics = ({ data }: { data: AnalyticsData["trendingFeeds"] }) => { - if (!data?.length) return null - - return ( -
-
- - - acc + (feed.analytics?.view || 0), 0)} - emoji="👀" - /> -
- - - - Trending Feeds - - - - - - Feed - Subscribers - Updates/Week - Views - - - - {data.map((feed) => ( - - - {feed.feed?.title || "Unknown Feed"} - - {feed.analytics?.subscriptionCount || 0} - {feed.analytics?.updatesPerWeek || 0} - {feed.analytics?.view || 0} - - ))} - -
-
-
-
- ) -} - -const OverviewAnalytics = ({ data }: { data: AnalyticsData["overviewStats"] }) => { - if (!data) return null - - return ( -
-
- - - -
-
- ) -} - -const AIDisplayAnalyticsPartBase = ({ - output, -}: { - output: NonNullable -}) => { - const { analyticsData, analyticsType, timeRange, displayType, title } = output - - const renderAnalytics = () => { - switch (analyticsType) { - case "feed": { - return - } - case "subscription": { - return - } - case "reading": { - return - } - case "trending": { - return - } - case "overview": { - return - } - default: { - return
No analytics data available
- } - } - } - - return ( - - - - 📊 - - {title || `${analyticsType.charAt(0).toUpperCase() + analyticsType.slice(1)} Analytics`} - - - - {formatTimeRange(timeRange)} • Display type: {displayType} - - - {renderAnalytics()} - - ) -} - -export const AIDisplayAnalyticsPart = withDisplayStateHandler({ - title: "Analytics", - loadingDescription: "Fetching analytics data...", - errorTitle: "Analytics Error", - maxWidth: "max-w-full", -})(AIDisplayAnalyticsPartBase) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/index.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/index.ts index 0f5c9ebba..c2ce6aca7 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/index.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/displays/index.ts @@ -1,5 +1,4 @@ export { AIChainOfThought } from "./AIChainOfThought" -export { AIDisplayAnalyticsPart } from "./AIDisplayAnalyticsPart" export { AIDisplayEntriesPart } from "./AIDisplayEntriesPart" export { AIDisplayFeedPart } from "./AIDisplayFeedsPart" export { AIDisplaySubscriptionsPart } from "./AIDisplaySubscriptionsPart" diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx index 034058656..9f0580537 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx @@ -6,7 +6,6 @@ import type { ToolUIPart } from "ai" import * as React from "react" import type { - AIDisplayAnalyticsTool, AIDisplayEntriesTool, AIDisplayFeedTool, AIDisplayFlowTool, @@ -17,7 +16,6 @@ import type { import { useChatStatus } from "../../store/hooks" import { AIChainOfThought, - AIDisplayAnalyticsPart, AIDisplayEntriesPart, AIDisplayFeedPart, AIDisplaySubscriptionsPart, @@ -106,9 +104,6 @@ export const AIMessageParts: React.FC = React.memo( ) } - case "tool-displayAnalytics": { - return - } case "tool-displayEntries": { return } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/store/types.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/store/types.ts index 229d46048..aef04cc53 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/store/types.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/store/types.ts @@ -43,7 +43,6 @@ export interface AIChatContextBlocks { blocks: AIChatContextBlock[] } -export type AIDisplayAnalyticsTool = ToolWithState export type AIDisplayFeedTool = ToolWithState export type AIDisplayEntriesTool = ToolWithState export type AIDisplaySubscriptionsTool = ToolWithState