Skip to content

The agent that grows with you

test(desktop): onboarding persists the resolved local endpoint URL (#65488)

teknium1588bc72bc844
diff --git a/apps/desktop/src/store/onboarding.test.ts b/apps/desktop/src/store/onboarding.test.ts
index f41cbbad767..91e06396ac1 100644
--- a/apps/desktop/src/store/onboarding.test.ts
+++ b/apps/desktop/src/store/onboarding.test.ts
@@ -688,6 +688,49 @@ describe('saveOnboardingLocalEndpoint', () => {
})
})
+ it('persists the resolved_base_url that served /models, not the URL as typed (#65488)', async () => {
+ const calls: { body?: unknown; path: string }[] = []
+
+ const api = vi.fn(async ({ body, path }: { body?: unknown; path: string }) => {
+ calls.push({ body, path })
+
+ if (path === '/api/providers/validate') {
+ // The probe fell through from the bare host root to its /v1 variant.
+ return {
+ ok: true,
+ reachable: true,
+ message: '',
+ models: ['llama-3.1-8b'],
+ resolved_base_url: 'http://127.0.0.1:1234/v1'
+ }
+ }
+
+ if (path === '/api/model/set') {
+ return { ok: true, provider: 'custom', model: 'llama-3.1-8b', base_url: 'http://127.0.0.1:1234/v1' }
+ }
+
+ throw new Error(`unexpected api path: ${path}`)
+ })
+
+ installApiMock(api)
+
+ const result = await saveOnboardingLocalEndpoint('http://127.0.0.1:1234', '', {
+ requestGateway: readyGateway()
+ })
+
+ expect(result.ok).toBe(true)
+
+ // The runtime POSTs {base_url}/chat/completions verbatim, so Save must store
+ // the base that actually answered /models rather than the typed host root.
+ const assign = calls.find(c => c.path === '/api/model/set')
+ expect(assign?.body).toMatchObject({
+ scope: 'main',
+ provider: 'custom',
+ model: 'llama-3.1-8b',
+ base_url: 'http://127.0.0.1:1234/v1'
+ })
+ })
+
it('reports the runtime reason when resolution still fails after saving', async () => {
installApiMock(async ({ path }: { path: string }) => {
if (path === '/api/providers/validate') {