Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(model-hub): treat a bare scheme-less host and port as a callback address (#2423)

Call White488065513d0a
diff --git a/ui/src/components/settings/models/serverCopy.test.ts b/ui/src/components/settings/models/serverCopy.test.ts
index bd8a12367..57a868cb8 100644
--- a/ui/src/components/settings/models/serverCopy.test.ts
+++ b/ui/src/components/settings/models/serverCopy.test.ts
@@ -312,6 +312,16 @@ describe('pasted OAuth callback value', () => {
expect(callbackValueCarriesResult('chatgpt.com/')).toBe(false);
});
+ // The server reads these as addresses with no answer and refuses them, so the
+ // dialog does too instead of sending them as a code.
+ it('treats a bare scheme-less host and port as an address, as the server does', () => {
+ for (const value of ['localhost:1455', 'localhost', '127.0.0.1:54545', '[::1]:1455', 'example.com:1455']) {
+ expect(callbackValueCarriesResult(value), value).toBe(false);
+ }
+ // A named host alone may be a code: the server sends it as one.
+ expect(callbackValueCarriesResult('a.b.cd')).toBe(true);
+ });
+
it('refuses a page address that carries no answer', () => {
expect(callbackValueCarriesResult('https://chatgpt.com/')).toBe(false);
expect(callbackValueCarriesResult('https://auth.openai.com/log-in')).toBe(false);
diff --git a/ui/src/components/settings/models/serverCopy.ts b/ui/src/components/settings/models/serverCopy.ts
index 776567c81..6c55cc142 100644
--- a/ui/src/components/settings/models/serverCopy.ts
+++ b/ui/src/components/settings/models/serverCopy.ts
@@ -106,10 +106,11 @@ export const pasteRejectedKey = (detail: string | undefined): TranslationKey =>
// A browser that cannot load the loopback callback page often copies its address
// without the scheme (`localhost:1455/auth/callback?code=…`). Same rule as the
-// server's `_oauth_callback_address`: a host followed by a port, path or query is
-// an address; a provider code carries none of them.
+// server's `_oauth_callback_address`: a loopback or IP host is an address on its
+// own, with or without a port; a named host needs a port, path or query, since
+// `a.b.c` alone may be a code. A provider code carries none of them.
const SCHEMELESS_CALLBACK_ADDRESS =
- /^(?:localhost|\[[0-9a-f:.]+\]|\d{1,3}(?:\.\d{1,3}){3}|(?:[a-z0-9-]+\.)+[a-z]{2,})(?::\d{1,5})?[/?]/i;
+ /^(?:(?:localhost|\[[0-9a-f:.]+\]|\d{1,3}(?:\.\d{1,3}){3})(?::\d{1,5})?(?:[/?]|$)|(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d{1,5}(?:[/?]|$)|[/?]))/i;
/**
* Whether a pasted callback address carries the provider's answer. The engine