diff --git a/features/profile-assistant/plugin-profile-assistant/src/components/AssistantChat.tsx b/features/profile-assistant/plugin-profile-assistant/src/components/AssistantChat.tsx index 0b51107b5..f678216de 100644 --- a/features/profile-assistant/plugin-profile-assistant/src/components/AssistantChat.tsx +++ b/features/profile-assistant/plugin-profile-assistant/src/components/AssistantChat.tsx @@ -36,6 +36,8 @@ export function AssistantChat({ inputPlaceholder = 'Ask your assistant...', }: AssistantChatProps) { const ctx = useContext(AssistantContext); + const confirmedCodes = ctx?.draft.confirmedCodes ?? new Set(); + const hasDraftPreview = (ctx?.draft.preview?.items.length ?? 0) > 0; // Map AssistantMessages to MessageThread format const threadMessages = messages.map((msg) => ({ @@ -45,10 +47,13 @@ export function AssistantChat({ createdAt: msg.createdAt, })); - // Find the last AI message that has extracted attributes (for DraftDiffCard) - const lastAiWithAttributes = [...messages] - .reverse() - .find((m) => m.role === 'assistant' && m.extractedAttributes.length > 0); + // Find the last AI message that has extracted attributes (for DraftDiffCard). + // Once all drafts are published (hasDraftPreview = false), hide the inline cards. + const lastAiWithAttributes = hasDraftPreview + ? [...messages] + .reverse() + .find((m) => m.role === 'assistant' && m.extractedAttributes.length > 0) + : undefined; // Find the last AI message that has quick replies const lastAiWithReplies = messages.findLast( @@ -88,23 +93,26 @@ export function AssistantChat({ /> - {/* Inline draft diff cards after last AI message with attributes */} + {/* Inline draft diff cards after last AI message with attributes. + Only show unconfirmed attributes — confirmed ones are already in the draft preview. */} {lastAiWithAttributes && ( - {lastAiWithAttributes.extractedAttributes.map((attr) => ( - - ))} + {lastAiWithAttributes.extractedAttributes + .filter((attr) => !confirmedCodes.has(attr.code)) + .map((attr) => ( + + ))} )}