Skip to content

🐛(frontend) fix outlook web handler in unquote logic#754

Merged
jbpenrath merged 1 commit into
mainfrom
fix/quote-message
Jul 20, 2026
Merged

🐛(frontend) fix outlook web handler in unquote logic#754
jbpenrath merged 1 commit into
mainfrom
fix/quote-message

Conversation

@jbpenrath

@jbpenrath jbpenrath commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Purpose

About the unquote-message logic, we encount a bug with a thread implying Outlook Desktop quotes. Actually, for Outlook web we were looking for a hr tag as quote separtor element. But sometimes this one can be wrap into a div and we missed it.

Summary by CodeRabbit

  • Bug Fixes
    • Improved removal of quoted content from Microsoft Outlook Web replies, including cases with nested wrapper elements.
    • Enhanced Outlook Desktop reply separator handling to recognize both standalone and wrapped horizontal rules.
    • Improved boundary detection to better preserve the actual reply content.
  • Tests
    • Added additional coverage for Microsoft Outlook Web and Desktop quote-removal scenarios, including custom detect cases and edge conditions.

@jbpenrath jbpenrath self-assigned this Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Microsoft Outlook Web quote detection now climbs nested wrappers before collecting quote siblings. Outlook Desktop detection recognizes wrapped <hr> separators. Custom detection tests cover nested wrappers, wrapped separators, and quote boundary behavior.

Changes

Outlook quote detection

Layer / File(s) Summary
Expand Outlook detection logic
src/frontend/src/features/utils/unquote-message/handlers.ts
Outlook Web traversal climbs eligible wrapper <div> levels, and Outlook Desktop recognizes both direct and wrapped <hr> separators.
Add Outlook regression coverage
src/frontend/src/features/utils/unquote-message/index.test.ts
Adds tests for wrapped Desktop separators, nested Web headers, preserved preceding reply text, and continued traversal past quoted text nodes.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing Outlook Web handling in the unquote-message logic.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/frontend/src/features/utils/unquote-message/handlers.ts`:
- Around line 155-160: Update the sibling detection around msoRoot to inspect
parentElement.childNodes so plain-text nodes are included, but only consider
nodes positioned before msoRoot. Preserve the existing non-empty text check via
trimmed textContent and break when a preceding sibling contains content,
avoiding quoted nodes that follow msoRoot.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c185b923-67b7-4034-b13a-ee888e256175

📥 Commits

Reviewing files that changed from the base of the PR and between 39f2d9c and 6f83b71.

📒 Files selected for processing (2)
  • src/frontend/src/features/utils/unquote-message/handlers.ts
  • src/frontend/src/features/utils/unquote-message/index.test.ts

Comment thread src/frontend/src/features/utils/unquote-message/handlers.ts Outdated
About the unquote-message logic, we encount a bug with a thread
implying Outlook Desktop quotes. Actually, for Outlook web we were looking for
a hr tag as quote separtor element. But sometimes this one can be wrap into a div
and we missed it.
@jbpenrath
jbpenrath force-pushed the fix/quote-message branch from 6f83b71 to 7b2528b Compare July 20, 2026 08:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/frontend/src/features/utils/unquote-message/handlers.ts`:
- Around line 158-169: Update the preceding-sibling check in the unquote-message
traversal to walk backward from msoRoot.previousSibling using previousSibling,
stopping when a qualifying ELEMENT_NODE or non-empty TEXT_NODE is found. Remove
the siblings Array.from and previousSiblings.slice allocations while preserving
the existing break behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac70cdeb-0dcf-4c39-a68c-19844bbbb335

📥 Commits

Reviewing files that changed from the base of the PR and between 6f83b71 and 7b2528b.

📒 Files selected for processing (2)
  • src/frontend/src/features/utils/unquote-message/handlers.ts
  • src/frontend/src/features/utils/unquote-message/index.test.ts

Comment on lines +158 to 169
const siblings = Array.from(msoRoot.parentElement.childNodes);
const previousSiblings = siblings.slice(0, siblings.indexOf(msoRoot));
if (
previousSiblings.some(
(node) =>
(node.nodeType === Node.ELEMENT_NODE ||
node.nodeType === Node.TEXT_NODE) &&
node.textContent?.trim()
)
) {
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optimize preceding sibling traversal to avoid array allocations.

Instead of creating intermediate arrays for all child nodes and slicing them on every climb iteration, you can traverse backwards using previousSibling. This avoids O(N) array allocations within the loop while achieving the same logic.

♻️ Proposed refactor
-          const siblings = Array.from(msoRoot.parentElement.childNodes);
-          const previousSiblings = siblings.slice(0, siblings.indexOf(msoRoot));
-          if (
-            previousSiblings.some(
-              (node) =>
-                (node.nodeType === Node.ELEMENT_NODE ||
-                  node.nodeType === Node.TEXT_NODE) &&
-                node.textContent?.trim()
-            )
-          ) {
-            break;
-          }
+          let hasMeaningfulContent = false;
+          let current = msoRoot.previousSibling;
+
+          while (current) {
+            if (
+              (current.nodeType === Node.ELEMENT_NODE ||
+                current.nodeType === Node.TEXT_NODE) &&
+              current.textContent?.trim()
+            ) {
+              hasMeaningfulContent = true;
+              break;
+            }
+            current = current.previousSibling;
+          }
+
+          if (hasMeaningfulContent) {
+            break;
+          }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const siblings = Array.from(msoRoot.parentElement.childNodes);
const previousSiblings = siblings.slice(0, siblings.indexOf(msoRoot));
if (
previousSiblings.some(
(node) =>
(node.nodeType === Node.ELEMENT_NODE ||
node.nodeType === Node.TEXT_NODE) &&
node.textContent?.trim()
)
) {
break;
}
let hasMeaningfulContent = false;
let current = msoRoot.previousSibling;
while (current) {
if (
(current.nodeType === Node.ELEMENT_NODE ||
current.nodeType === Node.TEXT_NODE) &&
current.textContent?.trim()
) {
hasMeaningfulContent = true;
break;
}
current = current.previousSibling;
}
if (hasMeaningfulContent) {
break;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/frontend/src/features/utils/unquote-message/handlers.ts` around lines 158
- 169, Update the preceding-sibling check in the unquote-message traversal to
walk backward from msoRoot.previousSibling using previousSibling, stopping when
a qualifying ELEMENT_NODE or non-empty TEXT_NODE is found. Remove the siblings
Array.from and previousSiblings.slice allocations while preserving the existing
break behavior.

@jbpenrath
jbpenrath merged commit 1eb68ee into main Jul 20, 2026
15 checks passed
@jbpenrath
jbpenrath deleted the fix/quote-message branch July 20, 2026 08:55
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