A local-first multi-agent app development platform, built on PenguinHarness
A key authorization opened on a LAN address falls back to the pasted code
- Date: 2026-10-26
- Type: fix
- Scope:
server,web - Breaking: no
Connecting TokenDance from the Models page, with the Web App opened over plain HTTP on anything
but loopback (a LAN address such as http://192.168.1.10:4000, a hostname, 0.0.0.0), sent the
browser to an authorization page that refused the whole request as invalid. That page redirects
back only to an HTTPS address or to plain HTTP on localhost, [::1] or 127.x.x.x, and the
server had handed it the address the browser used.
The server now asks for the redirect only when that address can receive it. Otherwise it opens the
flow in manual mode: no callback address, the same S256 PKCE challenge. The start answer's new
mode field says which mode the flow opened in, and the dialog follows it — it opens straight on
the one-time code step, and the switch back to the automatic redirect is withdrawn for as long as
it stays open, because the provider would refuse it again. On loopback and HTTPS addresses the
redirect stays the default and the switch between the two works as before.
Details
packages/server/src/services/model-oauth-service.ts: new exportedopenedMode(asked, callbackOrigin)—manualis never upgraded; acallbackrequest keeps its redirect only onhttps:or onhttp:tolocalhost,[::1]or127.x.x.x, the set the authorization page accepts (itscallback_urlcheck, read from its own client bundle). An origin that does not parse names nowhere a browser can be sent, so it falls back too.startuses it for the callback URL and for the mode the flow is stored with, so a downgraded flow refuses a redirect deposit exactly like a manual one;startalso returnsmode.packages/server/src/api/types.ts:ModelOAuthStartResponse.mode(required — the server always answers it) and theModelOAuthModecomment now says why acallbackrequest can open asmanual.packages/web/src/features/models/models-page.tsx(ModelOAuthDialog): aredirectRefusedstate set when a callback request comes backmanual; it feeds a singlebyHandthat replaces themanualreads (code step, no poll, no redirect switch), so a retry keeps it that way. The dialog only looks atres.mode === "manual", so a server that predates the field behaves as before. No new copy: the code step's existing hint already says what to do.packages/server/test/model-oauth.test.ts: the opened-mode table (loopback and HTTPS keep the redirect; LAN, hostname,0.0.0.0,*.localhostand an unparsable origin open as manual; manual is never upgraded) plus a route case reached onhttp://192.168.1.10:7364that answersmode: "manual", carries nocallback_url, keeps S256, and then redeems a pasted code.- Ported from upstream
12a58d4f(#1328), applied as its own change rather than merged; its header comment in the server test was merged by hand (upstream's version also describes a disconnect path this tree does not have) and its web test was not taken — it needs jsdom, whichpackages/webdoes not install, so the dialog half was verified in a real browser instead.
Compatibility
- No dependency, stored-data, package-name or config change.
POST /api/projects/:p/model-oauth/startgains one response field (mode); nothing is removed and older Web Apps ignore it.