Skip to content

Add SMTP Configuration Toggle#647

Merged
lucksus merged 1 commit intodevfrom
settings-smtp-toggle
Jan 23, 2026
Merged

Add SMTP Configuration Toggle#647
lucksus merged 1 commit intodevfrom
settings-smtp-toggle

Conversation

@lucksus
Copy link
Member

@lucksus lucksus commented Jan 22, 2026

Adds an enabled toggle to SMTP configuration, allowing users to temporarily disable email sending without losing their configuration settings.

Changes

Backend:

  • Added enabled: bool field to SmtpConfig in both app_state.rs and config.rs
  • Updated email sending logic to check enabled flag before sending emails
  • Modified validation to skip field checks when SMTP is disabled
  • Backward compatible: existing configs default to enabled: true

Frontend:

  • Added toggle control in Settings UI that auto-saves on change
  • Configuration fields hidden when SMTP is disabled
  • Settings are preserved when toggling off/on

Use Case

Enables testing multi-user mode with password-only authentication without having to delete and re-enter SMTP configuration each time.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added SMTP enable/disable toggle in email settings for convenient control of email functionality.
    • SMTP configuration fields now conditionally display and only appear when enabled.
    • Configuration validation and error messaging updated to reflect enabled/disabled states.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds an enabled boolean field to SMTP configuration structures across the Tauri and Rust Executor applications, implementing conditional validation and resolver logic to skip email operations when SMTP is disabled. Includes UI toggle for managing the enabled state.

Changes

Cohort / File(s) Summary
SMTP Config Structure Definition
rust-executor/src/config.rs, ui/src-tauri/src/app_state.rs
Added enabled: bool field to SmtpConfig and SmtpConfigDto structs. Updated serialization/deserialization to handle the new field with backwards compatibility (defaults to true when absent). Modified SmtpConfig::new() constructor to accept enabled as first parameter.
Resolver & Validation Logic
rust-executor/src/graphql/mutation_resolvers.rs, ui/src-tauri/src/commands/app.rs
Added filter checks on SMTP config retrieval to ensure enabled flag is true before proceeding. Modified set_smtp_config to conditionally validate SMTP fields only when config.enabled is true. Updated error messages to reflect that SMTP could be disabled.
Configuration Propagation
ui/src-tauri/src/lib.rs
Propagates enabled field from multi-user config into Rust Executor's SmtpConfig during initialization.
UI Toggle & Conditional Rendering
ui/src/components/Settings.tsx
Introduced SMTP Enable/Disable toggle in Settings component. Added conditional rendering of SMTP configuration fields (Host, Port, Username, Password, From Address) only when smtpConfig.enabled is true. Defaults enabled to true on initial load.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Settings.tsx
    participant Tauri as Tauri App<br/>(commands/app.rs)
    participant State as app_state.rs
    participant Executor as rust-executor<br/>(mutation_resolvers.rs)

    User->>UI: Toggle SMTP enabled
    UI->>UI: Update smtpConfig.enabled state
    UI->>Tauri: set_smtp_config(smtpConfig)
    activate Tauri
    Tauri->>Tauri: Validate fields only if<br/>config.enabled == true
    alt enabled && fields invalid
        Tauri-->>UI: Error
    else enabled && fields valid
        Tauri->>State: Save to state
        State->>State: Serialize with enabled field
        Tauri-->>UI: Success
    else not enabled
        Tauri->>State: Save disabled state
        State->>State: Serialize with enabled: false
        Tauri-->>UI: Success
    end
    deactivate Tauri

    Note over Executor: Later: User triggers email operation
    UI->>Executor: Trigger mutation (e.g., login/test email)
    activate Executor
    Executor->>Executor: Filter SMTP config<br/>where config.enabled == true
    alt no enabled config
        Executor-->>UI: Error: "SMTP is disabled"
    else enabled config exists
        Executor->>Executor: Proceed with email
        Executor-->>UI: Success
    end
    deactivate Executor
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jhweir

Poem

🐰 A toggle here, a boolean there,
SMTP blooms with thoughtful care,
Disabled gracefully, enabled with cheer,
Email flows freely when conditions are clear! ✨📧

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add SMTP Configuration Toggle' accurately describes the main change across all modified files, which introduces an enabled/disabled toggle for SMTP settings.

✏️ 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
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/src/components/Settings.tsx (1)

669-869: Show the restart-required warning even when SMTP is toggled off.

The warning is inside the smtpConfig.enabled block, so disabling SMTP hides it even though changes still require a restart. Consider moving the warning outside the enabled-only section or placing it next to the toggle.

🛠️ Suggested fix
               <j-box px="500" my="500">
                 <j-toggle
                   checked={smtpConfig.enabled}
                   onChange={(e) => {
                     const newConfig = { ...smtpConfig, enabled: (e.target as HTMLInputElement).checked };
                     setSmtpConfig(newConfig);
                     handleSmtpConfigChange(newConfig);
                   }}
                 >
                   Enable Email/SMTP
                 </j-toggle>
               </j-box>
 
+              {/* Restart Required Warning */}
+              {smtpChanged && (
+                <j-box px="500" my="500">
+                  <j-box p="400" style={{
+                    backgroundColor: "#fff3cd",
+                    borderRadius: "8px",
+                    border: "1px solid `#ffc107`"
+                  }}>
+                    <j-flex a="center" gap="300">
+                      <j-icon name="exclamation-triangle" color="warning"></j-icon>
+                      <j-text size="500">
+                        Restart required: SMTP settings will take effect after restarting the launcher.
+                      </j-text>
+                    </j-flex>
+                  </j-box>
+                </j-box>
+              )}
+
               {smtpConfig.enabled && (
                 <>
                   {/* SMTP Host */}
                   ...
-                  {/* Restart Required Warning */}
-                  {smtpChanged && (
-                    <j-box px="500" my="500">
-                      <j-box p="400" style={{
-                        backgroundColor: "#fff3cd",
-                        borderRadius: "8px",
-                        border: "1px solid `#ffc107`"
-                      }}>
-                        <j-flex a="center" gap="300">
-                          <j-icon name="exclamation-triangle" color="warning"></j-icon>
-                          <j-text size="500">
-                            Restart required: SMTP settings will take effect after restarting the launcher.
-                          </j-text>
-                        </j-flex>
-                      </j-box>
-                    </j-box>
-                  )}
                   ...
                 </>
               )}

@lucksus lucksus merged commit 14bbf46 into dev Jan 23, 2026
5 checks passed
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