From 52461a6cd826f9ea473e7d9cb3d4fab0ba5fd823 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Oct 2026 10:42:21 +0200 Subject: [PATCH] fix(admin): stop a stale base URL from reaching the Anthropic config on the phone The phone AI parsing form saved the base URL left over from a Local or OpenAI setup after switching to Anthropic, so Anthropic requests went to the old host. It now saves an empty base URL for Anthropic, as the desktop form does since #1777. --- .../screens/admin/MAdminAddonManager.tsx | 2 +- .../mobile/admin/MAdminAddonManager.test.tsx | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client/src/mobile/screens/admin/MAdminAddonManager.tsx b/client/src/mobile/screens/admin/MAdminAddonManager.tsx index 898fb202a..4855a2d3c 100644 --- a/client/src/mobile/screens/admin/MAdminAddonManager.tsx +++ b/client/src/mobile/screens/admin/MAdminAddonManager.tsx @@ -446,7 +446,7 @@ function LlmParsingConfig({ addon }: { addon: Addon }) { setSaving(true) try { // Send the masked sentinel unchanged so the server keeps the stored key. - await adminApi.updateAddon(addon.id, { config: { provider, model: model.trim(), baseUrl: baseUrl.trim(), apiKey, vision } }) + await adminApi.updateAddon(addon.id, { config: { provider, model: model.trim(), baseUrl: provider === 'anthropic' ? '' : baseUrl.trim(), apiKey, vision } }) toast.success('Saved') } catch { toast.error('Failed to save') diff --git a/client/tests/unit/mobile/admin/MAdminAddonManager.test.tsx b/client/tests/unit/mobile/admin/MAdminAddonManager.test.tsx index 8b114e362..44e161298 100644 --- a/client/tests/unit/mobile/admin/MAdminAddonManager.test.tsx +++ b/client/tests/unit/mobile/admin/MAdminAddonManager.test.tsx @@ -1,4 +1,4 @@ -// FE-MOB-AADD-001 to FE-MOB-AADD-034 +// FE-MOB-AADD-001 to FE-MOB-AADD-035 import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import userEvent from '@testing-library/user-event'; import { delay, http, HttpResponse } from 'msw'; @@ -684,6 +684,26 @@ describe('MAdminAddonManager', () => { await screen.findByText('Failed to save'); }); + it('FE-MOB-AADD-035: switching to Anthropic saves an empty base URL instead of the old host', async () => { + const user = userEvent.setup(); + let body: { config?: Record } | null = null; + server.use( + addonsRoute([llmAddon({ provider: 'openai', model: 'gpt-4o', baseUrl: 'https://api.openai.com/v1', apiKey: '' })]), + http.put('/api/admin/addons/llm_parsing', async ({ request }) => { + body = (await request.json()) as { config?: Record }; + return HttpResponse.json({ success: true }); + }), + ); + render(<>); + + await user.click(await screen.findByRole('button', { name: /Anthropic/ })); + await user.click(screen.getByRole('button', { name: 'Save' })); + + await screen.findByText('Saved'); + expect(body?.config?.provider).toBe('anthropic'); + expect(body?.config?.baseUrl).toBe(''); + }); + it('FE-MOB-AADD-033: whether the model reads images is a three-way choice, saved as picked', async () => { const user = userEvent.setup(); const bodies: unknown[] = [];