Skip to content

Conversation

@Tsopic
Copy link

@Tsopic Tsopic commented Jan 20, 2026

Summary

  • Adds a new user preference setting that allows users to configure emails to open in a new browser tab by default instead of inline preview
  • When enabled on web platform, clicking an email will automatically open it in a new browser tab
  • Preference is stored locally using SharedPreferences
  • Web-only feature: Toggle is hidden on mobile/desktop platforms where browser tabs don't apply

Changes

  • New files:
    • OpenEmailInNewWindowConfig - Preference model with JSON serialization
    • OpenEmailInNewWindowExtension - Dashboard extension to load preference at startup
  • Modified files:
    • PreferencesSettingManager - Added persistence methods for new config
    • PreferencesSetting - Added getter for new config
    • PreferencesOptionType - Added enum value with UI text methods
    • PreferencesController - Added toggle handler for the setting
    • MailboxDashBoardController - Added reactive variable, load call, and reload after Settings
    • PreferencesView - Added platform check to hide toggle on non-web platforms
    • ThreadController - Checks preference on email preview action
    • AppLocalizations - Added localization strings

Tests (21 tests)

  • OpenEmailInNewWindowConfig unit tests (14 tests):
    • Constructor defaults, JSON serialization/deserialization
    • Null/missing field handling, copyWith extension, equality comparison
  • PreferencesSettingManager persistence tests (7 tests):
    • get/update methods, round-trip verification, loadPreferences integration

Test plan

  • Navigate to Settings > Preferences (on web)
  • Verify "Open emails in new window" toggle is visible
  • Toggle "Open emails in new window" ON
  • Click an email in mailbox list - should open in new browser tab
  • Toggle setting OFF
  • Click an email - should open inline in current view
  • Verify setting persists after app refresh
  • Verify setting applies immediately without restart
  • Verify toggle is NOT visible on mobile/desktop builds

🤖 Generated with Claude Code

Adds a new user preference setting that allows users to configure
emails to open in a new browser tab by default instead of inline preview.
When enabled on web platform, clicking an email will automatically
open it in a new browser tab.

Changes:
- Add OpenEmailInNewWindowConfig preference model
- Integrate with PreferencesSettingManager for persistence
- Add preferences toggle in settings UI via PreferencesOptionType
- Load preference at dashboard startup via extension
- Use preference in ThreadController email preview action

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

Walkthrough

This pull request introduces a new "Open emails in new window" feature that allows users to configure whether clicking on emails opens them in a new browser tab instead of the current view. The implementation includes a new configuration model, integration into the preferences system, updates to the mailbox dashboard controller to load and expose the configuration state, localization strings for UI labels, and conditional logic in the thread controller to route email preview actions to the new tab opening flow when the feature is enabled on web.

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • dab246
  • hoangdat
  • tddang-linagora
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly matches the main feature being added: a new user preference to open emails in a new window, which is clearly articulated in the objectives and reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

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

Copy link

@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

🤖 Fix all issues with AI agents
In
`@lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart`:
- Around line 140-141: The controller currently reads
isOpenEmailInNewWindowEnabled only in onReady (in MailboxDashboardController),
so changes in Settings won’t apply until restart; update the controller to
refresh preferences after returning from the Settings flow (or subscribe to
local settings changes) by invoking the same preference-loading logic used in
onReady — e.g., add a public method like reloadPreferences()/loadSettings() that
re-reads the preference flags (isOpenEmailInNewWindowEnabled and any
reopenComposerCache flag from reopen_composer_cache_extension), call that method
after the Settings navigation completes (or wire it to the settings change
stream) and ensure any UI/state consumers are updated accordingly.
🧹 Nitpick comments (1)
lib/features/mailbox_dashboard/presentation/extensions/open_email_in_new_window_extension.dart (1)

7-18: Narrow the try/catch around getBinding usage; null checks don't throw exceptions.
getBinding<T>() returns null rather than throwing when a binding is not found. The current broad try/catch wraps the entire method unnecessarily and masks errors from the actual async operation. Move the null check outside and only guard the async call.

♻️ Suggested refactor
-  Future<void> loadOpenEmailInNewWindowConfig() async {
-    try {
-      final preferencesManager = getBinding<PreferencesSettingManager>();
-      if (preferencesManager != null) {
-        final config = await preferencesManager.getOpenEmailInNewWindowConfig();
-        isOpenEmailInNewWindowEnabled.value = config.isEnabled;
-        log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: isEnabled = ${config.isEnabled}');
-      }
-    } catch (e) {
-      log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: error = $e');
-      isOpenEmailInNewWindowEnabled.value = false;
-    }
-  }
+  Future<void> loadOpenEmailInNewWindowConfig() async {
+    final preferencesManager = getBinding<PreferencesSettingManager>();
+    if (preferencesManager == null) {
+      log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: PreferencesSettingManager not registered');
+      isOpenEmailInNewWindowEnabled.value = false;
+      return;
+    }
+    try {
+      final config = await preferencesManager.getOpenEmailInNewWindowConfig();
+      isOpenEmailInNewWindowEnabled.value = config.isEnabled;
+      log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: isEnabled = ${config.isEnabled}');
+    } catch (e) {
+      log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: error = $e');
+      isOpenEmailInNewWindowEnabled.value = false;
+    }
+  }

Tsopic and others added 3 commits January 20, 2026 20:29
- Add unit tests for OpenEmailInNewWindowConfig model (14 tests)
  - Constructor defaults, JSON serialization/deserialization
  - copyWith extension, equality comparison
- Add persistence tests for PreferencesSettingManager (7 tests)
  - get/update methods, round-trip verification
  - loadPreferences integration

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The feature only works on web (uses browser tabs), so hiding the
toggle on mobile and desktop prevents user confusion.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The preference was only loaded in onReady(), so changes made in Settings
wouldn't apply until app restart. Now loadOpenEmailInNewWindowConfig()
is called after both goToSettings() and goToVacationSetting() return,
matching the pattern used for loadAIScribeConfig().

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Comment on lines +1206 to +1207
} else if (PlatformInfo.isWeb && mailboxDashBoardController.isOpenEmailInNewWindowEnabled.value) {
openEmailInNewTabAction(selectedEmail);
Copy link
Member

Choose a reason for hiding this comment

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

Note: This function only supports opening emails in a new tab, not a new window. If you want to open them in a new window, please rewrite the function.

Copy link
Collaborator

@tddang-linagora tddang-linagora left a comment

Choose a reason for hiding this comment

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

  • Generate and commit updated arb
  • Stop the infinite email opening
Screen.Recording.2026-01-26.at.10.28.31.AM.mov

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.

3 participants