Skip to content

Modularize preferences#4601

Draft
hoangdat wants to merge 1 commit into
linagora:masterfrom
chibenwa:refactor/preferences-option-registry
Draft

Modularize preferences#4601
hoangdat wants to merge 1 commit into
linagora:masterfrom
chibenwa:refactor/preferences-option-registry

Conversation

@hoangdat

@hoangdat hoangdat commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Restructured internal preference settings architecture to improve consistency and maintainability across account preference options (Read Receipt, Sender Priority, AI Label Categorization, Thread, Spam Report, AI Scribe, and Label preferences).

@codescene-delta-analysis codescene-delta-analysis 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.

Gates Failed
New code is healthy (1 new file with code health below 10.00)

Our agent can fix these. Install it.

Gates Passed
2 Quality Gates Passed

Reason for failure
New code is healthy Violations Code Health Impact
preference_option.dart 1 rule 9.69 Suppress

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

final session = context.session;
final accountId = context.accountId;
final current = context.serverOptions;
if (session == null || accountId == null || current == null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❌ New issue: Complex Conditional
ServerPreferenceOption.toggle has 1 complex conditionals with 2 branches, threshold = 2

Suppress

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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

Plan: Pro

Run ID: af375d56-6861-4ea5-ab1d-6aeb1d3fa450

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:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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
`@lib/features/manage_account/presentation/preferences/model/preference_option.dart`:
- Around line 107-110: The null-check block currently lumps all missing values
into NotFoundAccountIdException; update the logic in preference_option.dart to
check each nullable (session, accountId, current) separately and return a
Stream.value(Left(UpdateServerSettingFailure(...))) with the specific exception
for the missing value (e.g., NotFoundSessionException when session is null,
NotFoundAccountIdException when accountId is null,
NotFoundServerOptionsException or similar when current is null), ensuring the
returned exception type matches the failing validation case and keeping the
existing UpdateServerSettingFailure and Stream.value/Left wrapping.
🪄 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: CHILL

Plan: Pro

Run ID: e131f433-75aa-46a5-b4d3-6d84f8d8601d

📥 Commits

Reviewing files that changed from the base of the PR and between 426b166 and 47da63e.

📒 Files selected for processing (10)
  • lib/features/manage_account/presentation/model/preferences_option_type.dart
  • lib/features/manage_account/presentation/preferences/bindings/preferences_bindings.dart
  • lib/features/manage_account/presentation/preferences/model/preference_option.dart
  • lib/features/manage_account/presentation/preferences/model/preference_option_registry.dart
  • lib/features/manage_account/presentation/preferences/model/preference_options.dart
  • lib/features/manage_account/presentation/preferences/preferences_controller.dart
  • lib/features/manage_account/presentation/preferences/preferences_view.dart
  • lib/features/manage_account/presentation/preferences/widgets/preferences_option_item.dart
  • test/features/manage_account/presentation/model/preferences_option_type_test.dart
  • test/features/manage_account/presentation/preferences/preference_option_registry_test.dart
💤 Files with no reviewable changes (2)
  • test/features/manage_account/presentation/model/preferences_option_type_test.dart
  • lib/features/manage_account/presentation/model/preferences_option_type.dart

Comment on lines +107 to +110
if (session == null || accountId == null || current == null) {
return Stream.value(
Left(UpdateServerSettingFailure(NotFoundAccountIdException())),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Exception name doesn't match all validation cases.

The condition validates three nullable fields (session, accountId, current), but always returns NotFoundAccountIdException() regardless of which is actually null. This makes debugging harder when the real issue is a missing session or server options.

🔍 Suggested fix with specific exceptions
-    if (session == null || accountId == null || current == null) {
-      return Stream.value(
-        Left(UpdateServerSettingFailure(NotFoundAccountIdException())),
-      );
-    }
+    if (session == null) {
+      return Stream.value(
+        Left(UpdateServerSettingFailure(NotFoundSessionException())),
+      );
+    }
+    if (accountId == null) {
+      return Stream.value(
+        Left(UpdateServerSettingFailure(NotFoundAccountIdException())),
+      );
+    }
+    if (current == null) {
+      return Stream.value(
+        Left(UpdateServerSettingFailure(NotFoundServerSettingsException())),
+      );
+    }
🤖 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
`@lib/features/manage_account/presentation/preferences/model/preference_option.dart`
around lines 107 - 110, The null-check block currently lumps all missing values
into NotFoundAccountIdException; update the logic in preference_option.dart to
check each nullable (session, accountId, current) separately and return a
Stream.value(Left(UpdateServerSettingFailure(...))) with the specific exception
for the missing value (e.g., NotFoundSessionException when session is null,
NotFoundAccountIdException when accountId is null,
NotFoundServerOptionsException or similar when current is null), ensuring the
returned exception type matches the failing validation case and keeping the
existing UpdateServerSettingFailure and Stream.value/Left wrapping.

@hoangdat

hoangdat commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

LGTM but @tddang-linagora should we have E2E test to ensure the preference options are displayed well with our configuration

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