diff --git a/src/components/AiChatWidget.tsx b/src/components/AiChatWidget.tsx index cc123fa..2842bef 100644 --- a/src/components/AiChatWidget.tsx +++ b/src/components/AiChatWidget.tsx @@ -9,10 +9,12 @@ interface ChatMessage { intent?: string; status?: string; suggestedAction?: string; - /** Semantic category: ticket_created | ticket_pending | kb_results | usage_info | navigation */ + /** Semantic category: ticket_created | ticket_pending | kb_results | usage_info | navigation | profile_draft | cover_letter_draft */ actionType?: string; /** Original user text — stored so ticket confirm has a description to send */ userQuery?: string; + /** Raw generated content (profile draft, cover letter body) for save/copy actions */ + draftContent?: string; /** True once the user has clicked the confirm/action button on this message */ confirmed?: boolean; } @@ -29,6 +31,8 @@ interface ChatResponse { status?: string; suggested_action?: string; action_type?: string; + /** Raw generated text (profile draft, cover letter body) for copy/save actions */ + draft_content?: string; } function statusLabel(status?: string): string | null { @@ -195,6 +199,7 @@ export function AiChatWidget() { status: data.status, suggestedAction: data.suggested_action, actionType: data.action_type, + draftContent: data.draft_content, userQuery: text, confirmed: false, }; @@ -280,10 +285,8 @@ export function AiChatWidget() { }; /** Called when user clicks "Save to Profile" on a profile_draft message. */ - const confirmSaveProfile = async (msgIdx: number, draftText: string) => { - // Extract just the quoted improved text if it's wrapped in our "Here's an improved..." message - const quotedMatch = draftText.match(/"([^"]+)"/); - const cleanDraft = quotedMatch ? quotedMatch[1] : draftText; + const confirmSaveProfile = async (msgIdx: number, draftContent: string) => { + const cleanDraft = draftContent; setMessages((prev) => prev.map((m, i) => (i === msgIdx ? { ...m, confirmed: true } : m))); setIsLoading(true); @@ -591,9 +594,9 @@ export function AiChatWidget() { {/* Save-profile button — for profile_draft messages */} - + + + {/* Copy button — for cover_letter_draft messages */} + + +