Skip to content

Comments

fix: auto draft compose#1946

Merged
ahmetskilinc merged 3 commits intostagingfrom
08-07-wip_of_new_prompt_for_compose
Aug 7, 2025
Merged

fix: auto draft compose#1946
ahmetskilinc merged 3 commits intostagingfrom
08-07-wip_of_new_prompt_for_compose

Conversation

@ahmetskilinc
Copy link
Contributor

@ahmetskilinc ahmetskilinc commented Aug 7, 2025

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 <br> tags.
  • Style

    • Removed unnecessary trailing spaces from certain prompt texts.

@jazzberry-ai
Copy link

jazzberry-ai bot commented Aug 7, 2025

Bug Report

Name Severity Example test case Description
Incorrect Paragraph Separation High Generate an email with multiple paragraphs. The prompt instructs the model to use <br> tags for paragraph separation, which is semantically incorrect and will cause rendering issues.
Missing HTML Structure Medium Generate any email. The prompt prevents the use of <html>, <head>, and <body> tags, which can cause rendering problems in some email clients.
Potential HTML Injection Vulnerability Medium Generate an email with a link. If the email body is not properly sanitized, a malicious user could inject arbitrary HTML code via the <a> tag.

Comments? Email us.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

Walkthrough

This update removes trailing whitespace from specific lines in the AI chat prompt definition and modifies the generateAutomaticDraft function to replace newline characters with HTML <br> tags in its returned content. No changes were made to function signatures or overall logic outside these formatting adjustments.

Changes

Cohort / File(s) Change Summary
Prompt Whitespace Cleanup
apps/server/src/lib/prompts.ts
Removed trailing whitespace from three lines within the AiChatPrompt system prompt string.
Draft Formatting Update
apps/server/src/thread-workflow-utils/index.ts
Modified generateAutomaticDraft to return draft content with newlines replaced by <br> tags.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Server
    participant DraftGenerator

    User->>Server: Trigger automatic draft generation
    Server->>DraftGenerator: Call generateAutomaticDraft()
    DraftGenerator->>DraftGenerator: Generate content with newlines
    DraftGenerator->>DraftGenerator: Replace \n with <br>
    DraftGenerator-->>Server: Return formatted draft content
    Server-->>User: Deliver HTML-formatted draft
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • MrgSub

Poem

Rockets to Mars, but code must be neat,
Trailing spaces gone—now that’s elite!
Drafts get new lines, but HTML’s the star,
<br> tags in place, formatting up to par.
Onward we go, optimizing the base,
One small step for code, one giant leap for space! 🚀

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 08-07-wip_of_new_prompt_for_compose

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ahmetskilinc ahmetskilinc force-pushed the 08-07-wip_of_new_prompt_for_compose branch from ad3036e to b3ae4b9 Compare August 7, 2025 14:58
@jazzberry-ai
Copy link

jazzberry-ai bot commented Aug 7, 2025

Bug Report

Name Severity Example test case Description
XSS vulnerability in email composition Critical Inject a <script> tag into the email composition prompt. The generateAutomaticDraft function generates email content based on a prompt, but the output is not sanitized before being returned to the client. This allows an attacker to inject arbitrary HTML, including malicious scripts, into the email body, leading to a potential XSS vulnerability.

Comments? Email us.

@jazzberry-ai
Copy link

jazzberry-ai bot commented Aug 7, 2025

Bug Report

Inconsistent formatting instructions in the StyledEmailAssistantSystemPrompt|Medium|User requests an email with multiple paragraphs and bullet points.|The StyledEmailAssistantSystemPrompt contains contradictory formatting instructions. Specifically, it instructs the model to "Separate paragraphs with two newline characters" while simultaneously implying the use of HTML paragraph tags (<p>). The prompt also does not specify to surround the email in HTML tags. This combination could lead to malformed HTML output where paragraphs are separated by newlines instead of <p> tags, lists are created using newlines instead of HTML list tags, and the entire body is not enclosed in an appropriate <html><body> structure, which means the client is required to infer how to display the content. The newline replacement in thread-workflow-utils/index.ts will then insert <br> tags where the newlines are, further corrupting the intended structure.

Comments? Email us.

@ahmetskilinc ahmetskilinc changed the title wip of new prompt for compose fix: auto draft compose Aug 7, 2025
@ahmetskilinc ahmetskilinc marked this pull request as ready for review August 7, 2025 15:12
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76b7330 and fc50bd7.

📒 Files selected for processing (2)
  • apps/server/src/lib/prompts.ts (3 hunks)
  • apps/server/src/thread-workflow-utils/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

**/*.{js,jsx,ts,tsx}: Use 2-space indentation
Use single quotes for strings
Limit lines to 100 characters in length
Semicolons are required at the end of statements

Files:

  • apps/server/src/lib/prompts.ts
  • apps/server/src/thread-workflow-utils/index.ts
**/*.{js,jsx,ts,tsx,css,scss}

📄 CodeRabbit Inference Engine (AGENT.md)

Use Prettier with sort-imports and Tailwind plugins for code formatting

Files:

  • apps/server/src/lib/prompts.ts
  • apps/server/src/thread-workflow-utils/index.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

Enable TypeScript strict mode

Files:

  • apps/server/src/lib/prompts.ts
  • apps/server/src/thread-workflow-utils/index.ts
**/*.{css,js,ts,jsx,tsx,mdx}

📄 CodeRabbit Inference Engine (.cursor/rules/tailwind-css-v4.mdc)

**/*.{css,js,ts,jsx,tsx,mdx}: Chain variants together for composable variants (e.g., group-has-data-potato:opacity-100).
Use new variants such as starting, not-*, inert, nth-*, in-*, open (for :popover-open), and ** for all descendants.
Do not use deprecated utilities like bg-opacity-*, text-opacity-*, border-opacity-*, and divide-opacity-*; use the new syntax (e.g., bg-black/50).
Use renamed utilities: shadow-sm is now shadow-xs, shadow is now shadow-sm, drop-shadow-sm is now drop-shadow-xs, drop-shadow is now drop-shadow-sm, blur-sm is now blur-xs, blur is now blur-sm, rounded-sm is now rounded-xs, rounded is now rounded-sm, outline-none is now outline-hidden.
Use bg-(--brand-color) syntax for CSS variables in arbitrary values instead of bg-[--brand-color].
Stacked variants now apply left-to-right instead of right-to-left.

Files:

  • apps/server/src/lib/prompts.ts
  • apps/server/src/thread-workflow-utils/index.ts
🧠 Learnings (2)
📚 Learning: in the prompt management system, users should be allowed to save empty prompts as this gives them th...
Learnt from: retrogtx
PR: Mail-0/Zero#1354
File: apps/mail/components/ui/prompts-dialog.tsx:148-159
Timestamp: 2025-06-20T05:34:41.297Z
Learning: In the prompt management system, users should be allowed to save empty prompts as this gives them the choice to disable certain AI functionality or start fresh. Validation should not prevent empty prompts from being saved.

Applied to files:

  • apps/server/src/lib/prompts.ts
📚 Learning: in apps/server/src/lib/driver/google.ts, the normalization of "draft" to "drafts" in the count() met...
Learnt from: retrogtx
PR: Mail-0/Zero#1734
File: apps/server/src/lib/driver/google.ts:211-221
Timestamp: 2025-07-15T06:46:33.349Z
Learning: In apps/server/src/lib/driver/google.ts, the normalization of "draft" to "drafts" in the count() method is necessary because the navigation item in apps/mail/config/navigation.ts has id: 'drafts' (plural) while the Google API returns "draft" (singular). The nav-main.tsx component matches stats by comparing stat.label with item.id, so the backend must return "drafts" for the draft counter badge to appear in the sidebar.

Applied to files:

  • apps/server/src/thread-workflow-utils/index.ts
🔇 Additional comments (1)
apps/server/src/lib/prompts.ts (1)

338-338: Outstanding move removing that trailing whitespace, my friend!

These changes are like optimizing rocket fuel efficiency - small but crucial improvements. The cleanup eliminates unnecessary whitespace in the system prompt, which is exactly the kind of precision engineering we need for consistent AI behavior.

Also applies to: 354-354, 538-538

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

No issues found across 2 files. Review in cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76b7330 and fc50bd7.

📒 Files selected for processing (2)
  • apps/server/src/lib/prompts.ts (3 hunks)
  • apps/server/src/thread-workflow-utils/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

**/*.{js,jsx,ts,tsx}: Use 2-space indentation
Use single quotes for strings
Limit lines to 100 characters in length
Semicolons are required at the end of statements

Files:

  • apps/server/src/thread-workflow-utils/index.ts
  • apps/server/src/lib/prompts.ts
**/*.{js,jsx,ts,tsx,css,scss}

📄 CodeRabbit Inference Engine (AGENT.md)

Use Prettier with sort-imports and Tailwind plugins for code formatting

Files:

  • apps/server/src/thread-workflow-utils/index.ts
  • apps/server/src/lib/prompts.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

Enable TypeScript strict mode

Files:

  • apps/server/src/thread-workflow-utils/index.ts
  • apps/server/src/lib/prompts.ts
**/*.{css,js,ts,jsx,tsx,mdx}

📄 CodeRabbit Inference Engine (.cursor/rules/tailwind-css-v4.mdc)

**/*.{css,js,ts,jsx,tsx,mdx}: Chain variants together for composable variants (e.g., group-has-data-potato:opacity-100).
Use new variants such as starting, not-*, inert, nth-*, in-*, open (for :popover-open), and ** for all descendants.
Do not use deprecated utilities like bg-opacity-*, text-opacity-*, border-opacity-*, and divide-opacity-*; use the new syntax (e.g., bg-black/50).
Use renamed utilities: shadow-sm is now shadow-xs, shadow is now shadow-sm, drop-shadow-sm is now drop-shadow-xs, drop-shadow is now drop-shadow-sm, blur-sm is now blur-xs, blur is now blur-sm, rounded-sm is now rounded-xs, rounded is now rounded-sm, outline-none is now outline-hidden.
Use bg-(--brand-color) syntax for CSS variables in arbitrary values instead of bg-[--brand-color].
Stacked variants now apply left-to-right instead of right-to-left.

Files:

  • apps/server/src/thread-workflow-utils/index.ts
  • apps/server/src/lib/prompts.ts
🧠 Learnings (3)
📚 Learning: in apps/server/src/lib/driver/google.ts, the normalization of "draft" to "drafts" in the count() met...
Learnt from: retrogtx
PR: Mail-0/Zero#1734
File: apps/server/src/lib/driver/google.ts:211-221
Timestamp: 2025-07-15T06:46:33.349Z
Learning: In apps/server/src/lib/driver/google.ts, the normalization of "draft" to "drafts" in the count() method is necessary because the navigation item in apps/mail/config/navigation.ts has id: 'drafts' (plural) while the Google API returns "draft" (singular). The nav-main.tsx component matches stats by comparing stat.label with item.id, so the backend must return "drafts" for the draft counter badge to appear in the sidebar.

Applied to files:

  • apps/server/src/thread-workflow-utils/index.ts
📚 Learning: in the prompt management system, users should be allowed to save empty prompts as this gives them th...
Learnt from: retrogtx
PR: Mail-0/Zero#1354
File: apps/mail/components/ui/prompts-dialog.tsx:148-159
Timestamp: 2025-06-20T05:34:41.297Z
Learning: In the prompt management system, users should be allowed to save empty prompts as this gives them the choice to disable certain AI functionality or start fresh. Validation should not prevent empty prompts from being saved.

Applied to files:

  • apps/server/src/lib/prompts.ts
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : limit lines to 100 characters in length...
Learnt from: CR
PR: Mail-0/Zero#0
File: AGENT.md:0-0
Timestamp: 2025-08-03T20:41:43.899Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Limit lines to 100 characters in length

Applied to files:

  • apps/server/src/lib/prompts.ts
🔇 Additional comments (1)
apps/server/src/lib/prompts.ts (1)

338-338: Excellent whitespace cleanup!

These trailing whitespace removals are precisely the kind of attention to detail that separates great code from mediocre code. Like removing unnecessary mass from a rocket - every bit of efficiency matters. The prompt functionality remains intact while the code becomes cleaner.

Also applies to: 354-354, 538-538

@ahmetskilinc ahmetskilinc merged commit fae9457 into staging Aug 7, 2025
8 checks passed
Copy link
Contributor Author

Merge activity

@ahmetskilinc ahmetskilinc deleted the 08-07-wip_of_new_prompt_for_compose branch August 7, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant