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.
This commit is contained in:
Maurice
2026-10-09 10:42:21 +02:00
parent 2a242f29fb
commit 52461a6cd8
2 changed files with 22 additions and 2 deletions
@@ -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')
@@ -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<string, unknown> } | 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<string, unknown> };
return HttpResponse.json({ success: true });
}),
);
render(<><ToastContainer /><MAdminAddonManager /></>);
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[] = [];