diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index cf087e99a..6b03d8dc2 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -1493,6 +1493,7 @@ def fetch_and_prompt_with_remote_templates( if not show_prompt and (template not in available_templates): console.error(f"{template!r} is not a valid template name.") + redir.open_browser(constants.Templates.REFLEX_TEMPLATES_URL) template = ( prompt_for_remote_template_selection(available_templates) if available_templates diff --git a/reflex/utils/redir.py b/reflex/utils/redir.py index 1dbd989e9..b35cbe26e 100644 --- a/reflex/utils/redir.py +++ b/reflex/utils/redir.py @@ -10,6 +10,18 @@ from .. import constants from . import console +def open_browser(target_url: str) -> None: + """Open a browser window to target_url. + + Args: + target_url: The URL to open in the browser. + """ + if not webbrowser.open(target_url): + console.warn( + f"Unable to automatically open the browser. Please navigate to {target_url} in your browser." + ) + + def open_browser_and_wait( target_url: str, poll_url: str, interval: int = 2 ) -> httpx.Response: @@ -23,10 +35,7 @@ def open_browser_and_wait( Returns: The response from the poll_url. """ - if not webbrowser.open(target_url): - console.warn( - f"Unable to automatically open the browser. Please navigate to {target_url} in your browser." - ) + open_browser(target_url) console.info("[b]Complete the workflow in the browser to continue.[/b]") while True: try: