Skip to content

Studio: show the LAN address on the API page when LAN access is on - #12906

Merged
mahiatlinux merged 3 commits into
unslothai:mainfrom
NilayYadav:api-page-lan-url
Oct 7, 2026
Merged

mahiatlinux merged 3 commits into
unslothai:mainfrom
NilayYadav:api-page-lan-url

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

With LAN access on, the API page still shows http://127.0.0.1:/v1 as the base URL, in the desktop app and in a browser on the same machine. That address only works on the machine itself, so copying it to a phone or another computer fails, even though the LAN address in Settings works.

The API page now shows the LAN address as the base URL when LAN access is on and no Cloudflare URL is active. A Cloudflare URL still takes priority, a browser that opened Studio over the LAN keeps its own address, and the base URL goes back to 127.0.0.1 when LAN access is turned off.

@NilayYadav NilayYadav left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review + reproduction evidence

Pinned review: ffa8ef2f. 1 finding in the submitted head (273f7b49), fixed in ffa8ef2f.

I reproduced the flow (start Studio at 127.0.0.1, log in, Settings > Remote & LAN > LAN access > Start, open the API page) on fresh upstream main with a real install.sh --local --no-torch install on Linux, Chromium 1440x900:

  • main 0587140f: Base URL stays http://127.0.0.1:8888/v1 with LAN access online, live and after a reload, while Settings lists http://172.20.3.58:8888.
  • PR head ffa8ef2f: Base URL is http://172.20.34.198:8888/v1, the same address Settings lists, live and after a reload. Stop in Settings puts it back to http://127.0.0.1:8888/v1 without a reload. A browser opened at the LAN address keeps its own origin. /v1/models on the shown address answers 401 without a key, same as on 127.0.0.1.

PR 12906 before/after

  • Fixed in ffa8ef2f: the submitted head also used launch-managed LAN addresses (-H 0.0.0.0, which is how the Docker image starts). Opened through a forwarded localhost:9000 (the docker -p / ssh -L case) it showed http://172.20.25.65:8888/v1, the container's internal address and port, instead of http://localhost:9000/v1. Only LAN access started from Settings now feeds the Base URL (lanApiUrls, with a test); the same flow shows http://localhost:9000/v1 again, as on main.
  • Tests: remote-access-state.test.ts fails on main (not ok 6, actual http://127.0.0.1:8888) and passes on the branch; lan-access-state.test.ts 28/28 with the fix; related suites 111/111; build passes. eslint on the touched files reports the same 10 pre-existing errors as main.
  • Not on a hot path: one extra settings GET on API page mount and window focus.

Conclusion: real bug, fixed. Fork Actions runs for both arms were still queued when I finished, and upstream CI restarted on ffa8ef2f. Desktop app, Cloudflare plus LAN, and non-Chromium browsers were not run by hand.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Codex review coverage, run on a mirror of this branch (NilayYadav#472):

Round Commit Result
1 273f7b49 1 P2, not accepted (below)
2 ffa8ef2f (current head) No major issues

Round 1 item:

  • P2: Fetch LAN status through a non-owner endpoint (api-monitor-page.tsx:596). Not accepted: a non-owner account gets 403 from the owner-only LAN settings route and keeps the 127.0.0.1 Base URL, which is the same as main. The LAN settings tab is owner-only by design.

The forwarded-port fix in ffa8ef2f came from manual testing, not from Codex. Round 2 reviewed that commit.

@danielhanchen

Copy link
Copy Markdown
Member

The red Frontend build + bundle sanity is not from this PR: account-permissions.test.ts "picking High without an OS sandbox opens the install popup and keeps Low" failed once. It passes on main and on this head (15/15 isolated), and the whole frontend suite passes 3/3 on main locally, so I have re-run it.

@mahiatlinux

Copy link
Copy Markdown
Contributor

Review and verification evidence

Reviewed final source head d10243e796 against merge base 0aaea8b585 and the current-main prospective merge (5255bc3a44 on the required mirror). I found no correctness defect in the PR. The only pushed change is a comment cleanup; the TypeScript AST/printer gate confirms it does not change executable output.

  • Targeted A/B: the regression harness fails on the merge base with http://127.0.0.1:8888/v1, then passes on both the PR head and prospective merge with the active settings-managed LAN URL. Focused state suites: base 45/45, head 47/47, prospective merge 47/47.
  • Frontend: typecheck and production build passed on the prospective merge. The full frontend suite ran 10,763 tests with one known transient account-permissions.test.ts failure; that exact file then passed 19/19 three times on current main and 19/19 three times on the prospective merge. Final-head Frontend CI is green.
  • Isolated UI proof: Chromium 141 ran headlessly inside a credential-free bwrap sandbox with no host display access. BEFORE kept the loopback URL; AFTER showed the first active settings-managed LAN URL (uses_lan_base: false -> true).
  • Cross-platform: all required source-PR checks passed at final head, including Windows frontend units, Windows Composer, macOS browser/Safari Composer, Tauri Linux, and Rust on Windows/macOS. Disposable staging PR #44 independently passed the Ubuntu frontend build plus Ubuntu and macOS browser/Safari Composer jobs; duplicate staging Windows jobs were cancelled after the final-head source checks had already passed them.
  • Review convergence: the required mirror PR #128 reviewed final mirror head 5255bc3a44; the fresh second Codex review found no major issues.

Before/after API base URL

@mahiatlinux mahiatlinux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Ready to merge, all manually checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants