diff --git a/apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.tsx b/apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.tsx index 2baae14945d..2a1182f4960 100644 --- a/apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.tsx +++ b/apps/sim/app/workspace/[workspaceId]/components/message-actions/message-actions.tsx @@ -34,7 +34,7 @@ interface MessageActionsProps { getCopyContent?: () => string hasCopyContent?: boolean prepareContentForCopy?: (content: string) => ClipboardContent - userQuery?: string + userQuery: string | undefined requestId?: string messageId?: string } diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx index 977ef369b7f..9133ba18929 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx @@ -211,6 +211,7 @@ interface AssistantMessageRowProps { prepareContentForCopy: (content: string) => ClipboardContent isStreaming: boolean isLast: boolean + precedingUserContent: string | undefined /** Transcript-derived answers for this message's question card (renders the recap). */ questionAnswers?: string[] /** Transcript-derived status payload for this message's credential card. */ @@ -227,6 +228,7 @@ const AssistantMessageRow = memo(function AssistantMessageRow({ prepareContentForCopy, isStreaming, isLast, + precedingUserContent, questionAnswers, credentialSubmission, credentialAbandoned, @@ -311,6 +313,7 @@ const AssistantMessageRow = memo(function AssistantMessageRow({ getCopyContent={getCopyContent} hasCopyContent={Boolean(getOrchestratorMessageText(blocks, message.content).trim())} prepareContentForCopy={prepareContentForCopy} + userQuery={precedingUserContent} requestId={message.requestId} messageId={message.id} /> @@ -562,6 +565,16 @@ export function MothershipChat({ return out }, [messages]) + const precedingUserContentByIndex = useMemo(() => { + const out: Array = [] + let lastUserContent: string | undefined + for (const [index, message] of messages.entries()) { + out[index] = lastUserContent + if (message.role === 'user') lastUserContent = message.content + } + return out + }, [messages]) + /** * Pairs each assistant question/credential card with the user message that * completed it. The paired user message is hidden — the answered card IS the @@ -809,6 +822,7 @@ export function MothershipChat({ prepareContentForCopy={prepareContentForCopy} isStreaming={isStreamActive && isLast} isLast={isLast} + precedingUserContent={precedingUserContentByIndex[index]} questionAnswers={interactionPairing.answersByIndex[index]} credentialSubmission={interactionPairing.credentialSubmissionByIndex[index]} credentialAbandoned={interactionPairing.credentialAbandonedByIndex[index]}