Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(admin): stop a stale base URL from reaching the Anthropic config on the phone

Maurice52461a6cd826
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<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[] = [];