Skip to content

Conversation

@JoaquinVeraOrtega
Copy link

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

After these steps, you're ready to open a pull request.

 Describe your changes:

Add connection_error_message variable to Config class and change the add_hooks method in ConnectionToaster class to show the custom message from the config only in production mode.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 20, 2025

Greptile Summary

  • Adds optional connection_error_message field to BaseConfig class enabling custom connection error messages in production mode
  • Modifies ConnectionToaster.add_hooks() method to display custom error messages from config in production while preserving technical details in development mode

Important Files Changed

Filename Overview
reflex/config.py Added nullable connection_error_message field to BaseConfig class for customizable connection error messaging
reflex/components/core/banner.py Updated toast notification logic to use custom error messages in production mode while preserving debug info in development

Confidence Score: 4/5

  • This PR is safe to merge with minor concerns about edge case handling in production mode
  • Score reflects good implementation of dev/prod mode separation but lowered due to potential empty string issue in loading_message fallback and lack of tests for the new feature
  • Pay close attention to reflex/components/core/banner.py for the empty string fallback in loading_message logic

Sequence Diagram

sequenceDiagram
    participant User
    participant ConfigModule as "rxconfig.py"
    participant Config
    participant ConnectionToaster
    participant Environment
    participant ToastSystem as "Toast System"

    User->>ConfigModule: "Define connection_error_message in config"
    ConfigModule->>Config: "Initialize with connection_error_message"
    Config->>Config: "_post_init() - setup config"
    Config->>Config: "update_from_env() - check environment variables"
    Config->>ConnectionToaster: "get_config() called during add_hooks()"
    ConnectionToaster->>Environment: "Check REFLEX_ENV_MODE"
    Environment-->>ConnectionToaster: "Return environment mode (DEV/PROD)"
    ConnectionToaster->>ConnectionToaster: "Determine message based on mode and config"
    alt Development Mode or No Custom Message
        ConnectionToaster->>ToastSystem: "Show default error message with server URL"
    else Production Mode with Custom Message
        ConnectionToaster->>ToastSystem: "Show custom connection_error_message from config"
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. reflex/components/core/banner.py, line 142-145 (link)

    logic: Setting loading_message to empty string in production with custom error message may result in a blank toast notification, which could confuse users. Should the loading_message use the custom error message instead of an empty string when config.connection_error_message is set?

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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