Skip to content

Using a custom browser #11709

@gershu-ar

Description

@gershu-ar

Feature Idea

The Situation
Feature request with proposed solution; sorry if this is not the place to post it, not Gitxxx savvy just yet.

So: ComfyUI (portable/manual installs), opens Windows' default browser after console finishes it's mighty work. In my case, I use several browsers (depending on the task), and I did not want to use the default one. I did the code and it has been working like a charm since v0.6.0 up to v0.8.0 so why not share it and perhaps add it to ComfyUI settings?

Code is below for anyone wanting to test/apply this to their installs; even if this never gets implemented, it serves as a future reference for anyone facing the same dilemma.

The Thinking
All the coding involves just MAIN.PY where just setting the browser is not enough, ComfyUI keeps listening and wants an answer, a "subprocess" needs to be included. "Subprocess" only adds about 1 microsecond to the loading sequence and it weights a few KB, resource impact is negligent next to none and it gets the job done.

The Code
All done in main.py:

  1. Add Import
    Open main.py and add import subprocess at the top (around line 15).
import sys
import subprocess # Add this line

  1. Modify Logic
    Locate the startup_server function (around line 384) and replace it with this:
def startup_server(scheme, address, port):
    if os.name == 'nt' and address == '0.0.0.0':
        address = '127.0.0.1'
    if ':' in address:
        address = "[{}]".format(address)
    
    url = f"{scheme}://{address}:{port}"
    # Set your preferred browser path here
    brave_path = r"C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
    
    try:
        # Launch the custom browser
        subprocess.Popen([brave_path, url])
    except Exception as e:
        import webbrowser
        webbrowser.open(url)

That's it.

The example clearly uses Brave, but it allows to open any browser and even specific brower's profiles for those using one browser with multiple profiles.

What now?
Safe to say I'd love to have the option to be able to do that directly from ComfyUI's settings: "Set custom browser" <3 Each new version requires modifying the code by hand if desiring the option and it's quite a pain in the hides :D

Thank you for reading me and thank you for ComfyUI.

Existing Solutions

I did search -perhaps not that deep-, but no easy and visible solution was available.

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureA new feature to add to ComfyUI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions