diff --git a/src/components/appbar/AddAgentModal.tsx b/src/components/appbar/AddAgentModal.tsx index 26b671e..79f4b3d 100644 --- a/src/components/appbar/AddAgentModal.tsx +++ b/src/components/appbar/AddAgentModal.tsx @@ -17,11 +17,11 @@ interface AddAgentModalProps { } export const AddAgentModal: React.FC = ({ open, onClose, addAgentByUrl }) => { - const [url, setUrl] = React.useState("https://example.com/.well-known/agent-card.json"); + const [url, setUrl] = React.useState(process.env.NEXT_PUBLIC_DEFAULT_AGENT_CARDS_URL || "https://example.com/.well-known/agent-card.json"); const [loading, setLoading] = React.useState(false); const handleClose = (): void => { - setUrl("https://example.com/.well-known/agent-card.json"); + setUrl(process.env.NEXT_PUBLIC_DEFAULT_AGENT_CARDS_URL || "https://example.com/.well-known/agent-card.json"); setLoading(false); onClose(); }; diff --git a/src/components/chat/Chat.tsx b/src/components/chat/Chat.tsx index d2f62d5..2529f4c 100644 --- a/src/components/chat/Chat.tsx +++ b/src/components/chat/Chat.tsx @@ -120,7 +120,25 @@ export const Chat: React.FC = ({ } } - return chatItems2; + // Deduplicate messages by messageId, keeping only the latest (last) occurrence + const seen = new Set(); + const deduplicated: ChatItem[] = []; + for (let i = chatItems2.length - 1; i >= 0; i--) { + const item = chatItems2[i]; + if ("messageId" in item) { + // It's a Message + if (!seen.has(item.messageId)) { + seen.add(item.messageId); + deduplicated.unshift(item); + } + // Skip if already seen + } else { + // Non-message items (task-divider, tool-call, artifact) are always included + deduplicated.unshift(item); + } + } + + return deduplicated; }, [activeChatContext]); const handleSendMessage = (message: string): void => {