-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow custom toast message in production mode by adding optional connection_error_message arg in rx.config #6060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rror toaster in prod mode
…riable for readability
Greptile Summary
Important Files Changed
Confidence Score: 4/5
Sequence DiagramsequenceDiagram
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (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
| toast_id = "websocket-error" | ||
| target_url = WebsocketTargetURL.create() | ||
| config = get_config() | ||
| is_dev_mode = environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be simpler to change the responsibility of providing this to the config provider? meaning, in rxconfig you only provide connection error message when on prod
All Submissions:
Type of change
Please delete options that are not relevant.
Changes To Core Features:
After these steps, you're ready to open a pull request.
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.