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
fix: preserve selected Admin tab on refresh (#1755)
Ali Khokharf3a3aacb19d5
diff --git a/e2e/test_admin_assets.py b/e2e/test_admin_assets.pyindex caab621c..831c8f48 100644--- a/e2e/test_admin_assets.py+++ b/e2e/test_admin_assets.py@@ -7,6 +7,29 @@ from playwright.sync_api import Error, Page, Request, expectfrom free_claude_code.core.version import package_version+def test_selected_admin_tab_survives_refresh_and_browser_navigation(+ page, admin_base_url+):+ page.goto(f"{admin_base_url}/admin")+ for title, path in (+ ("Model Config", "/admin/model_config"),+ ("Messaging", "/admin/messaging"),+ ("Integrations", "/admin/integrations"),+ ("Providers", "/admin"),+ ):+ page.get_by_role("button", name=title, exact=True).click()+ expect(page).to_have_url(f"{admin_base_url}{path}")+ page.reload()+ expect(page.locator("#pageTitle")).to_have_text(title)+ expect(page.get_by_role("button", name=title, exact=True)).to_have_attribute(+ "aria-current", "page"+ )+ page.go_back()+ expect(page.locator("#pageTitle")).to_have_text("Integrations")+ page.go_forward()+ expect(page.locator("#pageTitle")).to_have_text("Providers")++def test_admin_removes_chat_drafts_and_preserves_other_storage(page, admin_base_url):page.add_init_script("""(() => {for (let index = 0; index < 16; index++) {diff --git a/pyproject.toml b/pyproject.tomlindex 44cd7759..b06679dd 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "free-claude-code"-version = "6.2.3"+version = "6.2.4"description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"readme = "README.md"requires-python = ">=3.14.0"diff --git a/src/free_claude_code/api/admin_routes.py b/src/free_claude_code/api/admin_routes.pyindex 2da86f13..0c25fe3b 100644--- a/src/free_claude_code/api/admin_routes.py+++ b/src/free_claude_code/api/admin_routes.py@@ -92,6 +92,9 @@ def admin_page_response() -> HTMLResponse:@router.get("/admin", include_in_schema=False)[email protected]("/admin/model_config", include_in_schema=False)[email protected]("/admin/messaging", include_in_schema=False)[email protected]("/admin/integrations", include_in_schema=False)def admin_page(request: Request):require_loopback_admin(request)return admin_page_response()diff --git a/src/free_claude_code/api/admin_static/admin.js b/src/free_claude_code/api/admin_static/admin.jsindex a6fb20e5..de7bb614 100644--- a/src/free_claude_code/api/admin_static/admin.js+++ b/src/free_claude_code/api/admin_static/admin.js@@ -6,7 +6,7 @@ const state = {modelOptions: [],modelComboboxes: new Set(),authPollers: new Map(),- activeView: sessionViewFromPath(),+ activeView: viewFromLocation(),};const MASKED_SECRET = "********";@@ -49,8 +49,8 @@ const VIEW_GROUPS = [},];-function sessionViewFromPath() {- return window.location.pathname.startsWith("/admin/code") ? "code" : "providers";+function viewFromLocation() {+ return window.location.pathname.split("/")[2] || "providers";}const byId = (id) => document.getElementById(id);@@ -178,12 +178,9 @@ function setActiveView(viewId, { scroll = false } = {}) {}function navigateToView(viewId) {- if (viewId === "code") {- if (window.location.pathname !== `/admin/${viewId}`) {- window.history.pushState({}, "", `/admin/${viewId}`);- }- } else if (sessionViewFromPath() !== "providers") {- window.history.pushState({}, "", "/admin");+ const target = viewId === "providers" ? "/admin" : `/admin/${viewId}`;+ if (window.location.pathname + window.location.search !== target) {+ window.history.pushState({}, "", target);}setActiveView(viewId, { scroll: true });}@@ -1234,7 +1231,7 @@ document.addEventListener("pointerdown", (event) => {});window.addEventListener("popstate", () => {- const viewId = sessionViewFromPath();+ const viewId = viewFromLocation();setActiveView(viewId, { scroll: false });});diff --git a/tests/api/test_admin.py b/tests/api/test_admin.pyindex a2c3b45c..5d691731 100644--- a/tests/api/test_admin.py+++ b/tests/api/test_admin.py@@ -162,13 +162,16 @@ def _catalog_proxy_env_keys() -> tuple[str, ...]:return tuple(keys)-def test_admin_page_is_loopback_only(monkeypatch, tmp_path):+ "path", ["/admin", "/admin/model_config", "/admin/messaging", "/admin/integrations"]+)+def test_admin_page_is_loopback_only(monkeypatch, tmp_path, path):_set_home(monkeypatch, tmp_path)app = create_test_app()- assert _local_client(app).get("/admin").status_code == 200+ assert _local_client(app).get(path).status_code == 200remote_client = TestClient(app, client=("203.0.113.10", 50000))- assert remote_client.get("/admin").status_code == 403+ assert remote_client.get(path).status_code == 403def test_admin_page_uses_installed_version(monkeypatch, tmp_path):diff --git a/uv.lock b/uv.lockindex c39d2053..0f06f3a5 100644--- a/uv.lock+++ b/uv.lock@@ -598,7 +598,7 @@ wheels = [[[package]]name = "free-claude-code"-version = "6.2.3"+version = "6.2.4"source = { editable = "." }dependencies = [{ name = "aiohttp" },