Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(chat): quote by reference — store messageId+excerpt in metadata, not inline blockquote

Gusdd1c95356243
diff --git a/src/cli/daemon/prompt.test.ts b/src/cli/daemon/prompt.test.ts
index 095bae9da..b78bdbcf8 100644
--- a/src/cli/daemon/prompt.test.ts
+++ b/src/cli/daemon/prompt.test.ts
@@ -299,6 +299,36 @@ describe("buildPrompt", () => {
expect(parsed.email_id).toBeUndefined();
});
+ it("includes message_id in DM prompt when context has it", () => {
+ const task: Task = {
+ ...makeTask("Fix the bug"),
+ context: { message_id: "msg_abc123" },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.message_id).toBe("msg_abc123");
+ });
+
+ it("omits message_id for DM tasks without context", () => {
+ const task = makeTask("Hello");
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.message_id).toBeUndefined();
+ });
+
+ it("includes quoted_message in DM prompt when context has it", () => {
+ const task: Task = {
+ ...makeTask("Can you fix this?"),
+ context: { quoted_message: { message_id: "msg_orig", excerpt: "The auth module has a bug" } },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.quoted_message).toEqual({ message_id: "msg_orig", excerpt: "The auth module has a bug" });
+ });
+
+ it("omits quoted_message for DM tasks without quote context", () => {
+ const task = makeTask("Hello");
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.quoted_message).toBeUndefined();
+ });
+
it("does not add notice for unknown task types", () => {
const task = makeTask("Check inbox", "some_other_type");
const parsed = JSON.parse(buildPrompt(task));
diff --git a/src/cli/daemon/prompt.ts b/src/cli/daemon/prompt.ts
index 0ec372b46..eef45b025 100644
--- a/src/cli/daemon/prompt.ts
+++ b/src/cli/daemon/prompt.ts
@@ -50,6 +50,13 @@ export function buildTaskObject(task: Task, attachments?: Attachment[]): Record<
};
if (task.type === "user_dm_message") {
obj.notice = DM_RESPONSE_NOTICE;
+ const ctx = task.context as Record<string, unknown> | undefined;
+ if (ctx?.message_id) {
+ obj.message_id = ctx.message_id;
+ }
+ if (ctx?.quoted_message) {
+ obj.quoted_message = ctx.quoted_message;
+ }
}
if (task.type === "email_notification") {
const ctx = task.context as Record<string, unknown> | undefined;
diff --git a/src/shared/src/schemas.ts b/src/shared/src/schemas.ts
index b098cc0be..ed127ca69 100644
--- a/src/shared/src/schemas.ts
+++ b/src/shared/src/schemas.ts
@@ -539,6 +539,7 @@ export type CreateConversationRequest = z.infer<
export const CreateMessageRequestSchema = z.object({
content: z.string().min(1, "content is required"),
+ metadata: z.record(z.string(), z.unknown()).optional(),
});
export type CreateMessageRequest = z.infer<typeof CreateMessageRequestSchema>;
diff --git a/src/shared/test/schemas/message.test.ts b/src/shared/test/schemas/message.test.ts
new file mode 100644
index 000000000..bdfc7963d
--- /dev/null
+++ b/src/shared/test/schemas/message.test.ts
@@ -0,0 +1,40 @@
+import { describe, it, expect } from "vitest";
+import { CreateMessageRequestSchema } from "../../src/schemas";
+
+describe("CreateMessageRequestSchema", () => {
+ it("TC1: accepts content with quote metadata", () => {
+ const result = CreateMessageRequestSchema.safeParse({
+ content: "Can you fix this?",
+ metadata: { quote: { messageId: "msg_123", excerpt: "The auth module has a bug" } },
+ });
+ expect(result.success).toBe(true);
+ if (result.success) {
+ expect(result.data.metadata).toEqual({
+ quote: { messageId: "msg_123", excerpt: "The auth module has a bug" },
+ });
+ }
+ });
+
+ it("TC1: accepts content without metadata", () => {
+ const result = CreateMessageRequestSchema.safeParse({ content: "Hello" });
+ expect(result.success).toBe(true);
+ if (result.success) {
+ expect(result.data.metadata).toBeUndefined();
+ }
+ });
+
+ it("TC1: rejects empty content", () => {
+ const result = CreateMessageRequestSchema.safeParse({ content: "" });
+ expect(result.success).toBe(false);
+ });
+
+ it("TC1: rejects missing content", () => {
+ const result = CreateMessageRequestSchema.safeParse({});
+ expect(result.success).toBe(false);
+ });
+
+ it("TC1: metadata is optional", () => {
+ const result = CreateMessageRequestSchema.safeParse({ content: "hi" });
+ expect(result.success).toBe(true);
+ });
+});
diff --git a/src/web/src/app/api/conversations/[id]/messages/route.test.ts b/src/web/src/app/api/conversations/[id]/messages/route.test.ts
index 7ed1812f2..d13c371bb 100644
--- a/src/web/src/app/api/conversations/[id]/messages/route.test.ts
+++ b/src/web/src/app/api/conversations/[id]/messages/route.test.ts
@@ -303,4 +303,74 @@ describe("POST /api/conversations/[id]/messages", () => {
expect(mockGetConversation).toHaveBeenCalledWith({}, "c1", "w1");
});
+
+ it("TC2: passes metadata.quote to createMessage and adds quoted_message to task context", async () => {
+ const conv = { id: "c1", workspaceId: "w1", agentId: "a1" };
+ const msg = { id: "m1", content: "Can you fix this?" };
+ const task = { id: "t1", status: "pending" };
+ mockGetConversation.mockResolvedValue(conv);
+ mockCreateMessage.mockResolvedValue(msg);
+ mockUpdateConversationTitle.mockResolvedValue(undefined);
+ mockEnqueueTask.mockResolvedValue(task);
+
+ const res = await POST(
+ new NextRequest("http://localhost/api/conversations/c1/messages", {
+ method: "POST",
+ body: JSON.stringify({
+ content: "Can you fix this?",
+ metadata: { quote: { messageId: "msg_orig", excerpt: "The auth module has a bug" } },
+ }),
+ headers: { "Content-Type": "application/json" },
+ }),
+ withParams("c1")
+ );
+
+ expect(res.status).toBe(201);
+ expect(mockCreateMessage).toHaveBeenCalledWith(
+ {},
+ expect.objectContaining({
+ content: "Can you fix this?",
+ metadata: JSON.stringify({ quote: { messageId: "msg_orig", excerpt: "The auth module has a bug" } }),
+ }),
+ );
+ expect(mockEnqueueTask).toHaveBeenCalledWith(
+ "a1", "c1", "w1", "Can you fix this?", "user_dm_message",
+ expect.objectContaining({
+ context: expect.objectContaining({
+ message_id: "m1",
+ quoted_message: { message_id: "msg_orig", excerpt: "The auth module has a bug" },
+ }),
+ }),
+ );
+ });
+
+ it("TC3: message without metadata has no quote in metadata or task context", async () => {
+ const conv = { id: "c1", workspaceId: "w1", agentId: "a1" };
+ const msg = { id: "m1", content: "Hello" };
+ const task = { id: "t1", status: "pending" };
+ mockGetConversation.mockResolvedValue(conv);
+ mockCreateMessage.mockResolvedValue(msg);
+ mockUpdateConversationTitle.mockResolvedValue(undefined);
+ mockEnqueueTask.mockResolvedValue(task);
+
+ await POST(
+ new NextRequest("http://localhost/api/conversations/c1/messages", {
+ method: "POST",
+ body: JSON.stringify({ content: "Hello" }),
+ headers: { "Content-Type": "application/json" },
+ }),
+ withParams("c1")
+ );
+
+ expect(mockCreateMessage).toHaveBeenCalledWith(
+ {},
+ expect.objectContaining({ metadata: null }),
+ );
+ expect(mockEnqueueTask).toHaveBeenCalledWith(
+ "a1", "c1", "w1", "Hello", "user_dm_message",
+ expect.objectContaining({
+ context: { message_id: "m1" },
+ }),
+ );
+ });
});
diff --git a/src/web/src/app/api/conversations/[id]/messages/route.ts b/src/web/src/app/api/conversations/[id]/messages/route.ts
index abffca19a..dc9df6a9b 100644
--- a/src/web/src/app/api/conversations/[id]/messages/route.ts
+++ b/src/web/src/app/api/conversations/[id]/messages/route.ts
@@ -70,6 +70,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
const isMultipart = contentType.includes("multipart/form-data");
let content: string;
+ let messageMetadata: Record<string, unknown> | undefined;
const files: File[] = [];
if (isMultipart) {
@@ -80,6 +81,10 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
return writeError("invalid form data", 400);
}
content = (formData.get("content") as string) || "";
+ const metaRaw = formData.get("metadata") as string | null;
+ if (metaRaw) {
+ try { messageMetadata = JSON.parse(metaRaw); } catch { /* ignore malformed */ }
+ }
for (const [key, value] of formData.entries()) {
if (key === "file" && value instanceof File) {
files.push(value);
@@ -89,6 +94,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
const [body, valErr] = await parseBody(req, CreateMessageRequestSchema);
if (valErr) return valErr;
content = body.content;
+ messageMetadata = body.metadata;
}
if (isMultipart && !content) {
@@ -142,6 +148,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
role: "user",
content,
attachmentIds: artifactIds.length > 0 ? JSON.stringify(artifactIds) : null,
+ metadata: messageMetadata ? JSON.stringify(messageMetadata) : null,
});
broadcastToUser(ctx.userId, {
@@ -181,9 +188,12 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
}
const contextKey = id;
+ const quote = messageMetadata?.quote as { messageId?: string; excerpt?: string } | undefined;
const taskContext: Record<string, unknown> = {
+ message_id: message.id,
...(artifactIds.length > 0 ? { attachment_ids: artifactIds } : {}),
...mentionContext,
+ ...(quote ? { quoted_message: { message_id: quote.messageId, excerpt: quote.excerpt } } : {}),
};
const traceId = "tr_" + nanoid();
const taskService = new TaskService(db);
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsx
index f9e11b55a..a7030b997 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -188,7 +188,7 @@ export function AgentChatView({
const [caretIndex, setCaretIndex] = useState<number | null>(null);
const [renderNow] = useState(() => Date.now());
- const [quotedText, setQuotedText] = useState<string | null>(() => {
+ const [quotedMessage, setQuotedMessage] = useState<{ id: string; excerpt: string } | null>(() => {
if (typeof window === "undefined") return null;
try {
const meta = JSON.parse(
@@ -196,7 +196,8 @@ export function AgentChatView({
`chat-draft-meta:${agentId}:${targetConvId ?? "default"}`,
) ?? "null",
);
- return meta?.quote ?? null;
+ const q = meta?.quote;
+ return q && typeof q === "object" && q.id ? q : null;
} catch {
return null;
}
@@ -219,7 +220,7 @@ export function AgentChatView({
// because `slashCommand` is defined after `useAgentChat` (it needs the
// hook-created `composerRef`).
const inputRef = useLatest(input);
- const quotedTextRef = useLatest(quotedText);
+ const quotedMessageRef = useLatest(quotedMessage);
const pendingFilesRef = useLatest(pendingFiles);
const activeSkillRef = useRef<SkillEntry | null>(null);
// Holds the `slashCommand` instance (created after this hook call, since it
@@ -248,12 +249,12 @@ export function AgentChatView({
setFlaggedIds,
setPendingFiles,
setInput,
- setQuotedText,
+ setQuotedMessage,
setActiveSkill: (skill: SkillEntry | null) =>
slashCommandRef.current?.setActiveSkill(skill),
clearActiveSkill: () => slashCommandRef.current?.clearActiveSkill(),
inputRef,
- quotedTextRef,
+ quotedMessageRef,
pendingFilesRef,
activeSkillRef,
draftMetaRestoredRef,
@@ -418,7 +419,7 @@ export function AgentChatView({
const key = `chat-draft-meta:${agentId}:${targetConvId ?? "default"}`;
const meta: {
skill?: { name: string; description: string } | null;
- quote?: string | null;
+ quote?: { id: string; excerpt: string } | null;
} = {};
if (slashCommand.activeSkill) {
meta.skill = {
@@ -426,15 +427,15 @@ export function AgentChatView({
description: slashCommand.activeSkill.description,
};
}
- if (quotedText) {
- meta.quote = quotedText;
+ if (quotedMessage) {
+ meta.quote = quotedMessage;
}
if (meta.skill || meta.quote) {
localStorage.setItem(key, JSON.stringify(meta));
} else {
localStorage.removeItem(key);
}
- }, [slashCommand.activeSkill, quotedText, agentId, targetConvId]);
+ }, [slashCommand.activeSkill, quotedMessage, agentId, targetConvId]);
useEffect(() => {
if (!sending) {
@@ -448,7 +449,12 @@ export function AgentChatView({
const handleQuoteSelection = useCallback(() => {
if (selectionPopup) {
- setQuotedText(selectionPopup.text);
+ const excerpt = selectionPopup.text.slice(0, 100);
+ setQuotedMessage(
+ selectionPopup.messageId
+ ? { id: selectionPopup.messageId, excerpt }
+ : null,
+ );
setSelectionPopup(null);
window.getSelection()?.removeAllRanges();
composerRef.current?.focus();
@@ -456,6 +462,11 @@ export function AgentChatView({
// eslint-disable-next-line react-hooks/exhaustive-deps -- composerRef and setSelectionPopup are stable
}, [selectionPopup]);
+ const handleQuoteMessage = useCallback((messageId: string, excerpt: string) => {
+ setQuotedMessage({ id: messageId, excerpt });
+ composerRef.current?.focus();
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- composerRef is stable
+ }, []);
useEffect(() => {
if (!issueSheetOpen || !selectedIssueId) return;
@@ -770,6 +781,7 @@ export function AgentChatView({
agentAvatarConfig={agentAvatarConfig}
isSendFailed={failedSends.has(msg.id)}
onRetrySend={handleRetrySend}
+ onQuote={handleQuoteMessage}
/>
</div>
);
@@ -912,7 +924,7 @@ export function AgentChatView({
className={cn(
"relative flex-1 min-w-0 flex flex-col rounded-3xl border border-border/50 bg-background/90 transition-[border-radius] duration-200",
"focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",
- (isMultiLine || quotedText || slashCommand.activeSkill) &&
+ (isMultiLine || quotedMessage || slashCommand.activeSkill) &&
"rounded-2xl",
sending && "opacity-50",
dragging && "border-ring ring-3 ring-ring/50",
@@ -926,7 +938,7 @@ export function AgentChatView({
<div
className={cn(
"absolute inset-0 z-10 flex items-center justify-center bg-background/80 border-2 border-dashed border-ring pointer-events-none",
- isMultiLine || quotedText || slashCommand.activeSkill
+ isMultiLine || quotedMessage || slashCommand.activeSkill
? "rounded-2xl"
: "rounded-3xl",
)}
@@ -960,18 +972,17 @@ export function AgentChatView({
</button>
</div>
)}
- {quotedText && (
+ {quotedMessage && (
<div className="flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50">
<div className="flex-1 min-w-0 flex items-start gap-2">
<MessageSquareQuote className="size-3.5 shrink-0 mt-0.5 text-muted-foreground" />
<p className="text-xs text-muted-foreground truncate">
- {quotedText.slice(0, 120)}
- {quotedText.length > 120 ? "..." : ""}
+ {quotedMessage.excerpt}
</p>
</div>
<button
type="button"
- onClick={() => setQuotedText(null)}
+ onClick={() => setQuotedMessage(null)}
className="shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground"
>
<X className="size-3.5" />
diff --git a/src/web/src/components/agent-chat/message-list.tsx b/src/web/src/components/agent-chat/message-list.tsx
index f37e211c4..861ea73ed 100644
--- a/src/web/src/components/agent-chat/message-list.tsx
+++ b/src/web/src/components/agent-chat/message-list.tsx
@@ -11,7 +11,7 @@ import { highlightMentions } from "@/lib/highlight-mentions";
import { TaskStream } from "@/components/task-stream";
import { RuntimeErrorBlock } from "@/components/agent-chat/runtime-error-block";
import { AnimatedAvatar, type AvatarConfig } from "@/components/avatar";
-import { FileText, Flag, Copy, Check } from "lucide-react";
+import { FileText, Flag, Copy, Check, MessageSquareQuote } from "lucide-react";
import { EmailCard } from "@/components/agent-chat/event-cards/email-card";
import { CalendarCard } from "@/components/agent-chat/event-cards/calendar-card";
import { IssueCard } from "@/components/agent-chat/event-cards/issue-card";
@@ -77,6 +77,7 @@ export interface MessageItemProps {
/** This optimistic user message failed to send — show the inline retry affordance. */
isSendFailed?: boolean;
onRetrySend?: (messageId: string) => void;
+ onQuote?: (messageId: string, excerpt: string) => void;
}
type EmailData = {
@@ -423,6 +424,7 @@ export const MessageItem = memo(function MessageItem({
agentAvatarConfig,
isSendFailed,
onRetrySend,
+ onQuote,
}: MessageItemProps) {
const { copy, copied } = useCopyToClipboard();
@@ -486,6 +488,14 @@ export const MessageItem = memo(function MessageItem({
onClick: doCopy,
});
}
+ if (onQuote && (msg.role === "assistant" || msg.role === "user")) {
+ messageActions.push({
+ key: "quote",
+ label: "Quote",
+ icon: <MessageSquareQuote className="size-3.5" />,
+ onClick: () => onQuote(msg.id, msg.content.slice(0, 100)),
+ });
+ }
if (msg.role === "assistant" && onToggleFlag) {
messageActions.push({
key: "flag",
@@ -551,6 +561,24 @@ export const MessageItem = memo(function MessageItem({
const messageBody = slashMatch ? (slashMatch[2] || "") : msg.content;
return (
<div className="group/msg flex flex-col items-end" data-message-id={msg.id} {...(msg.task_id ? { "data-task-id": msg.task_id } : {})}>
+ {(() => {
+ const quote = msg.metadata?.quote as { messageId?: string; excerpt?: string } | undefined;
+ const quoteId = quote?.messageId;
+ if (!quoteId) return null;
+ return (
+ <button
+ type="button"
+ onClick={() => {
+ const target = document.querySelector(`[data-message-id="${CSS.escape(quoteId)}"]`);
+ target?.scrollIntoView({ behavior: "smooth", block: "center" });
+ }}
+ className="max-w-[80%] mb-0.5 flex items-center gap-1.5 rounded-lg bg-muted/60 px-2.5 py-1 text-left"
+ >
+ <MessageSquareQuote className="size-3 shrink-0 text-muted-foreground" />
+ <span className="text-xs text-muted-foreground truncate">{quote.excerpt}</span>
+ </button>
+ );
+ })()}
<div
className={cn(
"max-w-[80%] px-3 py-1.5 bg-primary text-primary-foreground text-base relative",
diff --git a/src/web/src/hooks/use-agent-chat.ts b/src/web/src/hooks/use-agent-chat.ts
index 33de3f0f9..c0f414d7a 100644
--- a/src/web/src/hooks/use-agent-chat.ts
+++ b/src/web/src/hooks/use-agent-chat.ts
@@ -91,12 +91,12 @@ export interface UseAgentChatExternal {
setFlaggedIds: (ids: Set<string>) => void;
setPendingFiles: (files: File[]) => void;
setInput: (value: string) => void;
- setQuotedText: (value: string | null) => void;
+ setQuotedMessage: (value: { id: string; excerpt: string } | null) => void;
setActiveSkill: (skill: SkillEntry | null) => void;
clearActiveSkill: () => void;
// (b) Values the hook READS — owned outside, passed IN via useLatest ref.
inputRef: MutableRefObject<string>;
- quotedTextRef: MutableRefObject<string | null>;
+ quotedMessageRef: MutableRefObject<{ id: string; excerpt: string } | null>;
pendingFilesRef: MutableRefObject<File[]>;
activeSkillRef: MutableRefObject<SkillEntry | null>;
// Component-owned ref written by the load effect (gates draft-meta persist).
@@ -125,11 +125,11 @@ export function useAgentChat(
setFlaggedIds,
setPendingFiles,
setInput,
- setQuotedText,
+ setQuotedMessage,
setActiveSkill,
clearActiveSkill,
inputRef,
- quotedTextRef,
+ quotedMessageRef,
pendingFilesRef,
activeSkillRef,
draftMetaRestoredRef,
@@ -320,16 +320,17 @@ export function useAgentChat(
if (metaRaw) {
try {
const meta = JSON.parse(metaRaw);
- setQuotedText(meta.quote ?? null);
+ const q = meta.quote;
+ setQuotedMessage(q && typeof q === "object" && q.id ? q : null);
setActiveSkill(
meta.skill ? (meta.skill as SkillEntry) : null,
);
} catch {
- setQuotedText(null);
+ setQuotedMessage(null);
setActiveSkill(null);
}
} else {
- setQuotedText(null);
+ setQuotedMessage(null);
setActiveSkill(null);
}
draftMetaRestoredRef.current = true;
@@ -1576,10 +1577,8 @@ export function useAgentChat(
return;
}
- // Prepend quoted text as blockquote if present
- let content = quotedTextRef.current
- ? `> ${quotedTextRef.current.split("\n").join("\n> ")}\n\n${rawContent}`
- : rawContent;
+ let content = rawContent;
+ const quoteRef = quotedMessageRef.current;
// Prepend skill instruction if active
if (activeSkillRef.current) {
@@ -1589,7 +1588,7 @@ export function useAgentChat(
const filesToSend = [...pendingFilesRef.current];
setInput("");
setPendingFiles([]);
- setQuotedText(null);
+ setQuotedMessage(null);
clearActiveSkill();
setSending(true);
@@ -1605,6 +1604,7 @@ export function useAgentChat(
content,
task_id: null,
attachment_ids: null,
+ ...(quoteRef ? { metadata: { quote: { messageId: quoteRef.id, excerpt: quoteRef.excerpt } } } : {}),
created_at: new Date().toISOString(),
};
@@ -1626,6 +1626,7 @@ export function useAgentChat(
content,
workspaceId,
filesToSend.length > 0 ? filesToSend : undefined,
+ quoteRef ? { quote: { messageId: quoteRef.id, excerpt: quoteRef.excerpt } } : undefined,
);
// Clean up pending files ref
setPendingFilesByMessage((prev) => {
diff --git a/src/web/src/hooks/use-text-selection-quote.ts b/src/web/src/hooks/use-text-selection-quote.ts
index 839464962..4a8de32ea 100644
--- a/src/web/src/hooks/use-text-selection-quote.ts
+++ b/src/web/src/hooks/use-text-selection-quote.ts
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react";
export type SelectionPopup = {
text: string;
+ messageId: string | null;
x: number;
y: number;
} | null;
@@ -37,13 +38,16 @@ export function useTextSelectionQuote() {
range.commonAncestorContainer instanceof HTMLElement
? range.commonAncestorContainer
: range.commonAncestorContainer.parentElement;
- if (!container?.closest("[data-quote-source]")) {
+ const quoteSource = container?.closest("[data-quote-source]");
+ if (!quoteSource) {
setSelectionPopup(null);
return;
}
+ const msgEl = quoteSource.closest("[data-message-id]");
+ const messageId = msgEl?.getAttribute("data-message-id") ?? null;
const rects = range.getClientRects();
const lastRect = rects[rects.length - 1] || range.getBoundingClientRect();
- setSelectionPopup({ text, x: lastRect.right, y: lastRect.top - 4 });
+ setSelectionPopup({ text, messageId, x: lastRect.right, y: lastRect.top - 4 });
}, []);
useEffect(() => {
diff --git a/src/web/src/lib/api.ts b/src/web/src/lib/api.ts
index c342dbbe5..c407358b4 100644
--- a/src/web/src/lib/api.ts
+++ b/src/web/src/lib/api.ts
@@ -367,19 +367,21 @@ export const sendMessage = async (
content: string,
workspaceId: string,
files?: File[],
+ metadata?: Record<string, unknown>,
): Promise<{ message: Message; task: TaskApi }> => {
if (!files || files.length === 0) {
return apiFetch<{ message: Message; task: TaskApi }>(
`/api/conversations/${conversationId}/messages${wsQuery(workspaceId)}`,
{
method: "POST",
- body: JSON.stringify({ content }),
+ body: JSON.stringify({ content, ...(metadata ? { metadata } : {}) }),
},
);
}
const fd = new FormData();
fd.append("content", content);
+ if (metadata) fd.append("metadata", JSON.stringify(metadata));
for (const file of files) {
fd.append("file", file);
}