Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: say when remote access Start automatically opens a public URL (#15849)
Nilay782e786b323e
diff --git a/studio/backend/run.py b/studio/backend/run.pyindex 9bd988a57c1..6c87dc779da 100644--- a/studio/backend/run.py+++ b/studio/backend/run.py@@ -615,6 +615,7 @@ def _emit_startup_output(secure: bool = False,enable_tools: "Optional[bool]" = None,lan_addresses: "tuple[str, ...]" = (),+ remote_access_starting: bool = False,) -> None:"""A loopback launch with LAN addresses bound is network-reachable, so the banner must say so."""if secure:@@ -631,6 +632,7 @@ def _emit_startup_output(include_stop_hint = False,lan_addresses = lan_addresses,scheme = _url_scheme,+ remote_access_starting = remote_access_starting,)if localhost_mismatch_url:_print_localhost_ipv6_mismatch_warning(localhost_mismatch_url, port)@@ -640,12 +642,19 @@ def _emit_startup_output(_print_wsl_windows_hint(port)_verify_global_reachability(display_host, port, wsl_nat = wsl_nat)if _url_scheme == "http": # --cloudflare is refused alongside --ssl-certfile- _print_cloudflare_line(loopback_host = _loopback_bind_host_for(host))+ _print_cloudflare_line(+ loopback_host = _loopback_bind_host_for(host),+ remote_access_starting = remote_access_starting,+ )_emit_tool_policy_notice(lan_addresses[0] if lan_addresses else host, False, enable_tools)print_studio_stop_hint()-def _print_cloudflare_line(secure: bool = False, loopback_host: str = "127.0.0.1") -> None:+def _print_cloudflare_line(+ secure: bool = False,+ loopback_host: str = "127.0.0.1",+ remote_access_starting: bool = False,+) -> None:from startup_banner import stdout_supports_coloraccent = "\033[38;5;150;1m"@@ -679,6 +688,16 @@ def _print_cloudflare_line(secure: bool = False, loopback_host: str = "127.0.0.1warn,)return+ if remote_access_starting:+ # The banner already announces the saved auto-start tunnel; "OFF" would contradict it.+ if _public_reachable is True:+ _emit(+ " The raw port is also reachable from the public internet (see the "+ "reachability check above): --no-cloudflare skips only the Cloudflare URL; "+ f"bind {loopback_host} or close firewall access to keep Unsloth private.",+ warn,+ )+ returnif _cloudflare_requested:if _public_reachable is True:_emit(@@ -2898,7 +2917,8 @@ def run_server(from utils.remote_access_settings import maybe_auto_start_remote_access- if maybe_auto_start_remote_access(app.state):+ remote_access_starting = maybe_auto_start_remote_access(app.state)+ if remote_access_starting:logger.info("Remote access auto-start scheduled")from lan_access import close_lan_listener_lifecycle, lan_listener_status@@ -2916,6 +2936,7 @@ def run_server(secure = secure,enable_tools = enable_tools,lan_addresses = tuple(lan_listener_status()["addresses"]),+ remote_access_starting = remote_access_starting,)return app@@ -2961,8 +2982,9 @@ def _build_arg_parser():default = None,help = "Expose Unsloth on a PUBLIC internet URL via a free Cloudflare HTTPS ""tunnel, for non-api-only wildcard binds (0.0.0.0 or ::). Off by default; "- "pass --cloudflare to enable it (--secure implies it), --no-cloudflare to "- "force it off. It does not change a raw wildcard bind. If the admin "+ "pass --cloudflare to enable it (--secure implies it). The Remote access "+ "'Start automatically' setting also starts one on every launch, on any host. "+ "--no-cloudflare forces both off. It does not change a raw wildcard bind. If the admin ""password was never changed, Unsloth asks for a new one in the terminal ""before publishing the URL.",)diff --git a/studio/backend/startup_banner.py b/studio/backend/startup_banner.pyindex 8745c2eff73..4ed6d220ac5 100644--- a/studio/backend/startup_banner.py+++ b/studio/backend/startup_banner.py@@ -80,6 +80,7 @@ def print_studio_access_banner(include_stop_hint: bool = True,lan_addresses: "tuple[str, ...]" = (),scheme: str = "http",+ remote_access_starting: bool = False,) -> None:"""Prints server URLs once listening; display_host may be a public WAN IP, so pass network_host for LAN; include_stop_hint=False omits the stop block."""use_color = stdout_supports_color()@@ -162,6 +163,23 @@ def print_studio_access_banner(])+ if remote_access_starting:+ lines.extend(+ [+ "",+ style(+ " Remote access is set to start automatically, so a PUBLIC Cloudflare URL "+ "is starting.",+ stop_hint_style,+ ),+ style(+ " Relaunch with --no-cloudflare to skip it, or turn it off in "+ "Settings > Remote & LAN.",+ secondary,+ ),+ ]+ )+if loopback_bind and not listen_all:if lan_addresses:lines.append("")@@ -170,7 +188,7 @@ def print_studio_access_banner()lines.extend(style(f" {scheme}://{a}:{port}", secondary) for a in lan_addresses)lines.append(style(" Turn it off in Settings > Remote & LAN > LAN access.", secondary))- else:+ elif not remote_access_starting:lines.extend(["",@@ -185,12 +203,13 @@ def print_studio_access_banner(),])- lines.append(- style(- " Only on trusted networks -- anyone who reaches this machine can use Unsloth.",- secondary,+ if lan_addresses or not remote_access_starting:+ lines.append(+ style(+ " Only on trusted networks -- anyone who reaches this machine can use Unsloth.",+ secondary,+ ))- )if include_stop_hint:lines.extend(diff --git a/studio/backend/tests/test_secure_tunnel_gate.py b/studio/backend/tests/test_secure_tunnel_gate.pyindex 1b853dfc571..73678f7ba86 100644--- a/studio/backend/tests/test_secure_tunnel_gate.py+++ b/studio/backend/tests/test_secure_tunnel_gate.py@@ -154,6 +154,15 @@ def test_arg_parser_secure_polarity_and_not_secure_alias():assert parser.parse_args(["--not-secure", "--secure"]).secure is True+def test_arg_parser_cloudflare_help_names_the_saved_auto_start_setting(monkeypatch):+ import run++ monkeypatch.setenv("COLUMNS", "1000")+ help_text = run._build_arg_parser().format_help()+ assert "'Start automatically' setting also starts one on every launch" in help_text+ assert "--no-cloudflare forces both off" in help_text++def test_arg_parser_dns_pinning_opt_out_defaults_off():import run@@ -237,6 +246,56 @@ def test_startup_output_emits_tool_notice_on_network_bind(capsys, monkeypatch):assert "follow each request's enable_tools" in out+def test_startup_output_auto_start_on_wildcard_does_not_say_tunnel_off(capsys, monkeypatch):+ import run++ monkeypatch.setattr(run, "_verify_global_reachability", lambda *a, **k: None)+ monkeypatch.setattr(run, "_localhost_ipv6_mismatch_url", lambda *a, **k: None)+ monkeypatch.setattr(run, "_is_wsl_nat", lambda: False)+ monkeypatch.setattr(run, "_cloudflare_url", None)+ monkeypatch.setattr(run, "_cloudflare_requested", False)+ monkeypatch.setattr(run, "_cloudflare_flag", None)++ run._emit_startup_output("0.0.0.0", 8000, "0.0.0.0", remote_access_starting = True)+ out = capsys.readouterr().out+ assert "PUBLIC Cloudflare URL" in out+ assert "Cloudflare tunnel: OFF" not in out+++def test_startup_output_auto_start_keeps_the_public_raw_port_warning(capsys, monkeypatch):+ import run++ def _reachable(*a, **k):+ run._public_reachable = True++ monkeypatch.setattr(run, "_verify_global_reachability", _reachable)+ monkeypatch.setattr(run, "_localhost_ipv6_mismatch_url", lambda *a, **k: None)+ monkeypatch.setattr(run, "_is_wsl_nat", lambda: False)+ monkeypatch.setattr(run, "_cloudflare_url", None)+ monkeypatch.setattr(run, "_cloudflare_requested", False)+ monkeypatch.setattr(run, "_cloudflare_flag", None)++ run._emit_startup_output("0.0.0.0", 8000, "203.0.113.5", remote_access_starting = True)+ out = capsys.readouterr().out+ assert "raw port is also reachable from the public internet" in out+ assert "bind 127.0.0.1" in out+ assert "Cloudflare tunnel: OFF" not in out+++def test_startup_output_auto_start_on_wildcard_keeps_a_ready_tunnel_url(capsys, monkeypatch):+ import run++ monkeypatch.setattr(run, "_verify_global_reachability", lambda *a, **k: None)+ monkeypatch.setattr(run, "_localhost_ipv6_mismatch_url", lambda *a, **k: None)+ monkeypatch.setattr(run, "_is_wsl_nat", lambda: False)+ monkeypatch.setattr(run, "_cloudflare_url", "https://ready.trycloudflare.com")+ monkeypatch.setattr(run, "_cloudflare_requested", False)+ monkeypatch.setattr(run, "_cloudflare_flag", None)++ run._emit_startup_output("0.0.0.0", 8000, "0.0.0.0", remote_access_starting = True)+ assert "https://ready.trycloudflare.com" in capsys.readouterr().out++def test_startup_output_emits_disabled_notice(capsys, monkeypatch):import rundiff --git a/studio/backend/tests/test_startup_banner_loopback.py b/studio/backend/tests/test_startup_banner_loopback.pyindex 1ce6fa46be6..734e3ce48e2 100644--- a/studio/backend/tests/test_startup_banner_loopback.py+++ b/studio/backend/tests/test_startup_banner_loopback.py@@ -42,6 +42,18 @@ def test_wildcard_aliases_show_reachable_urls(capsys, host, loopback_url):assert "http://192.168.1.24:8891" in out[email protected]("host", ["127.0.0.1", "0.0.0.0"])+def test_banner_says_when_remote_access_auto_start_opens_a_public_url(capsys, host):+ print_studio_access_banner(+ port = 8891, bind_host = host, display_host = host, remote_access_starting = True+ )+ out = capsys.readouterr().out+ assert "PUBLIC Cloudflare URL" in out+ assert "--no-cloudflare" in out+ assert "Reachable on this machine only" not in out+ assert "Only on trusted networks" not in out++WSL_HINT = "WSL2: open http://localhost:"diff --git a/unsloth_cli/commands/studio.py b/unsloth_cli/commands/studio.pyindex c810013a956..809520efa79 100644--- a/unsloth_cli/commands/studio.py+++ b/unsloth_cli/commands/studio.py@@ -1903,8 +1903,9 @@ def studio_default("--cloudflare/--no-cloudflare",help = "Expose Unsloth on a PUBLIC internet URL via a free Cloudflare HTTPS ""tunnel, for non-api-only wildcard binds (0.0.0.0 or ::). Off by default; "- "pass --cloudflare to enable it (--secure implies it). --no-cloudflare forces "- "it off but does not change a raw wildcard bind.",+ "pass --cloudflare to enable it (--secure implies it). The Remote access "+ "'Start automatically' setting also starts one on every launch, on any host. "+ "--no-cloudflare forces both off but does not change a raw wildcard bind.",),secure: bool = typer.Option(False,@@ -2561,8 +2562,9 @@ def run(rich_help_panel = _RUN_PANEL_SERVER,help = "Expose Unsloth on a PUBLIC internet URL via a free Cloudflare HTTPS ""tunnel, for non-api-only wildcard binds (0.0.0.0 or ::). Off by default; "- "pass --cloudflare to enable it (--secure implies it). --no-cloudflare forces "- "it off but does not change a raw wildcard bind.",+ "pass --cloudflare to enable it (--secure implies it). The Remote access "+ "'Start automatically' setting also starts one on every launch, on any host. "+ "--no-cloudflare forces both off but does not change a raw wildcard bind.",),secure: bool = typer.Option(False,diff --git a/unsloth_cli/tests/test_studio_cloudflare_flag.py b/unsloth_cli/tests/test_studio_cloudflare_flag.pyindex 6ea5587df5f..b51c0fef2ba 100644--- a/unsloth_cli/tests/test_studio_cloudflare_flag.py+++ b/unsloth_cli/tests/test_studio_cloudflare_flag.py@@ -45,6 +45,15 @@ def test_studio_default_exposes_cloudflare_option_default_off():assert getattr(opt, "default", "missing") is None[email protected]("command", ["run", "studio_default"])+def test_cloudflare_help_names_the_saved_auto_start_setting(command):+ import inspect++ help_text = inspect.signature(getattr(_studio(), command)).parameters["cloudflare"].default.help+ assert "Start automatically" in help_text+ assert "--no-cloudflare forces both off" in help_text++class _ExecCaptured(SystemExit):def __init__(self, argv):super().__init__(0)