diff --git a/packages/agent/src/activities/agent.ts b/packages/agent/src/activities/agent.ts index 7c8a4d96..a7dfce14 100644 --- a/packages/agent/src/activities/agent.ts +++ b/packages/agent/src/activities/agent.ts @@ -811,7 +811,12 @@ export async function initializeAgentSessionActivity(params: { const commentDetails: ShumaiMessageContext = { ...(userObj ? { user: userObj } : {}), ...(position ? { position } : {}), - ...(annotation ? { annotation: true } : {}), + ...(annotation + ? { + annotation: true, + annotations: c.annotation as unknown as ShumaiMessageContext['annotations'], + } + : {}), ...(attachedFiles.length > 0 ? { attachedFiles } : {}), } @@ -1190,6 +1195,7 @@ export async function getAssetActivity(assetId: string) { }, }) + let resolvedAsset = asset if (asset && asset.type === AssetType.version_stack) { const latestVersion = await prisma.asset.findFirst({ where: { parentId: asset.id, isDeleted: false }, @@ -1205,18 +1211,36 @@ export async function getAssetActivity(assetId: string) { }) if (latestVersion) { - return { + resolvedAsset = { ...latestVersion, project: latestVersion.project ?? asset.project, - } + } as typeof asset } } - return asset + if (!resolvedAsset) return null + + let url: string | undefined + if (resolvedAsset.storageKey?.key) { + try { + url = await s3Service.presign( + process.env.S3_BUCKET || 'shumai', + resolvedAsset.storageKey.key, + 'GET', + ) + } catch { + // Ignore presign errors + } + } + + return { + ...resolvedAsset, + url, + } } export async function getCommentActivity(commentId: string) { - return prisma.assetComment.findUnique({ + const comment = await prisma.assetComment.findUnique({ where: { id: commentId }, include: { attachments: { @@ -1224,6 +1248,34 @@ export async function getCommentActivity(commentId: string) { }, }, }) + + if (!comment) return null + + const attachmentsWithUrl = await Promise.all( + comment.attachments.map(async (att) => { + let url: string | undefined + if (att.asset?.storageKey?.key) { + try { + url = await s3Service.presign( + process.env.S3_BUCKET || 'shumai', + att.asset.storageKey.key, + 'GET', + ) + } catch { + // Ignore + } + } + return { + ...att, + asset: att.asset ? { ...att.asset, url } : null, + } + }), + ) + + return { + ...comment, + attachments: attachmentsWithUrl, + } } export async function getProjectAutofillFieldsActivity(projectId: string) { diff --git a/packages/agent/src/workflows/agent-chat.test.ts b/packages/agent/src/workflows/agent-chat.test.ts index 0316f523..77f7fd36 100644 --- a/packages/agent/src/workflows/agent-chat.test.ts +++ b/packages/agent/src/workflows/agent-chat.test.ts @@ -735,4 +735,35 @@ describe('Agent Chat Workflow', () => { }), ) }) + + it('should include annotations and second in direct chat messageContext', async () => { + const task = await prisma.workflowTask.create({ + data: { + type: 'chat', + status: 'pending', + assetId: 'a1', + payload: { + projectId: 'p1', + agent: { + prompt: 'Look at the highlighted zone', + agentId: 'b1', + sessionId: 'session-markup-1', + second: 14.2, + annotations: [{ type: 'rectangle', x: 20, y: 30, width: 40, height: 50 }], + }, + }, + }, + }) + + await agentChat(task) + + expect(mockActivities.agentChatActivity).toHaveBeenCalledWith( + expect.objectContaining({ + messageContext: expect.objectContaining({ + position: { type: 'time', seconds: 14.2 }, + annotations: [{ type: 'rectangle', x: 20, y: 30, width: 40, height: 50 }], + }), + }), + ) + }) }) diff --git a/packages/agent/src/workflows/agent-chat.ts b/packages/agent/src/workflows/agent-chat.ts index d58c09f9..2ccd8977 100644 --- a/packages/agent/src/workflows/agent-chat.ts +++ b/packages/agent/src/workflows/agent-chat.ts @@ -61,6 +61,8 @@ export async function agentChat(task: WorkflowTask): Promise { let commentAnnotation = false let commentCreatorId: string | undefined + let commentAnnotations: unknown[] | undefined + if (userCommentId) { userComment = await executeActivity(agentWorkerQueue, getCommentActivity, userCommentId) if (!userComment) { @@ -77,6 +79,7 @@ export async function agentChat(task: WorkflowTask): Promise { userComment.annotation.length > 0 ) { commentAnnotation = true + commentAnnotations = userComment.annotation } // 2. Create Placeholder Comment @@ -101,6 +104,17 @@ export async function agentChat(task: WorkflowTask): Promise { } else { prompt = payload.agent?.prompt || '' attachmentImageUrls = payload.agent?.imageUrls || [] + if (payload.agent?.second !== null && payload.agent?.second !== undefined) { + commentTimestamp = payload.agent.second + } + if ( + payload.agent?.annotations && + Array.isArray(payload.agent.annotations) && + payload.agent.annotations.length > 0 + ) { + commentAnnotation = true + commentAnnotations = payload.agent.annotations + } } // 3. Get Asset @@ -181,6 +195,7 @@ export async function agentChat(task: WorkflowTask): Promise { mediaType: attProxyType as ShumaiAttachedFileContext['mediaType'], mimeType: att.asset.mediaType || undefined, path: filePath || undefined, + url: (att.asset as { url?: string }).url || undefined, }) attachedAssets.push({ id: att.asset.id, name: att.asset.name, type: att.asset.type }) } @@ -205,6 +220,7 @@ export async function agentChat(task: WorkflowTask): Promise { mediaType: fileProxyType as ShumaiAttachedFileContext['mediaType'], mimeType: file.mediaType || undefined, path: filePath || undefined, + url: (file as { url?: string }).url || undefined, }) attachedAssets.push({ id: file.id, name: file.name, type: file.type }) } @@ -233,6 +249,7 @@ export async function agentChat(task: WorkflowTask): Promise { mediaType: refProxyType as ShumaiAttachedFileContext['mediaType'], mimeType: referencedAsset.mediaType || undefined, path: filePath || undefined, + url: (referencedAsset as { url?: string }).url || undefined, }) attachedAssets.push({ id: referencedAsset.id, @@ -286,7 +303,12 @@ export async function agentChat(task: WorkflowTask): Promise { : {}), currentAsset: currentAssetContext, ...(mediaPosition ? { position: mediaPosition } : {}), - ...(commentAnnotation ? { annotation: true } : {}), + ...(commentAnnotation + ? { + annotation: true, + annotations: commentAnnotations as ShumaiMessageContext['annotations'], + } + : {}), ...(attachedFiles.length > 0 ? { attachedFiles } : {}), ...(referencedAssets.length > 0 ? { referencedAssets } : {}), } diff --git a/packages/api/src/chat.test.ts b/packages/api/src/chat.test.ts index 8d8e4052..3cd1a260 100644 --- a/packages/api/src/chat.test.ts +++ b/packages/api/src/chat.test.ts @@ -148,6 +148,48 @@ describe('Chat API', () => { ) }) + it('accepts chat request with annotations, second, and attachmentIds', async () => { + vi.mocked(chatService.startOrContinueChat).mockResolvedValue({ + sessionId: 'session1', + taskId: 'task1', + }) + + vi.mocked(chatService.getNewSessionMessages).mockResolvedValue({ + messages: [], + lastEntryId: null, + }) + + vi.mocked(chatService.getChatWorkflowStatus).mockResolvedValue({ + status: 'completed', + output: {}, + }) + + const res = await app.request('/teams/team1/chat', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + agentId: 'agent1', + textPrompt: 'Review annotation', + attachedFiles: ['att1'], + annotations: [{ type: 'rectangle', x: 10, y: 20 }], + second: 5.5, + }), + }) + + expect(res.status).toBe(200) + expect(chatService.startOrContinueChat).toHaveBeenCalledWith( + expect.objectContaining({ id: 'user1' }), + 'team1', + expect.objectContaining({ + agentId: 'agent1', + textPrompt: 'Review annotation', + attachedFiles: ['att1'], + annotations: [{ type: 'rectangle', x: 10, y: 20 }], + second: 5.5, + }), + ) + }) + it('sends ping keep-alive SSE events when there are no new messages', async () => { vi.mocked(chatService.startOrContinueChat).mockResolvedValue({ sessionId: 'session1', diff --git a/packages/core/src/chat/chat.test.ts b/packages/core/src/chat/chat.test.ts index 7abae4ff..c8a1db58 100644 --- a/packages/core/src/chat/chat.test.ts +++ b/packages/core/src/chat/chat.test.ts @@ -988,5 +988,29 @@ describe('ChatService', () => { const msg2 = mapEntryToMessage(emptyEntry) expect(msg2).toBeNull() }) + + it('should forward annotations and second to workflow task payload', async () => { + const { user, team, project } = await setupBasicData() + + const { sessionId, taskId } = await chatService.startOrContinueChat(user, team.id, { + agentId: 'test-agent-id', + textPrompt: 'Check out this area', + projectId: project.id, + annotations: [{ type: 'rectangle', x: 10, y: 20, width: 30, height: 40 }], + second: 8.5, + }) + + expect(sessionId).toBeDefined() + expect(taskId).toBeDefined() + + const task = await prisma.workflowTask.findUnique({ + where: { id: taskId }, + }) + expect(task).toBeDefined() + expect(task?.payload?.agent?.second).toBe(8.5) + expect(task?.payload?.agent?.annotations).toEqual([ + { type: 'rectangle', x: 10, y: 20, width: 30, height: 40 }, + ]) + }) }) }) diff --git a/packages/core/src/chat/chat.ts b/packages/core/src/chat/chat.ts index 8c1c5b27..84f05dc3 100644 --- a/packages/core/src/chat/chat.ts +++ b/packages/core/src/chat/chat.ts @@ -199,6 +199,8 @@ export class ChatService { sessionId: passedSessionId, contextAssetId, projectId: passedProjectId, + second, + annotations, } = req // 1. Permissions verification @@ -401,6 +403,8 @@ export class ChatService { userId: user.id, isNewChat: !passedSessionId, hasAssetChanged, + second: second ?? undefined, + annotations: annotations ?? undefined, }, }, }, diff --git a/packages/db/src/prisma-json-types.ts b/packages/db/src/prisma-json-types.ts index 93e4bd6f..d27d21bd 100644 --- a/packages/db/src/prisma-json-types.ts +++ b/packages/db/src/prisma-json-types.ts @@ -305,6 +305,8 @@ declare global { assetIds?: string[] isNewChat?: boolean hasAssetChanged?: boolean + second?: number | null + annotations?: Record[] context?: import('@shumai/dtos').ShumaiMessageContext } diff --git a/packages/dtos/src/chat.ts b/packages/dtos/src/chat.ts index 541b4254..c1a912e3 100644 --- a/packages/dtos/src/chat.ts +++ b/packages/dtos/src/chat.ts @@ -10,15 +10,19 @@ export const chatRequestSchema = z sessionId: z.string().optional(), // ID of existing session (to continue) contextAssetId: z.string().optional(), // Active page context asset ID projectId: z.string().optional(), // Target project ID + second: z.number().nullable().optional(), + annotations: z.array(z.record(z.string(), z.unknown())).optional(), }) .superRefine((data, ctx) => { const hasPrompt = data.textPrompt && data.textPrompt.trim().length > 0 const hasFiles = data.attachedFiles && data.attachedFiles.length > 0 const hasAssets = data.assetIds && data.assetIds.length > 0 - if (!hasPrompt && !hasFiles && !hasAssets) { + const hasAnnotations = data.annotations && data.annotations.length > 0 + if (!hasPrompt && !hasFiles && !hasAssets && !hasAnnotations) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: 'At least one of textPrompt, attachedFiles, or assetIds must be provided.', + message: + 'At least one of textPrompt, attachedFiles, assetIds, or annotations must be provided.', path: ['textPrompt'], }) } @@ -63,6 +67,7 @@ export const shumaiAttachedFileContextSchema = z.object({ mediaType: z.enum(['image', 'video', 'pdf', 'audio', 'other']).optional(), mimeType: z.string().optional(), path: z.string().optional(), + url: z.string().optional(), }) export type ShumaiAttachedFileContext = z.infer @@ -85,6 +90,7 @@ export const shumaiMessageContextSchema = z.object({ currentAsset: shumaiAssetContextSchema.optional(), position: shumaiMediaPositionSchema.optional(), annotation: z.boolean().optional(), + annotations: z.array(z.record(z.string(), z.unknown())).optional(), attachedFiles: z.array(shumaiAttachedFileContextSchema).optional(), referencedAssets: z.array(shumaiAttachedFileContextSchema).optional(), }) diff --git a/packages/webui/components/chat/message-input.test.tsx b/packages/webui/components/chat/message-input.test.tsx new file mode 100644 index 00000000..7af9390f --- /dev/null +++ b/packages/webui/components/chat/message-input.test.tsx @@ -0,0 +1,143 @@ +// @vitest-environment happy-dom +import React from 'react' +import { cleanup, render, fireEvent, screen } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { ChatInput } from './message-input' +import { useMemberStore } from '@/ui/stores/members' + +describe('ChatInput mention navigation', () => { + afterEach(() => { + cleanup() + vi.clearAllMocks() + }) + + it('selects the correct member item when the Agents section is collapsed', async () => { + const queryClient = new QueryClient({ + defaultOptions: { queries: { retry: false } }, + }) + + useMemberStore.setState({ + members: [ + { id: 'agent-1', name: 'Bot Alice', type: 'agent', role: 'bot' }, + { id: 'agent-2', name: 'Bot Bob', type: 'agent', role: 'bot' }, + { id: 'user-1', name: 'Carol Human', type: 'human', role: 'editor' }, + { id: 'user-2', name: 'David Human', type: 'human', role: 'editor' }, + ], + loading: false, + fetchMembers: vi.fn(), + fetchProjectMembers: vi.fn(), + }) + + const mockSendMessage = vi.fn() + + const { container, getByText } = render( + + + , + ) + + const editor = container.querySelector('[contenteditable="true"]') as HTMLDivElement + expect(editor).toBeTruthy() + + // Type @ and set cursor selection in DOM + const textNode = document.createTextNode('@') + editor.appendChild(textNode) + const range = document.createRange() + range.setStart(textNode, 1) + range.setEnd(textNode, 1) + const sel = window.getSelection()! + sel.removeAllRanges() + sel.addRange(range) + + fireEvent.input(editor) + + // Mention list should appear with Agents and Members headers + expect(getByText('Agents')).toBeTruthy() + expect(getByText('Members')).toBeTruthy() + + // Collapse the Agents section + const agentsHeaderBtn = getByText('Agents').closest('button')! + fireEvent.click(agentsHeaderBtn) + + // Agents should no longer be rendered, but Members should be visible + expect(screen.queryByText('Bot Alice')).toBeNull() + const carolBtn = getByText('Carol Human').closest('button')! + expect(carolBtn).toBeTruthy() + + // Carol Human should have data-index="0" because bots are collapsed + expect(carolBtn.getAttribute('data-index')).toBe('0') + + // Hover over Carol Human + fireEvent.mouseEnter(carolBtn) + + // Press Enter to select Carol Human + fireEvent.keyDown(editor, { key: 'Enter' }) + + // Editor should now contain the mention badge for Carol Human (user-1) + const mentionNode = editor.querySelector('[data-type="mention"]') as HTMLElement + expect(mentionNode).toBeTruthy() + expect(mentionNode.dataset.id).toBe('user-1') + expect(mentionNode.textContent).toContain('Carol Human') + }) + + it('navigates with ArrowDown and ArrowUp after clicking to collapse the Agents section', async () => { + const queryClient = new QueryClient({ + defaultOptions: { queries: { retry: false } }, + }) + + useMemberStore.setState({ + members: [ + { id: 'agent-1', name: 'Bot Alice', type: 'agent', role: 'bot' }, + { id: 'agent-2', name: 'Bot Bob', type: 'agent', role: 'bot' }, + { id: 'user-1', name: 'Carol Human', type: 'human', role: 'editor' }, + { id: 'user-2', name: 'David Human', type: 'human', role: 'editor' }, + ], + loading: false, + fetchMembers: vi.fn(), + fetchProjectMembers: vi.fn(), + }) + + const mockSendMessage = vi.fn() + + const { container, getByText } = render( + + + , + ) + + const editor = container.querySelector('[contenteditable="true"]') as HTMLDivElement + expect(editor).toBeTruthy() + + // Type @ and set cursor selection + const textNode = document.createTextNode('@') + editor.appendChild(textNode) + const range = document.createRange() + range.setStart(textNode, 1) + range.setEnd(textNode, 1) + const sel = window.getSelection()! + sel.removeAllRanges() + sel.addRange(range) + + fireEvent.input(editor) + + // Click collapse on Agents + const agentsHeaderBtn = getByText('Agents').closest('button')! + fireEvent.mouseDown(agentsHeaderBtn) + fireEvent.click(agentsHeaderBtn) + + // Now press ArrowDown on editor to move from item 0 (Carol) to item 1 (David) + fireEvent.keyDown(editor, { key: 'ArrowDown' }) + + const davidBtn = getByText('David Human').closest('button')! + expect(davidBtn.className).toContain('bg-accent') + + // Press Enter to select David + fireEvent.keyDown(editor, { key: 'Enter' }) + + const mentionNode = editor.querySelector('[data-type="mention"]') as HTMLElement + expect(mentionNode).toBeTruthy() + expect(mentionNode.dataset.id).toBe('user-2') + expect(mentionNode.textContent).toContain('David Human') + }) +}) diff --git a/packages/webui/components/chat/message-input.tsx b/packages/webui/components/chat/message-input.tsx index 76311f1a..c254f4b4 100644 --- a/packages/webui/components/chat/message-input.tsx +++ b/packages/webui/components/chat/message-input.tsx @@ -19,6 +19,7 @@ import { Paperclip, Redo, Square, + Trash2, Undo, XIcon, } from 'lucide-react' @@ -27,10 +28,12 @@ import { Button } from '../ui/button' import { DrawAnnotation } from '../ui/icons' import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover' import { ProgressCircle } from '../ui/progress-circle' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip' import { formatTimecode } from '../viewers/video/utils' import { useUiStore } from '@/ui/stores/ui' +import { isImageFileName } from '@/ui/lib/media' -type UploadingFile = { +export type UploadingFile = { id: string // A unique ID for the file, e.g., timestamp + name file: File progress: number @@ -38,7 +41,16 @@ type UploadingFile = { error?: string } -interface ChatInputProps { +export interface AttachedFileMeta { + id: string + name: string + type: string + url?: string + mediaType?: string + mimeType?: string +} + +export interface ChatInputProps { projectId: string onSendMessage: ( text: string, @@ -46,16 +58,51 @@ interface ChatInputProps { annotations?: Annotation[], replyToId?: string | null, second?: number | null, + attachedFilesMeta?: AttachedFileMeta[], ) => void - replyingTo?: CommentInfo | null - onCancelReply?: () => void + + placeholder?: string initialText?: string - hideAnnotationControl?: boolean + value?: string + onChangeText?: (text: string) => void + disabled?: boolean + + // Mentions + allowMentions?: boolean disableMentions?: boolean + + // Local file attachments + allowAttachments?: boolean + + // Referenced workspace assets + workspaceAssets?: Array<{ id: string; name: string; type: string }> + onRemoveWorkspaceAsset?: (id: string) => void + + // Markup / Annotations + allowMarkup?: boolean + hideAnnotationControl?: boolean + canMarkup?: boolean + markupDisabledTooltip?: string + + // Timestamps + allowTimestamp?: boolean currentTime?: number frameRate?: number startTimecode?: string formatTimestamp?: (second: number) => string + + // Comment Thread Reply + replyingTo?: CommentInfo | null + onCancelReply?: () => void + + // Bottom action bar extras (e.g. Agent Selector) + bottomLeftExtra?: React.ReactNode + + // Streaming & Abort + isStreaming?: boolean + onAbort?: () => void + + // Callbacks onTyping?: () => void } @@ -80,13 +127,28 @@ export const ChatInput = React.forwardRef( onSendMessage, replyingTo, onCancelReply, + placeholder, initialText = '', - hideAnnotationControl = false, + value, + onChangeText, + disabled = false, + allowMentions, disableMentions = false, + allowAttachments = true, + workspaceAssets, + onRemoveWorkspaceAsset, + allowMarkup, + hideAnnotationControl = false, + canMarkup = true, + markupDisabledTooltip, + allowTimestamp = true, currentTime, frameRate, startTimecode, formatTimestamp, + bottomLeftExtra, + isStreaming = false, + onAbort, onTyping, }, ref, @@ -95,6 +157,10 @@ export const ChatInput = React.forwardRef( const [viewingFile, setViewingFile] = useState(null) const [isTimestampEnabled, setIsTimestampEnabled] = useState(true) + const effectiveAllowMentions = allowMentions ?? !disableMentions + const effectiveAllowMarkup = allowMarkup ?? !hideAnnotationControl + const effectiveAllowTimestamp = allowTimestamp + const { videoTimeDisplayMode } = useUiStore() const displayTime = React.useMemo(() => { if (currentTime === undefined) return '' @@ -145,6 +211,7 @@ export const ChatInput = React.forwardRef( const paddingLeftClass = React.useMemo(() => { if ( !isTimestampEnabled || + !effectiveAllowTimestamp || currentTime === undefined || (!formatTimestamp && !frameRate) || hasContent @@ -155,12 +222,21 @@ export const ChatInput = React.forwardRef( return 'pl-[120px]' } return 'pl-[85px]' - }, [isTimestampEnabled, currentTime, frameRate, hasContent, videoTimeDisplayMode]) + }, [ + isTimestampEnabled, + effectiveAllowTimestamp, + currentTime, + frameRate, + hasContent, + videoTimeDisplayMode, + formatTimestamp, + ]) const editorRef = useRef(null) const fileInputRef = useRef(null) const mentionRangeRef = useRef(null) const mentionListRef = useRef(null) + const isInternalUpdateRef = useRef(false) const { mutateAsync: uploadAttachment } = useMutation({ mutationFn: async ({ @@ -180,7 +256,16 @@ export const ChatInput = React.forwardRef( }) useEffect(() => { - if (initialText && editorRef.current) { + if (value !== undefined && editorRef.current) { + if (isInternalUpdateRef.current) { + isInternalUpdateRef.current = false + return + } + if (editorRef.current.innerText !== value) { + editorRef.current.innerText = value + setHasContent(!!value.trim()) + } + } else if (initialText && editorRef.current) { editorRef.current.innerText = initialText setHasContent(!!initialText.trim()) // Focus and move cursor to end @@ -192,7 +277,7 @@ export const ChatInput = React.forwardRef( sel?.removeAllRanges() sel?.addRange(range) } - }, [initialText]) + }, [value, initialText]) // Focus editor when replyingTo becomes truthy useEffect(() => { @@ -254,10 +339,13 @@ export const ChatInput = React.forwardRef( const handleInput = () => { if (!editorRef.current) return - setHasContent(!!editorRef.current.innerText.trim()) + const text = editorRef.current.innerText || '' + setHasContent(!!text.trim()) + isInternalUpdateRef.current = true + onChangeText?.(text) onTyping?.() - if (disableMentions) { + if (!effectiveAllowMentions) { setShowMentionList(false) mentionRangeRef.current = null return @@ -337,13 +425,17 @@ export const ChatInput = React.forwardRef( setShowMentionList(false) mentionRangeRef.current = null setHasContent(true) + const currentText = editorRef.current.innerText || '' + isInternalUpdateRef.current = true + onChangeText?.(currentText) + onTyping?.() editorRef.current.focus() } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.nativeEvent.isComposing) return - if (showMentionList && filteredEntities.length > 0) { + if (showMentionList && effectiveAllowMentions && filteredEntities.length > 0) { if (e.key === 'ArrowUp') { e.preventDefault() setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : filteredEntities.length - 1)) @@ -444,6 +536,18 @@ export const ChatInput = React.forwardRef( .map((f) => f.attachmentId) .filter((id): id is string => !!id) + const successfulAttachedFilesMeta: AttachedFileMeta[] = uploadingFiles + .filter((f) => !f.error && !!f.attachmentId) + .map((f) => ({ + id: f.attachmentId!, + name: f.file.name, + type: f.file.type, + url: + f.file.type.startsWith('image/') || isImageFileName(f.file.name) + ? URL.createObjectURL(f.file) + : undefined, + })) + // Serialize content let processedText = '' editorRef.current.childNodes.forEach((node) => { @@ -466,20 +570,31 @@ export const ChatInput = React.forwardRef( processedText = processedText.trim() - // Allow sending if annotations exist, even if text is empty - if (!processedText && successfulAttachmentIds.length === 0 && annotations.length === 0) return + const hasWorkspaceAssets = (workspaceAssets?.length ?? 0) > 0 + + // Allow sending if annotations, attachments, or workspace assets exist, even if text is empty + if ( + !processedText && + successfulAttachmentIds.length === 0 && + annotations.length === 0 && + !hasWorkspaceAssets + ) + return onSendMessage( processedText, successfulAttachmentIds, annotations, replyingTo?.id, - isTimestampEnabled ? currentTime : undefined, + effectiveAllowTimestamp && isTimestampEnabled ? currentTime : undefined, + successfulAttachedFilesMeta, ) // Reset editor editorRef.current.innerHTML = '' setHasContent(false) + isInternalUpdateRef.current = true + onChangeText?.('') setUploadingFiles([]) setViewingFile(null) setIsDrawing(false) @@ -490,13 +605,18 @@ export const ChatInput = React.forwardRef( const isUploading = uploadingFiles.some((f) => !f.attachmentId && !f.error) const hasSuccessfulUploads = uploadingFiles.some((f) => !!f.attachmentId) - const canSend = hasContent || hasSuccessfulUploads || annotations.length > 0 - const showUpperPart = uploadingFiles.length > 0 || !!replyingTo + const hasWorkspaceAssets = (workspaceAssets?.length ?? 0) > 0 + const effectiveDisabled = disabled || isStreaming + const canSend = + (hasContent || hasSuccessfulUploads || annotations.length > 0 || hasWorkspaceAssets) && + !effectiveDisabled + const showUpperPart = + (workspaceAssets && workspaceAssets.length > 0) || uploadingFiles.length > 0 || !!replyingTo return (
{showMentionList && + effectiveAllowMentions && (membersLoading || filteredAgents.length > 0 || filteredHumans.length > 0) && ( -
+
e.preventDefault()} + className="absolute bottom-full left-4 mb-2 w-64 rounded-xl shadow-lg border border-border overflow-hidden z-20 bg-popover text-popover-foreground animate-in fade-in slide-in-from-bottom-2 duration-200" + >
{membersLoading ? (
@@ -545,12 +669,15 @@ export const ChatInput = React.forwardRef( {filteredAgents.length > 0 && ( <> {!collapsedSections.users && filteredHumans.map((item, index) => { - const actualIndex = - (collapsedSections.bots ? 0 : filteredAgents.length) + index + const agentOffset = collapsedSections.bots ? 0 : filteredAgents.length + const actualIndex = index + agentOffset return ( + )} +
+ ))} +
+ )} + + {/* Replying banner */} {replyingTo && (
@@ -662,6 +825,7 @@ export const ChatInput = React.forwardRef(
)} + {/* Local file uploads thumbnail strip */} {uploadingFiles.length > 0 && (
{uploadingFiles.map((upload) => ( @@ -687,7 +851,7 @@ export const ChatInput = React.forwardRef(
@@ -705,24 +869,29 @@ export const ChatInput = React.forwardRef( onClick={() => editorRef.current?.focus()} className="w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto" > - {isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && ( -
{ - e.stopPropagation() - editorRef.current?.focus() - }} - className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text" - > - {displayTime} -
- )} + {effectiveAllowTimestamp && + isTimestampEnabled && + currentTime !== undefined && + (frameRate !== undefined || formatTimestamp !== undefined) && ( +
{ + e.stopPropagation() + editorRef.current?.focus() + }} + className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text" + > + {displayTime} +
+ )}
@@ -818,59 +987,104 @@ export const ChatInput = React.forwardRef(
) : ( -
- - {currentTime !== undefined && frameRate !== undefined && ( - - )} - - {!hideAnnotationControl && ( - +
+ {bottomLeftExtra} + {allowAttachments && ( + <> + + + )} + {effectiveAllowTimestamp && + currentTime !== undefined && + (frameRate !== undefined || formatTimestamp !== undefined) && ( + + )} + {effectiveAllowMarkup && + (canMarkup ? ( + + ) : ( + + + + + + + + +

+ {markupDisabledTooltip || m.markup_not_supported_for_this_file()} +

+
+
+
+ ))}
)} - + {isStreaming ? ( + + ) : ( + + )}
{viewingFile && ( diff --git a/packages/webui/components/chatbot-sidebar.test.tsx b/packages/webui/components/chatbot-sidebar.test.tsx index bebc1040..bce84483 100644 --- a/packages/webui/components/chatbot-sidebar.test.tsx +++ b/packages/webui/components/chatbot-sidebar.test.tsx @@ -6,6 +6,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { ChatbotSidebar } from './chatbot-sidebar' import { useChatbotStore, AGENT_PREFERENCE_STORAGE_KEY } from '@/ui/stores/chatbot' import { client } from '@/ui/api/client' +import type { ChatMessage } from '@shumai/dtos' const localStorageMock = (() => { let store: Record = {} @@ -190,4 +191,281 @@ describe('ChatbotSidebar - Agent Selection & Preference Persistence', () => { expect(localStorage.getItem(AGENT_PREFERENCE_STORAGE_KEY)).toBeNull() }) }) + + it('renders user messages with markup badge, timestamp, and attachments and triggers onSelectMessage on click when matched', async () => { + vi.mocked(client.api.projects[':projectId']['chat-agents'].$get).mockResolvedValue({ + ok: true, + json: async () => [{ id: 'agent-1', name: 'Agent 1', type: 'chat', enabled: true }], + } as unknown as Awaited< + ReturnType<(typeof client.api.projects)[':projectId']['chat-agents']['$get']> + >) + + const mockSelectMessage = vi.fn() + + const mockMessage = { + id: 'msg-1', + role: 'custom', + customType: 'shumai_message', + content: 'Fix the color in this scene', + details: { + annotation: true, + annotations: [{ type: 'rectangle', x: 5, y: 10 }], + position: { type: 'time', seconds: 15 }, + currentAsset: { id: 'file-123', name: 'video.mp4', type: 'file' }, + attachedFiles: [ + { id: 'att-1', name: 'color-ref.png', type: 'image', mediaType: 'image/png' }, + ], + }, + } as unknown as ChatMessage + + useChatbotStore.setState({ + messages: [mockMessage], + }) + + const { getByText } = render( + + + , + ) + + expect(getByText('Fix the color in this scene')).toBeTruthy() + expect(getByText('00:15')).toBeTruthy() + expect(getByText('color-ref.png')).toBeTruthy() + + const msgCardInner = getByText('Fix the color in this scene').closest('.bg-primary') + expect(msgCardInner?.className).not.toContain('ring-2') + + const msgCard = getByText('Fix the color in this scene').closest('div') + msgCard?.click() + + expect(mockSelectMessage).toHaveBeenCalledWith(mockMessage) + }) + + it('renders selected message card with border-blue-500 instead of ring when selectedMessageId matches', async () => { + const mockMessage = { + id: 'msg-selected', + role: 'custom', + customType: 'shumai_message', + content: 'Selected message content', + details: { + position: { type: 'time', seconds: 10 }, + currentAsset: { id: 'file-123', name: 'video.mp4', type: 'file' }, + }, + } as unknown as ChatMessage + + useChatbotStore.setState({ + messages: [mockMessage], + }) + + const { getByText } = render( + + + , + ) + + const cardInner = getByText('Selected message content').closest('.bg-primary') + expect(cardInner?.className).toContain('border-blue-500') + expect(cardInner?.className).not.toContain('ring') + }) + + it('does not trigger onSelectMessage on click when currentAsset does not match', async () => { + vi.mocked(client.api.projects[':projectId']['chat-agents'].$get).mockResolvedValue({ + ok: true, + json: async () => [{ id: 'agent-1', name: 'Agent 1', type: 'chat', enabled: true }], + } as unknown as Awaited< + ReturnType<(typeof client.api.projects)[':projectId']['chat-agents']['$get']> + >) + + const mockSelectMessage = vi.fn() + + const mockMessage = { + id: 'msg-2', + role: 'custom', + customType: 'shumai_message', + content: 'Other file comment', + details: { + annotation: true, + annotations: [{ type: 'rectangle', x: 5, y: 10 }], + position: { type: 'time', seconds: 20 }, + currentAsset: { id: 'other-file-456', name: 'other.mp4', type: 'file' }, + }, + } as unknown as ChatMessage + + useChatbotStore.setState({ + messages: [mockMessage], + }) + + const { getByText } = render( + + + , + ) + + const msgCard = getByText('Other file comment').closest('div') + msgCard?.click() + + expect(mockSelectMessage).not.toHaveBeenCalled() + }) + + it('renders full-width message card with inline badges, attachments and assets sections', async () => { + vi.mocked(client.api.projects[':projectId']['chat-agents'].$get).mockResolvedValue({ + ok: true, + json: async () => [{ id: 'agent-1', name: 'Agent 1', type: 'chat', enabled: true }], + } as unknown as Awaited< + ReturnType<(typeof client.api.projects)[':projectId']['chat-agents']['$get']> + >) + + const mockMessage = { + id: 'msg-full', + role: 'custom', + customType: 'shumai_message', + content: 'Review this scene carefully', + details: { + annotation: true, + annotations: [ + { + type: 'box', + color: '#ff0000', + points: [ + [0, 0], + [10, 10], + ], + }, + ], + position: { type: 'time', seconds: 45 }, + currentAsset: { id: 'file-123', name: 'clip.mp4', type: 'file' }, + attachedFiles: [ + { id: 'att-1', name: 'reference-mood.jpg', type: 'image', mediaType: 'image/jpeg' }, + ], + referencedAssets: [ + { id: 'asset-ref-1', name: 'Storyboard.pdf', type: 'file' }, + { id: 'asset-ref-2', name: 'Audio Stems', type: 'folder' }, + ], + }, + } as unknown as ChatMessage + + useChatbotStore.setState({ + messages: [mockMessage], + }) + + const { getByText } = render( + + + , + ) + + // Inline text and timestamp + expect(getByText('Review this scene carefully')).toBeTruthy() + expect(getByText('00:45')).toBeTruthy() + + // Attachments section + expect(getByText('Attachments')).toBeTruthy() + expect(getByText('reference-mood.jpg')).toBeTruthy() + + // Assets section + expect(getByText('Assets')).toBeTruthy() + expect(getByText('Storyboard.pdf')).toBeTruthy() + expect(getByText('Audio Stems')).toBeTruthy() + + // Card should be full width (w-full) + const cardEl = getByText('Review this scene carefully').closest('.bg-primary') + expect(cardEl?.className).toContain('w-full') + }) + + it('asks for confirmation before deleting a session and deletes when confirmed', async () => { + const mockDeleteSession = vi.fn() + const originalDeleteSession = useChatbotStore.getState().deleteSession + useChatbotStore.setState({ + isHistoryMode: true, + historySessions: [ + { + id: 'sess-1', + agentId: 'agent-1', + userId: 'user-1', + assetId: 'asset-1', + userCommentId: null, + name: 'Important Chat', + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + }, + ], + deleteSession: mockDeleteSession, + }) + + const { useTeamContextStore } = await import('@/ui/stores/team-context') + useTeamContextStore.setState({ teamId: 'team-123' }) + + window.confirm = vi.fn() + const confirmSpy = vi.spyOn(window, 'confirm') + + // 1. User cancels confirmation + confirmSpy.mockReturnValue(false) + const { getByTitle } = render( + + + , + ) + + const deleteBtn = getByTitle('Delete Session') + deleteBtn.click() + expect(confirmSpy).toHaveBeenCalled() + expect(mockDeleteSession).not.toHaveBeenCalled() + + // 2. User confirms deletion + confirmSpy.mockReturnValue(true) + deleteBtn.click() + expect(mockDeleteSession).toHaveBeenCalledWith('team-123', 'sess-1') + + confirmSpy.mockRestore() + useChatbotStore.setState({ deleteSession: originalDeleteSession }) + }) + + it('renders thinking_level_change messages properly in the chat log', () => { + const mockThinkingChangeMsg = { + id: 'think-1', + role: 'thinking_level_change', + content: 'Thinking level changed to high', + timestamp: Date.now(), + } as unknown as ChatMessage + + useChatbotStore.setState({ + messages: [mockThinkingChangeMsg], + }) + + const { getByText } = render( + + + , + ) + + expect(getByText('Thinking level changed to high')).toBeTruthy() + }) + + it('disables message input when teamId is not available', async () => { + const { useTeamContextStore } = await import('@/ui/stores/team-context') + useTeamContextStore.setState({ teamId: null, projectTeamMap: {} }) + useChatbotStore.setState({ selectedAgentId: 'agent-1' }) + + const { container } = render( + + + , + ) + + const inputArea = container.querySelector('[contenteditable="false"]') + expect(inputArea).toBeTruthy() + expect(inputArea?.getAttribute('contenteditable')).toBe('false') + }) }) diff --git a/packages/webui/components/chatbot-sidebar.tsx b/packages/webui/components/chatbot-sidebar.tsx index 0532671b..00ca2ca3 100644 --- a/packages/webui/components/chatbot-sidebar.tsx +++ b/packages/webui/components/chatbot-sidebar.tsx @@ -11,31 +11,58 @@ import { cn } from '@/ui/lib/utils' import { m } from '@/ui/paraglide/messages.js' import { useChatbotStore } from '@/ui/stores/chatbot' import { useTeamContextStore } from '@/ui/stores/team-context' +import { useUiStore } from '@/ui/stores/ui' import { useDroppable } from '@dnd-kit/react' -import type { ChatMessage, ShumaiMessageContext } from '@shumai/dtos' +import type { AssetInfo, ChatMessage, ShumaiMessageContext } from '@shumai/dtos' import { useQuery, useQueryClient } from '@tanstack/react-query' import { ArrowLeft, - ArrowUp, Bot, Brain, ChevronDown, + Download, + FileIcon, + Folder, History, Loader2, Plus, Trash2, Wrench, + XIcon, } from 'lucide-react' -import { useCallback, useEffect, useRef } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import Markdown from 'react-markdown' import { formatTimeAgo } from '../lib/time' +import { ChatInput } from './chat/message-input' +import { DrawAnnotation } from './ui/icons' +import { formatTimecode } from './viewers/video/utils' +import { isImageFileName } from '@/ui/lib/media' interface ChatbotSidebarProps { projectId: string contextAssetId?: string + file?: AssetInfo | null + currentTime?: number + frameRate?: number + startTimecode?: string + formatTimestamp?: (second: number) => string + onTyping?: () => void + onSelectMessage?: (message: ChatMessage) => void + selectedMessageId?: string | null } -export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProps) { +export function ChatbotSidebar({ + projectId, + contextAssetId, + file, + currentTime, + frameRate, + startTimecode, + formatTimestamp, + onTyping, + onSelectMessage, + selectedMessageId, +}: ChatbotSidebarProps) { const { isHistoryMode, setIsHistoryMode, @@ -58,6 +85,8 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp } = useChatbotStore() const { teamId, ensureTeamIdForProject } = useTeamContextStore() + const { videoTimeDisplayMode } = useUiStore() + const [previewImage, setPreviewImage] = useState<{ url: string; name: string } | null>(null) useEffect(() => { if (projectId) { @@ -187,21 +216,6 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp queryClient.invalidateQueries({ queryKey: ['projects'] }) }, [queryClient]) - const handleSend = () => { - if (!inputText.trim() || isStreaming || !teamId) return - sendMessage(teamId, inputText, projectId, contextAssetId, handleAssetMutation) - setInputText('') - } - - const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.nativeEvent.isComposing) return - - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault() - handleSend() - } - } - const getMessageText = (content: unknown): string => { if (typeof content === 'string') return content if (Array.isArray(content)) { @@ -224,29 +238,221 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp const renderMessage = (msg: ChatMessage) => { switch (msg.role as string) { - case 'user': { + case 'user': + case 'custom': { const msgObj = msg as unknown as Record - return ( -
-
- {getMessageText(msgObj.content)} + if (msg.role === 'custom' && msgObj.customType === 'context_display_info') { + const details = msgObj.details as + | { assets?: Array<{ id: string; name: string; type: string }> } + | undefined + const assets = details?.assets || [] + if (assets.length === 0) return null + return ( +
+
{m.assets_added_to_context()}
+
    + {assets.map((asset) => ( +
  • + {asset.name} ({asset.type}) +
  • + ))} +
+ ) + } + if (msg.role === 'user' || msgObj.customType === 'shumai_message') { + const details = msgObj.details as ShumaiMessageContext | undefined + const referencedAssets = details?.referencedAssets || [] + const attachedFiles = details?.attachedFiles || [] + const position = details?.position + const hasAnnotations = + details?.annotation || (details?.annotations && details.annotations.length > 0) + const isCurrentAssetMatch = + !details?.currentAsset?.id || + (contextAssetId && details.currentAsset.id === contextAssetId) || + (file?.id && details.currentAsset.id === file.id) + const isSelected = selectedMessageId === msg.id + let timeStr = '' + if (position?.type === 'time') { + if (formatTimestamp) { + timeStr = formatTimestamp(position.seconds) + } else if (frameRate) { + const frameIndex = Math.round(position.seconds * frameRate) + timeStr = formatTimecode(frameIndex, frameRate, videoTimeDisplayMode, startTimecode) + } else { + const mins = Math.floor(position.seconds / 60) + const secs = Math.floor(position.seconds % 60) + timeStr = `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}` + } + } else if (position?.type === 'page') { + timeStr = m.page_prefix({ page: position.page }) + } + const messageText = getMessageText(msgObj.content) + const hasAttachmentsOrAssets = attachedFiles.length > 0 || referencedAssets.length > 0 + const handleCardClick = () => { + if (isCurrentAssetMatch && onSelectMessage) { + onSelectMessage(msg) + } + } + return ( +
+
+
+ {hasAnnotations && ( + + + + )} + {position && ( + + {timeStr} + + )} + {messageText && {messageText}} +
+ + {attachedFiles.length > 0 && ( +
+
+ {m.attachments()} +
+
+ {attachedFiles.map((att) => { + const name = att.name || 'file' + const isImage = + isImageFileName(name) || + att.mediaType === 'image' || + att.mimeType?.startsWith('image/') + return ( +
{ + e.stopPropagation() + if (att.url) { + if (isImage) { + setPreviewImage({ url: att.url, name }) + } else { + window.open(att.url, '_blank', 'noreferrer') + } + } + }} + > + {isImage && att.url ? ( +
+ {name} +
+ ) : ( + + )} +
+

+ {name} +

+
+ {att.url && ( + e.stopPropagation()} + title={m.download()} + > + + + )} +
+ ) + })} +
+
+ )} + + {referencedAssets.length > 0 && ( +
+
+ {m.assets()} +
+
+ {referencedAssets.map((asset) => ( +
+
+ {asset.type === 'folder' ? ( + + ) : ( + + )} + + {asset.name} + +
+ + {asset.type} + +
+ ))} +
+
+ )} +
+
+ ) + } + const systemContent = msgObj.content || '' + return ( +
+ {getMessageText(systemContent)}
) } - case 'assistant': { const msgObj = msg as unknown as Record const content = msgObj.content as unknown[] if (!content) return null - const renderedBlocks: React.ReactNode[] = [] - content.forEach((block: unknown, idx: number) => { if (!block || typeof block !== 'object') return - const b = block as unknown as Record - switch (b.type) { case 'text': { const text = b.text @@ -357,9 +563,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp } } }) - if (renderedBlocks.length === 0) return null - let shouldShowFooter = false if (content.length > 0) { const lastBlock = content[content.length - 1] @@ -372,7 +576,6 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp } } } - return (
{renderedBlocks}
@@ -384,7 +587,6 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
) } - case 'toolResult': { return (
) } - - case 'thinking_level_change': - case 'custom': { + case 'thinking_level_change': { const msgObj = msg as unknown as Record - if (msgObj.customType === 'shumai_message') { - const details = msgObj.details as ShumaiMessageContext | undefined - const referencedAssets = details?.referencedAssets || [] - return ( -
- {referencedAssets.length > 0 && ( -
-
{m.assets_added_to_context()}
-
    - {referencedAssets.map((asset) => ( -
  • - {asset.name}{' '} - ({asset.type}) -
  • - ))} -
-
- )} -
- {getMessageText(msgObj.content)} -
-
- ) - } - - if (msgObj.customType === 'context_display_info') { - const details = msgObj.details as - | { assets?: Array<{ id: string; name: string; type: string }> } - | undefined - const assets = details?.assets || [] - if (assets.length === 0) return null - return ( -
-
{m.assets_added_to_context()}
-
    - {assets.map((asset) => ( -
  • - {asset.name} ({asset.type}) -
  • - ))} -
-
- ) - } - const systemContent = msgObj.content || '' return (
) } - default: return null } @@ -477,92 +628,106 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
- {m.chatbot_drag_drop_hint() || 'Drop assets here'} + {m.chatbot_drag_drop_hint()}
)} - {/* Header section */} -
- {isHistoryMode ? ( - <> -
- {m.history()} -
+ {/* Header */} +
+
+ {isHistoryMode && ( - - ) : ( - <> -
- {m.shumai_agent()} -
-
+ )} + + + {isHistoryMode ? m.history() : m.shumai_agent()} + +
+
+ {!isHistoryMode ? ( + <> -
- - )} + + ) : ( + + )} +
- {/* Main body view */} + {/* Body */} {isHistoryMode ? ( - + {historySessions.length === 0 ? ( -
- -

{m.no_history_sessions()}

+
+ {m.no_history_sessions()}
) : ( -
- {historySessions.map((sess) => { - const isActive = sess.id === currentSessionId +
+ {historySessions.map((session) => { + const isCurrent = session.id === currentSessionId return (
{ + if (teamId) { + loadSession(teamId, session.id) + setIsHistoryMode(false) + } + }} className={cn( - 'group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card', - isActive ? 'border-primary' : 'border-border hover:bg-accent/30', + 'group flex items-center justify-between p-2.5 rounded-lg text-xs cursor-pointer transition-all border border-transparent', + isCurrent + ? 'bg-accent/80 text-accent-foreground font-medium border-border/40' + : 'hover:bg-muted/60 text-muted-foreground hover:text-foreground', )} > -
teamId && loadSession(teamId, sess.id)} - className="flex-1 min-w-0 pr-6" - > -
- {sess.name || m.new_chat()} -
-
- {formatTimeAgo(sess.createdAt)} -
+
+ + {session.name || m.untitled_session()} + + + {formatTimeAgo(session.updatedAt)} +
@@ -574,7 +739,6 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp ) : ( <> - {/* Active Chat view */} {messages.length === 0 ? (
@@ -594,7 +758,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp ).customType === 'shumai_message') && (
- Thinking... + {m.thinking_status()}
)}
@@ -602,62 +766,74 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp )} - {/* Input Area (nested inside the border exactly like comment input) */}
-
- {/* Context assets list at the top inside the border */} - {chatAssets.length > 0 && ( -
- {chatAssets.map((asset) => ( -
-
- {asset.name} - - {asset.type} - -
- -
- ))} -
- )} - - {/* Textarea inside the border */} -