feat(chat): support markups, attachments, and timestamps in agent 1-to-1 chat (#368)

* feat(chat): support markups, attachments, and timestamps in agent 1-to-1 chat

* feat(chat): improve message card layout with inline badges and integrated assets

* fix(chat): enable image attachment thumbnails in 1-to-1 chat cards

* fix(chat): address code review feedback on input state, mentions, i18n, and session deletion

* fix(chat): replace ring with border color on selected message card
This commit is contained in:
Yiling-J
2026-08-31 20:11:27 +08:00
committed by GitHub
parent 6e9cf8dfb6
commit e06478df88
36 changed files with 1908 additions and 353 deletions
@@ -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 }],
}),
}),
)
})
})
+23 -1
View File
@@ -61,6 +61,8 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
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<void> {
userComment.annotation.length > 0
) {
commentAnnotation = true
commentAnnotations = userComment.annotation
}
// 2. Create Placeholder Comment
@@ -101,6 +104,17 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
} 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<void> {
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<void> {
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<void> {
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<void> {
: {}),
currentAsset: currentAssetContext,
...(mediaPosition ? { position: mediaPosition } : {}),
...(commentAnnotation ? { annotation: true } : {}),
...(commentAnnotation
? {
annotation: true,
annotations: commentAnnotations as ShumaiMessageContext['annotations'],
}
: {}),
...(attachedFiles.length > 0 ? { attachedFiles } : {}),
...(referencedAssets.length > 0 ? { referencedAssets } : {}),
}