From cb1e919af0431cc35b7f034283bfbb83dcfdfe4d Mon Sep 17 00:00:00 2001 From: Lilith Date: Mon, 23 Feb 2026 13:07:36 -0800 Subject: [PATCH] =?UTF-8?q?chore(profile-assistant):=20=F0=9F=94=A7=20Impl?= =?UTF-8?q?ement=20refined=20message=20handling=20&=20UI=20improvements=20?= =?UTF-8?q?in=20AssistantChat.tsx=20for=20seamless=20profile=20assistant?= =?UTF-8?q?=20interactions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../src/components/AssistantChat.tsx | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) 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) => ( + + ))} )}