Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

open admin page on server startup

Alishahryar1494c6c9d9ae4
diff --git a/.env.example b/.env.example
index 980b9808..41e74246 100644
--- a/.env.example
+++ b/.env.example
@@ -100,6 +100,10 @@ HTTP_CONNECT_TIMEOUT=60
ANTHROPIC_AUTH_TOKEN="freecc"
+# Open /admin in the default browser when fcc-server becomes healthy (set 0/false/no to disable)
+FCC_OPEN_BROWSER=true
+
+
# Messaging Platform: "telegram" | "discord" | "none"
MESSAGING_PLATFORM="discord"
MESSAGING_RATE_LIMIT=1
diff --git a/cli/entrypoints.py b/cli/entrypoints.py
index 96c625d7..1782185b 100644
--- a/cli/entrypoints.py
+++ b/cli/entrypoints.py
@@ -6,6 +6,9 @@ import os
import shutil
import subprocess
import sys
+import threading
+import time
+import webbrowser
from collections.abc import Mapping, Sequence
from pathlib import Path
from urllib.error import HTTPError, URLError
@@ -13,7 +16,7 @@ from urllib.request import Request, urlopen
import uvicorn
-from api.admin_urls import local_proxy_root_url
+from api.admin_urls import local_admin_url, local_proxy_root_url
from api.app import GracefulLifespanApp, create_app
from cli.process_registry import (
kill_all_best_effort,
@@ -46,13 +49,17 @@ def _load_env_template() -> str:
def serve() -> None:
"""Start the FastAPI server (registered as `fcc-server` script)."""
+ opened_admin_browser = False
try:
try:
while True:
_migrate_legacy_env_if_missing()
settings = get_settings()
- if not _run_supervised_server(settings):
+ if not _run_supervised_server(
+ settings, open_admin_browser=not opened_admin_browser
+ ):
return
+ opened_admin_browser = True
get_settings.cache_clear()
except KeyboardInterrupt:
return
@@ -60,7 +67,36 @@ def serve() -> None:
kill_all_best_effort()
-def _run_supervised_server(settings: Settings) -> bool:
+def _admin_browser_open_enabled() -> bool:
+ """Whether to open /admin when the server becomes reachable (FCC_OPEN_BROWSER)."""
+
+ raw = os.environ.get("FCC_OPEN_BROWSER", "true").strip().lower()
+ return raw not in {"", "0", "false", "no"}
+
+
+def _schedule_open_admin_browser(settings: Settings) -> None:
+ """After /health succeeds, open the admin UI in the default browser (daemon thread)."""
+
+ if not _admin_browser_open_enabled():
+ return
+
+ admin_url = local_admin_url(settings)
+ proxy_root_url = local_proxy_root_url(settings)
+
+ def open_when_ready() -> None:
+ deadline = time.monotonic() + 30.0
+ while time.monotonic() < deadline:
+ if _preflight_proxy(proxy_root_url) is None:
+ webbrowser.open(admin_url)
+ return
+ time.sleep(0.15)
+
+ threading.Thread(
+ target=open_when_ready, name="fcc-open-admin-browser", daemon=True
+ ).start()
+
+
+def _run_supervised_server(settings: Settings, *, open_admin_browser: bool) -> bool:
"""Run one uvicorn server instance; return whether admin requested restart."""
restart_requested = False
@@ -84,6 +120,8 @@ def _run_supervised_server(settings: Settings) -> bool:
)
server = uvicorn.Server(config)
server_holder["server"] = server
+ if open_admin_browser:
+ _schedule_open_admin_browser(settings)
server.run()
return restart_requested
diff --git a/tests/cli/test_entrypoints.py b/tests/cli/test_entrypoints.py
index 6712af4b..a22692d3 100644
--- a/tests/cli/test_entrypoints.py
+++ b/tests/cli/test_entrypoints.py
@@ -159,6 +159,54 @@ def test_cli_scripts_are_registered() -> None:
assert scripts["fcc-claude"] == "cli.entrypoints:launch_claude"
+def test_schedule_open_admin_browser_opens_when_health_ready(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Opening /admin runs after /health preflight succeeds."""
+ monkeypatch.delenv("FCC_OPEN_BROWSER", raising=False)
+ from api.admin_urls import local_admin_url
+ from cli import entrypoints
+
+ settings = _launcher_settings(port=31337)
+ opened_urls: list[str] = []
+
+ class ImmediateThread:
+ def __init__(self, target=None, **_kwargs: object) -> None:
+ self._target = target
+
+ def start(self) -> None:
+ assert self._target is not None
+ self._target()
+
+ with (
+ patch.object(entrypoints.threading, "Thread", ImmediateThread),
+ patch.object(entrypoints, "_preflight_proxy", return_value=None),
+ patch.object(
+ entrypoints.webbrowser,
+ "open",
+ side_effect=lambda url: opened_urls.append(url),
+ ),
+ patch.object(entrypoints.time, "sleep"),
+ ):
+ entrypoints._schedule_open_admin_browser(settings)
+
+ assert opened_urls == [local_admin_url(settings)]
+
+
+def test_schedule_open_admin_browser_skips_when_disabled(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setenv("FCC_OPEN_BROWSER", "0")
+ from cli import entrypoints
+
+ settings = _launcher_settings()
+
+ with patch.object(entrypoints.threading, "Thread") as thread_cls:
+ entrypoints._schedule_open_admin_browser(settings)
+
+ thread_cls.assert_not_called()
+
+
def test_serve_supervisor_restarts_when_app_requests_restart() -> None:
from cli import entrypoints
@@ -185,6 +233,7 @@ def test_serve_supervisor_restarts_when_app_requests_restart() -> None:
patch.object(entrypoints, "get_settings", get_settings),
patch.object(entrypoints.uvicorn, "Config", side_effect=fake_config),
patch.object(entrypoints.uvicorn, "Server", side_effect=FakeServer),
+ patch.object(entrypoints, "_schedule_open_admin_browser"),
patch.object(entrypoints, "kill_all_best_effort") as kill_all,
):
entrypoints.serve()