feat: add ai hint that content contains ai generated text#13022
Conversation
21163d0 to
2f099a7
Compare
17eabe8 to
f884e5c
Compare
26ca113 to
59506e7
Compare
📝 WalkthroughWalkthroughThis change introduces an AI-generated content flag across the mail stack. The IMAP fetcher reads an Changes
Sequence Diagram(s)sequenceDiagram
participant ImapMessageFetcher
participant IMAPMessage
participant Message
participant ThreadEnvelope
ImapMessageFetcher->>ImapMessageFetcher: parseHeaders reads x-ai-generated
ImapMessageFetcher->>IMAPMessage: construct with isAiGenerated
IMAPMessage->>Message: toDbMessage sets flagAiGenerated
Message-->>ThreadEnvelope: jsonSerialize exposes flags.aiGenerated
ThreadEnvelope->>ThreadEnvelope: hasAiGeneratedContent computed
ThreadEnvelope->>ThreadEnvelope: render AI content label
Related issues: Suggested labels: enhancement, feature Suggested reviewers: GretaD, st3iny 🐰 A whisper of AI now tags each mail, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: eed45071-7465-42a0-93d9-22edd4613038
📒 Files selected for processing (6)
lib/Db/LocalMessage.phplib/Db/Message.phplib/IMAP/ImapMessageFetcher.phplib/Migration/Version5201Date20260604000000.phplib/Model/IMAPMessage.phpsrc/components/ThreadEnvelope.vue
💤 Files with no reviewable changes (1)
- lib/Db/LocalMessage.php
| display: flex; | ||
| align-items: center; | ||
| gap: 6px; | ||
| min-width: 0; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Replace hardcoded pixel gaps with Nextcloud CSS variables.
gap: 6px and gap: 4px are magic numbers. Per coding guidelines, spacing should use Nextcloud CSS variables (with calc() for finer control) rather than literal pixel values.
As per coding guidelines: "Use Nextcloud CSS variables for all CSS colors, spacing, and dimensions; do not use magic numbers. Use calc(x*var) when needing more specific control over dimensions with CSS variables."
♻️ Proposed fix
.sender {
margin-inline-start: calc(var(--default-grid-baseline) * 3);
display: flex;
align-items: center;
- gap: 6px;
+ gap: calc(var(--default-grid-baseline) * 1.5);
min-width: 0; .ai-generated-label {
display: flex;
align-items: center;
- gap: 4px;
+ gap: var(--default-grid-baseline);
opacity: 0.8;
}Also applies to: 1502-1508
Source: Coding guidelines
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end support for flagging messages as AI-generated: the composer can mark outgoing messages, the backend transmits/detects the flag via an email header and persists it on messages, and the UI surfaces a “Contains AI content” hint in the thread view.
Changes:
- Add a composer toggle (and auto-mark on smart reply) to mark outgoing mail as AI-generated and send it via
X-AI-Generated. - Detect
X-AI-Generatedon IMAP fetch and persist/expose the flag via message JSONflags.aiGenerated. - Show an AI label in the thread envelope when
flags.aiGeneratedis set.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/ThreadEnvelope.vue | Displays an AI-content label in the sender line based on envelope.flags.aiGenerated. |
| src/components/Composer.vue | Adds “Mark as AI generated” toggle and includes isAiGenerated in send payload; auto-sets it for smart replies. |
| lib/Service/MailTransmission.php | Adds X-AI-Generated: 1 header when sending AI-generated local messages. |
| lib/Model/IMAPMessage.php | Carries IMAP-detected AI flag into DB Message entity flags. |
| lib/Migration/Version5201Date20260604000000.php | Schema change related to AI-generated flag storage. |
| lib/IMAP/ImapMessageFetcher.php | Detects X-AI-Generated header during IMAP fetch. |
| lib/Db/Message.php | Persists/serializes flagAiGenerated into JSON flags.aiGenerated. |
| lib/Db/LocalMessage.php | Adds non-persisted aiGenerated flag on local messages (used for sending header). |
| lib/Controller/OutboxController.php | Accepts isAiGenerated in outbox create/update requests and sets it on the LocalMessage. |
5371779 to
b5bcfc2
Compare
Assisted-by: ClaudeCode:claude-sonnet-4-6 Assisted-by: Claude:claude-sonnet-5 Signed-off-by: greta <gretadoci@gmail.com>
b5bcfc2 to
4ee4979
Compare
|
|
||
| editorMode: (this.body?.format !== 'html') ? EDITOR_MODE_TEXT : EDITOR_MODE_HTML, | ||
| requestMdnVal: this.requestMdn, | ||
| isAiGeneratedVal: this.isAiGenerated, |
There was a problem hiding this comment.
Claude: Please also reset isAiGeneratedVal in reset method
| } | ||
| if (this.smartReply) { | ||
| this.bus.emit('append-to-body-at-cursor', this.smartReply) | ||
| this.isAiGeneratedVal = true |
There was a problem hiding this comment.
Claude flagged this block, because a onEditorReady event (e.g the user is changing the alias) would insert the smart reply again, reset isAiGeneratedVal to true, and overwrite the user's choice. I think it's okay for now to ignore it, but we should look into a better way as follow up.
fixes #12689
