diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/context-bar/blocks/ContextBlock.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/context-bar/blocks/ContextBlock.tsx
index bfb014113..bc2f73986 100644
--- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/context-bar/blocks/ContextBlock.tsx
+++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/context-bar/blocks/ContextBlock.tsx
@@ -22,15 +22,17 @@ const BlockContainer: FC<{
onDisableClick?: () => void
content: ReactNode
readOnly?: boolean
-}> = memo(({ icon, label, onRemove, content, disabled, onDisableClick, readOnly }) => {
+ className?: string
+}> = memo(({ icon, label, onRemove, content, disabled, onDisableClick, readOnly, className }) => {
const isStringContent = typeof content === "string"
return (
{
if (disabled) {
@@ -49,13 +51,13 @@ const BlockContainer: FC<{
{icon && }
- {label && {label}}
+ {label && {label}}
{isStringContent ? (
-
{content}
+
{content}
) : (
-
{content}
+
{content}
)}
@@ -64,7 +66,7 @@ const BlockContainer: FC<{
diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatContextBar.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatContextBar.tsx
index d23304a4f..d1ae8cb1f 100644
--- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatContextBar.tsx
+++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/AIChatContextBar.tsx
@@ -1,5 +1,6 @@
+import { Popover, PopoverContent, PopoverTrigger } from "@follow/components/ui/popover/index.jsx"
import { cn } from "@follow/utils/utils"
-import { memo, useCallback, useEffect, useRef } from "react"
+import { memo, useCallback, useEffect, useMemo, useRef } from "react"
import { useGeneralSettingKey } from "~/atoms/settings/general"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
@@ -13,6 +14,9 @@ import { BlockSliceAction } from "../../store/slices/block.slice"
import { CombinedContextBlock, ContextBlock } from "../context-bar/blocks"
import { MentionButton } from "../context-bar/MentionButton"
+// Maximum number of context blocks to show before collapsing into "more" popover
+const MAX_VISIBLE_BLOCKS = 4
+
export const AIChatContextBar: Component = memo(({ className }) => {
const blocks = useAIChatStore()((s) => s.blocks)
const fileInputRef = useRef(null)
@@ -83,15 +87,41 @@ export const AIChatContextBar: Component = memo(({ className }) => {
const displayBlocks = useDisplayBlocks(blocks)
+ // Split blocks into visible and hidden based on MAX_VISIBLE_BLOCKS
+ const { visibleBlocks, hiddenBlocks } = useMemo(() => {
+ if (displayBlocks.length <= MAX_VISIBLE_BLOCKS) {
+ return { visibleBlocks: displayBlocks, hiddenBlocks: [] }
+ }
+ return {
+ visibleBlocks: displayBlocks.slice(0, MAX_VISIBLE_BLOCKS),
+ hiddenBlocks: displayBlocks.slice(MAX_VISIBLE_BLOCKS),
+ }
+ }, [displayBlocks])
+
+ const renderBlock = useCallback((item: (typeof displayBlocks)[number]) => {
+ if (item.kind === "combined") {
+ return (
+
+ )
+ }
+
+ return
+ }, [])
+
return (
-
+
{/* File Upload Button */}
)
})