diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionComponent.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionComponent.tsx index f8d31700a..7517a788d 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionComponent.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionComponent.tsx @@ -35,7 +35,7 @@ const MentionTooltipContent = ({ mentionData.type === "date" && "bg-purple", )} > - + {displayName} @@ -76,6 +76,9 @@ const getMentionStyles = (type: MentionData["type"]) => { "hover:bg-purple/20 hover:border-purple/30", ) } + case "view": { + return cn(baseStyles) + } } } export const MentionComponent: React.FC = ({ mentionData, className }) => { @@ -100,7 +103,11 @@ export const MentionComponent: React.FC = ({ mentionData, - + @{displayName} diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionDropdown.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionDropdown.tsx index 4927d6476..5956e2996 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionDropdown.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/MentionDropdown.tsx @@ -109,7 +109,7 @@ const MentionSuggestionItem = React.memo( mention.type === "date" && "text-purple-500", )} > - + {/* Content */} diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/shared/MentionTypeIcon.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/shared/MentionTypeIcon.tsx index f2158366e..5568deede 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/shared/MentionTypeIcon.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/components/shared/MentionTypeIcon.tsx @@ -1,13 +1,19 @@ +import { getView } from "@follow/constants" import * as React from "react" import type { MentionType } from "../../types" interface MentionTypeIconProps { type: MentionType + value?: unknown className?: string } -export const MentionTypeIcon: React.FC = ({ type, className = "size-3" }) => { +export const MentionTypeIcon: React.FC = ({ + type, + value, + className = "size-3", +}) => { switch (type) { case "entry": { return @@ -21,6 +27,17 @@ export const MentionTypeIcon: React.FC = ({ type, classNam case "date": { return } + case "view": { + if (typeof value === "number") { + const viewDef = getView(value) + if (viewDef?.icon?.props?.className) { + return ( + + ) + } + } + return + } default: { return } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/useMentionSearchService.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/useMentionSearchService.ts index 1dc75ac54..046f07605 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/useMentionSearchService.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/useMentionSearchService.ts @@ -1,3 +1,4 @@ +import { getViewList } from "@follow/constants" import { useMemo } from "react" import { useTranslation } from "react-i18next" @@ -49,6 +50,24 @@ export const useMentionSearchService = () => { return results } + const views = getViewList() + const lowerQuery = trimmedQuery.toLowerCase() + + const firstView = views.find((view) => { + // @ts-expect-error + const viewName = t(view.name, { ns: "common" }).toLowerCase() + return viewName.includes(lowerQuery) || lowerQuery === "" + }) + + if (firstView) { + pushResult({ + id: `view-${firstView.view}`, + name: t(firstView.name, { ns: "common" }), + type: "view", + value: firstView.view, + }) + } + const dateSuggestions = buildDateMentions(trimmedQuery) const searchResults = search(trimmedQuery, undefined, 10) @@ -69,7 +88,7 @@ export const useMentionSearchService = () => { return results } - }, [buildDateMentions, search]) + }, [buildDateMentions, search, t]) return { searchMentions } } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/types.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/types.ts index 3f39222b8..fb3f26d7b 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/types.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/types.ts @@ -1,4 +1,4 @@ -export type MentionType = "entry" | "feed" | "date" | "category" +export type MentionType = "entry" | "feed" | "date" | "category" | "view" export type MentionLabelValue = string | number | boolean | MentionLabelDescriptor