Skip to content

Development - #768

Draft
jbpenrath wants to merge 5 commits into
mainfrom
development
Draft

Development#768
jbpenrath wants to merge 5 commits into
mainfrom
development

Conversation

@jbpenrath

@jbpenrath jbpenrath commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Purpose

Intermediate branch

Summary by CodeRabbit

  • Bug Fixes
    • Improved email thread matching when replies rewrite their subject lines.
    • Replies with In-Reply-To headers now remain in the original conversation even when the subject changes.
    • Improved normalization of reply and forward prefixes, including formats without a space after the colon.
    • Messages relying only on References are matched more accurately, preventing unrelated messages from being grouped together.

@jbpenrath jbpenrath assigned jbpenrath and unassigned jbpenrath Jul 29, 2026
@jbpenrath
jbpenrath marked this pull request as draft July 29, 2026 11:34
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f3a0e549-8770-4a5e-bfde-0057adb92290

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Inbound and imported messages now use a unified thread resolver. In-Reply-To takes precedence over subject matching, while References requires canonicalized subject equality. Subject prefixes without post-colon spacing are normalized, and tests cover rewritten-subject conversations.

Changes

Inbound threading

Layer / File(s) Summary
Thread resolution rules
src/backend/core/mda/inbound_create.py
Subject canonicalization accepts prefixes without spacing, parent messages are selected newest-first, and unified resolution applies In-Reply-To precedence or subject-validated References matching.
Message creation integration
src/backend/core/mda/inbound_create.py
Message creation uses find_thread_for_message for both inbound delivery and imports.
Threading behavior validation
src/backend/core/tests/mda/test_inbound.py, src/backend/core/tests/api/test_inbound_mta.py
Tests cover rewritten subjects, References-only mismatches, no-space Re: normalization, helper integration, and multi-message SMTP threading.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SMTPClient
  participant InboundMTA
  participant MessageCreation
  participant ThreadResolver
  participant Mailbox
  SMTPClient->>InboundMTA: deliver email
  InboundMTA->>MessageCreation: parse inbound message
  MessageCreation->>ThreadResolver: find_thread_for_message
  ThreadResolver->>Mailbox: query In-Reply-To and References parents
  Mailbox-->>ThreadResolver: matching parent messages
  ThreadResolver-->>MessageCreation: matching thread or None
  MessageCreation-->>InboundMTA: create message in selected thread
Loading

Possibly related PRs

Suggested reviewers: sylvinus

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic and does not describe the inbound threading changes in this pull request. Use a concise title that names the main change, such as inbound reply threading with rewritten subjects.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

@jbpenrath jbpenrath changed the title 🐛(inbound) thread replies whose subject was rewritten (#765) Development Jul 29, 2026
A reply carrying In-Reply-To to a message we already hold was still
rejected when its subject differed, because the delivery path required
both a reference match and an identical canonical subject. A subject
edited mid-conversation therefore started a brand new thread.

The import path had its own laxer rule (message-ids only), so the very
same conversation was grouped differently depending on whether it was
imported or received over SMTP.

Both paths now share find_thread_for_message: In-Reply-To is trusted on
its own (RFC 8621 §3 only allows splitting on subject, never requires
it), while References — which some clients recycle to start unrelated
topics — still needs a matching canonical subject. The canonicalization
also accepts "Re:subject" with no space, common on mobile clients.
Currently when a user paste content into the composer,
if this one has text or background color, this is preserved as is
then export into the output. Now only color supported by
blocknote are preserved and exported. We also apply this
sanitization to table elements.

Furthermore, we also drop unsupported blocks (file, audio, video)
and fix a bug that prevent to embed external images.
Use the new preview_text method of jmap_email to generate
clean snippet for thread (denormalized at update_stats)
and message (at serialization). Now when a mesage is folded, we
display this snippet. In the thread list we also display this snippet above
the subject.
Put app name as suffix not prefix of the page title.
Align all document title accross the app.
Mailbox Name - Folder Name - App Name
Do not fetch stats for sent folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant