From fae9457e8858cdb4e10d857cc3c23b15af3d71be Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Thu, 7 Aug 2025 17:02:23 +0100 Subject: [PATCH] fix: auto draft compose (#1946) # Update Email Assistant to use HTML formatting ## Description This PR updates the Email Assistant system prompt to generate emails with proper HTML formatting instead of plain text. ## Summary by CodeRabbit * **Bug Fixes** * Improved formatting of automatically generated drafts by displaying line breaks as HTML `
` tags. * **Style** * Removed unnecessary trailing spaces from certain prompt texts. --- apps/server/src/lib/prompts.ts | 6 +++--- apps/server/src/thread-workflow-utils/index.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/server/src/lib/prompts.ts b/apps/server/src/lib/prompts.ts index 632dd335f..182a3ce07 100644 --- a/apps/server/src/lib/prompts.ts +++ b/apps/server/src/lib/prompts.ts @@ -335,7 +335,7 @@ export const AiChatPrompt = () => A correct response must: 1. Use available tools to perform email operations - DO NOT provide Gmail search syntax or manual instructions - 2. Use only plain text - no markdown, XML, bullets, or formatting + 2. Use only plain text - no markdown, XML, bullets, or formatting 3. Never expose tool responses or internal reasoning to users 4. Confirm before affecting more than 5 threads 5. Be concise and action-oriented @@ -351,7 +351,7 @@ export const AiChatPrompt = () => - External information: Use webSearch tool - Email composition: Use composeEmail, sendEmail tools - + Only provide plain text responses for: - Clarifying questions when user intent is unclear @@ -535,7 +535,7 @@ export const AiChatPrompt = () => 1. State exactly what will be affected - 2. Show count and representative samples + 2. Show count and representative samples 3. Explain consequences (especially if irreversible) 4. Wait for explicit "yes" or "confirm" 5. Provide undo guidance where possible diff --git a/apps/server/src/thread-workflow-utils/index.ts b/apps/server/src/thread-workflow-utils/index.ts index a7658a028..26fee86ae 100644 --- a/apps/server/src/thread-workflow-utils/index.ts +++ b/apps/server/src/thread-workflow-utils/index.ts @@ -125,7 +125,9 @@ const generateAutomaticDraft = async ( connectionId, }); - return draftContent; + const draftNewLines = draftContent.replace(/\n/g, '
'); + + return draftNewLines; } catch (error) { console.log('[THREAD_WORKFLOW] Failed to generate automatic draft:', { connectionId,