Skip to content

Comments

Feat: Added open in new tab option for threads#1552

Closed
samrathreddy wants to merge 4 commits intoMail-0:stagingfrom
samrathreddy:feat/thread-in-new-window
Closed

Feat: Added open in new tab option for threads#1552
samrathreddy wants to merge 4 commits intoMail-0:stagingfrom
samrathreddy:feat/thread-in-new-window

Conversation

@samrathreddy
Copy link
Contributor

@samrathreddy samrathreddy commented Jun 29, 2025

Description

Added option to provide threads in new window


Type of Change

Please delete options that are not relevant.

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature with breaking changes)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • 🔒 Security enhancement
  • ⚡ Performance improvement

Areas Affected

Please check all that apply:

  • Email Integration (Gmail, IMAP, etc.)
  • User Interface/Experience
  • Authentication/Authorization
  • Data Storage/Management
  • API Endpoints
  • Documentation
  • Testing Infrastructure
  • Development Workflow
  • Deployment/Infrastructure

Testing Done

Describe the tests you've done:

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • Cross-browser testing (if UI changes)
  • Mobile responsiveness verified (if UI changes)

Security Considerations

For changes involving data or authentication:

  • No sensitive data is exposed
  • Authentication checks are in place
  • Input validation is implemented
  • Rate limiting is considered (if applicable)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • I have updated the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix/feature works
  • All tests pass locally
  • Any dependent changes are merged and published

Additional Notes

Add any other context about the pull request here.

Screenshots/Recordings

Before:
image

After:

Screen.Recording.2025-06-30.at.12.31.50.AM.mov

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features
    • Added an "Open in new tab" action to email thread menus, allowing threads to be opened in a popup window.
    • Introduced a dedicated popup view for displaying email threads in a full-screen overlay.
  • Improvements
    • Enhanced localization with new messages for popup actions and error handling.
  • Bug Fixes
    • Added user notifications for blocked or failed popup attempts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

Walkthrough

A new popup view for email threads was introduced, including a dedicated route and React components to render threads in a popup window. Context menus and dropdowns now offer an "Open in new tab" action, which opens the thread in a custom-sized popup. Localization strings for related UI messages were also added.

Changes

File(s) Change Summary
apps/mail/app/(full-width)/popup/thread/page.tsx Added ThreadPopup component to handle popup thread display and manage state from URL parameters.
apps/mail/app/routes.ts Registered new route /popup/thread for the popup thread view.
apps/mail/components/context/thread-context.tsx Added "Open in new tab" action to thread context menu with popup logic and error handling.
apps/mail/components/mail/mail-display.tsx Added optional isPopup prop to MailDisplay component.
apps/mail/components/mail/popup-thread-display.tsx Introduced PopupThreadDisplay component for rendering threads in popup UI, including attachment aggregation.
apps/mail/components/mail/thread-display.tsx Added "Open in new tab" dropdown menu item with popup logic and error handling; reorganized print menu placement.
apps/mail/locales/en.json Added localization strings for popup actions and error messages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ThreadContextMenu
    participant ThreadDisplay
    participant Browser
    participant PopupThreadDisplay

    User->>ThreadContextMenu: Right-click thread, select "Open in new tab"
    ThreadContextMenu->>Browser: window.open(popup URL)
    alt Popup allowed
        Browser->>PopupThreadDisplay: Render thread in popup window
    else Popup blocked
        ThreadContextMenu->>ThreadContextMenu: Show "Popup blocked" toast
    end

    User->>ThreadDisplay: Click dropdown, select "Open in new tab"
    ThreadDisplay->>Browser: window.open(popup URL)
    alt Popup allowed
        Browser->>PopupThreadDisplay: Render thread in popup window
    else Popup blocked
        ThreadDisplay->>ThreadDisplay: Show "Popup blocked" toast
    end
Loading

Possibly related PRs

  • context menu #708: Adds "Open in new tab" action to thread context menu in thread-context.tsx, closely related to this PR’s context menu enhancements.
  • threadid in url when user opens email #492: Synchronizes threadId in URL with mail list selection and thread display components, relevant for thread selection via URL query parameters.

Suggested reviewers

  • MrgSub

Poem

A popup thread, a window new,
With emails bright and actions true.
"Open in new tab!" the rabbit cries,
Attachments gathered, messages wise.
If popups blocked, don’t feel blue—
A gentle toast will comfort you.
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12216c5 and 1fa74d7.

📒 Files selected for processing (2)
  • apps/mail/app/(full-width)/popup/thread/page.tsx (1 hunks)
  • apps/mail/components/mail/popup-thread-display.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/mail/app/(full-width)/popup/thread/page.tsx
  • apps/mail/components/mail/popup-thread-display.tsx
✨ 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.
    • 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.
    • @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 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.
    • @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.

@samrathreddy samrathreddy changed the title Feat/thread in new window Feat: Added open in new tab option for threads Jun 29, 2025
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: 2

🧹 Nitpick comments (1)
apps/mail/components/mail/thread-display.tsx (1)

737-761: Consider extracting shared popup logic to reduce code duplication.

The function works correctly but duplicates the same logic found in thread-context.tsx (lines 270-296). This violates the DRY principle and makes maintenance harder.

Consider creating a shared utility function:

// utils/popup-utils.ts
export const openThreadInNewTab = (threadId: string, t: (key: string, options?: any) => string) => {
  try {
    const baseUrl = window.location.origin;
    const encodedThreadId = encodeURIComponent(threadId);
    const popupUrl = `${baseUrl}/popup/thread?threadId=${encodedThreadId}`;
    const popup = window.open(
      popupUrl,
      `thread-${encodedThreadId}`,
      'width=800,height=600,resizable=yes,status=no,location=no,toolbar=no,menubar=no'
    );

    if (!popup) {
      toast.error(
        t('common.actions.popupBlocked', {
          fallback: 'Popup blocked. Please allow popups for this site.',
        })
      );
    }
  } catch (error) {
    console.error('Failed to open popup:', error);
    toast.error(
      t('common.actions.failedToOpenPopup', {
        fallback: 'Failed to open thread in new tab.',
      })
    );
  }
};

Then use it in both components:

const handleOpenInNewTab = useCallback(() => {
  if (!id) return;
  openThreadInNewTab(id, t);
}, [id, t]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 59c18be and d1519d6.

📒 Files selected for processing (7)
  • apps/mail/app/(full-width)/popup/thread/page.tsx (1 hunks)
  • apps/mail/app/routes.ts (1 hunks)
  • apps/mail/components/context/thread-context.tsx (3 hunks)
  • apps/mail/components/mail/mail-display.tsx (1 hunks)
  • apps/mail/components/mail/popup-thread-display.tsx (1 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
  • apps/mail/locales/en.json (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: danteissaias
PR: Mail-0/Zero#902
File: apps/mail/components/connection/add.tsx:77-77
Timestamp: 2025-05-07T16:55:46.513Z
Learning: For the "Upgrade" link in AddConnectionDialog, using a proper <button> element instead of a <span> with onClick is recognized as an accessibility improvement but was deferred as out of scope in PR #902 (CSS variables PR).
apps/mail/app/routes.ts (1)
Learnt from: retrogtx
PR: Mail-0/Zero#1468
File: apps/server/src/trpc/routes/mail.ts:386-391
Timestamp: 2025-06-27T04:59:29.709Z
Learning: In apps/server/src/trpc/routes/mail.ts, the attachment processing logic conditionally handles mixed attachment types - it preserves existing File-like objects with arrayBuffer methods while only converting serialized attachments that need processing through toAttachmentFiles.
apps/mail/components/mail/thread-display.tsx (1)
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
apps/mail/components/context/thread-context.tsx (2)
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
Learnt from: danteissaias
PR: Mail-0/Zero#902
File: apps/mail/components/connection/add.tsx:77-77
Timestamp: 2025-05-07T16:55:46.513Z
Learning: For the "Upgrade" link in AddConnectionDialog, using a proper <button> element instead of a <span> with onClick is recognized as an accessibility improvement but was deferred as out of scope in PR #902 (CSS variables PR).
🧬 Code Graph Analysis (2)
apps/mail/app/(full-width)/popup/thread/page.tsx (1)
apps/mail/components/mail/popup-thread-display.tsx (1)
  • PopupThreadDisplay (10-77)
apps/mail/components/mail/thread-display.tsx (1)
apps/mail/components/icons/icons.tsx (1)
  • Printer (1748-1763)
🪛 Biome (1.9.4)
apps/mail/components/mail/popup-thread-display.tsx

[error] 18-18: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

🔇 Additional comments (12)
apps/mail/components/mail/mail-display.tsx (1)

297-297: LGTM! Clean prop addition for popup context.

The optional isPopup prop is well-designed and maintains backward compatibility while allowing the component to adjust its behavior when rendered in a popup window.

apps/mail/app/routes.ts (1)

16-16: LGTM! Route properly configured.

The new /popup/thread route is correctly placed under the full-width layout, which is appropriate for a popup thread view that needs maximum screen real estate.

apps/mail/locales/en.json (2)

60-61: LGTM! Well-crafted user feedback messages.

The popup-related error messages are clear and informative, providing users with actionable feedback when popup functionality fails.


214-214: LGTM! Clear UI label for the new feature.

The "Open in new tab" label is descriptive and follows the existing localization patterns in the threadDisplay section.

apps/mail/app/(full-width)/popup/thread/page.tsx (2)

18-21: LGTM! Document title setting is appropriate.

Setting the document title helps users identify the popup window when multiple tabs/windows are open.


23-29: LGTM! Clean full-screen container structure.

The container structure provides appropriate full-screen layout for the popup thread view.

apps/mail/components/context/thread-context.tsx (3)

15-15: Good addition of ExternalLink icon import.

The import is properly placed and will be used for the new "Open in new tab" action.


270-296: Well-implemented popup opening logic.

The function includes:

  • Proper URL encoding for security
  • Appropriate popup window features
  • Good error handling with user feedback
  • Popup blocking detection

The implementation follows best practices for opening popup windows.


320-326: Good integration of the new action.

The new "Open in new tab" action is properly integrated into the primaryActions array with appropriate icon, label, and handler.

apps/mail/components/mail/popup-thread-display.tsx (1)

24-76: Well-structured component with proper state handling.

The component properly:

  • Handles loading and empty states
  • Uses appropriate UI components and styling
  • Passes correct props to MailDisplay
  • Includes proper accessibility and responsive design

The conditional rendering logic is clear and the scrollable area implementation is appropriate.

apps/mail/components/mail/thread-display.tsx (2)

49-49: Good addition of ExternalLink import.

The import is properly added and will be used in the dropdown menu.


996-1014: Well-structured dropdown menu additions.

The new dropdown menu items are properly implemented:

  • Good use of event.stopPropagation() to prevent unintended behavior
  • Proper icon and text placement
  • Consistent styling with existing items
  • Logical placement of the print option alongside the new tab option

samrathreddy and others added 2 commits June 30, 2025 00:48
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@MrgSub
Copy link
Collaborator

MrgSub commented Jun 30, 2025

Please move to context menu

@samrathreddy
Copy link
Contributor Author

@MrgSub Could you please elaborate

@MrgSub
Copy link
Collaborator

MrgSub commented Jul 4, 2025

ThreadContextMenu is the place to add this button

@MrgSub MrgSub closed this Jul 4, 2025
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.

2 participants