Skip to content

Comments

Fix full draft not loading#428

Merged
elie222 merged 1 commit intomainfrom
fix/draft
May 10, 2025
Merged

Fix full draft not loading#428
elie222 merged 1 commit intomainfrom
fix/draft

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented May 10, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved the handling of asynchronous operations when enabling the reply tracker to ensure actions complete before navigation.
    • Enhanced email reply extraction to more accurately separate draft content from quoted messages, especially with complex nested HTML structures.
    • Updated email processing logic to skip archived threads, preventing unnecessary processing of archived emails.
  • Tests

    • Added a new test case to verify correct extraction of reply content from complex email drafts.

@vercel
Copy link

vercel bot commented May 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero 🔄 Building (Inspect) Visit Preview May 10, 2025 7:21pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 10, 2025

Walkthrough

The changes introduce improved asynchronous handling in the reply tracker enabling flow, refine the logic for extracting email replies from HTML, add a new test for complex draft extraction, and update the reply tracker to skip archived email threads during processing.

Changes

File(s) Change Summary
apps/web/app/(app)/[emailAccountId]/reply-zero/EnableReplyTracker.tsx Added await to ensure processPreviousSentEmailsAction completes before navigation proceeds.
apps/web/utils/parse/extract-reply.client.ts Updated logic to extract the reply draft directly from the parsed document, not a substring.
apps/web/utils/parse/extract-reply.client.test.ts Added a new test case for extracting replies from complex nested HTML drafts.
apps/web/utils/reply-tracker/check-previous-emails.ts Added logic to skip processing archived threads (threads with no messages in the "INBOX").

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant ReplyTracker
    participant Router

    User->>UI: Enable Reply Tracker
    UI->>ReplyTracker: processPreviousSentEmailsAction(emailAccountId)
    activate ReplyTracker
    ReplyTracker-->>UI: Promise resolves after processing (now awaited)
    deactivate ReplyTracker
    UI->>Router: router.push (after processing completes)
Loading

Possibly related PRs

Poem

A hop, a skip, a thread or two,
Now archived emails we bid adieu.
Replies extracted, nested and neat,
Async flows now can't be beat!
With every await, the code feels right—
The rabbit dances through the night. 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/(app)/[emailAccountId]/reply-zero/EnableReplyTracker.tsx

Oops! Something went wrong! :(

ESLint: 9.24.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/utils/parse/extract-reply.client.test.ts

Oops! Something went wrong! :(

ESLint: 9.24.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/utils/parse/extract-reply.client.ts

Oops! Something went wrong! :(

ESLint: 9.24.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

  • 1 others

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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

@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: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b3403a and 43ca57f.

📒 Files selected for processing (4)
  • apps/web/app/(app)/[emailAccountId]/reply-zero/EnableReplyTracker.tsx (1 hunks)
  • apps/web/utils/parse/extract-reply.client.test.ts (1 hunks)
  • apps/web/utils/parse/extract-reply.client.ts (1 hunks)
  • apps/web/utils/reply-tracker/check-previous-emails.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/utils/parse/extract-reply.client.test.ts (1)
apps/web/utils/parse/extract-reply.client.ts (1)
  • extractEmailReply (1-65)
apps/web/app/(app)/[emailAccountId]/reply-zero/EnableReplyTracker.tsx (1)
apps/web/utils/actions/reply-tracking.ts (1)
  • processPreviousSentEmailsAction (31-41)
🔇 Additional comments (3)
apps/web/utils/parse/extract-reply.client.ts (1)

33-38: Improved extraction of email reply content

The change improves the email reply extraction by directly using the DOM API to get the complete div[dir="ltr"] element instead of using substring operations. This is more reliable for complex HTML structures and should properly handle the full draft content.

apps/web/utils/parse/extract-reply.client.test.ts (1)

114-123: Good test coverage for complex email structures

This new test case validates that the extraction function correctly handles complex email structures with nested divs and line breaks. The test ensures that the full reply HTML is preserved while properly separating it from the quoted content.

apps/web/utils/reply-tracker/check-previous-emails.ts (1)

43-54: Optimization to skip processing archived threads

Good optimization to skip processing archived email threads. This will improve performance by avoiding unnecessary processing of threads that users have already archived, focusing only on active conversations.

toast.promise(
async () => {
processPreviousSentEmailsAction(emailAccountId);
await processPreviousSentEmailsAction(emailAccountId);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fixed asynchronous operation sequencing

Adding the await keyword ensures that email processing completes before navigation occurs. This fixes a potential race condition where the user might be redirected before the background task finishes, leading to incomplete data on the next page.

@elie222 elie222 merged commit d6c526c into main May 10, 2025
3 of 4 checks passed
@elie222 elie222 deleted the fix/draft branch December 18, 2025 23:06
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