The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(cloud): pass unfiltered through the models catalogue mapper
purple91673e8dfc89
diff --git a/e2e/no-refusals-mark.spec.ts b/e2e/no-refusals-mark.spec.tsnew file mode 100644index 00000000..ed9717ab--- /dev/null+++ b/e2e/no-refusals-mark.spec.ts@@ -0,0 +1,64 @@+import { test, expect } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate, cloudSwitch } from './support/cloud-mock'++/**+ * C10 (Testfenster-Bericht 34501513, e2e/testfenster/BERICHT.md): the picker+ * never showed the "No refusals" mark for any cloud model, because+ * `toModelEntry()` in `src/api/providers/openai-provider.ts` never copied+ * `unfiltered` out of the raw `/v1/models` row. `e2e/cloud-model-picker.spec.ts`+ * did not catch this: it drives the picker against the LIVE catalogue (and is+ * skipped entirely without test credentials), and it only checks the+ * tool-calling mark, never this one. This spec mocks the catalogue response+ * the way `flash-chat-billing.spec.ts` already does for the sibling `flash`+ * field, so the mark is checked against a real, controlled server answer+ * instead of production's current (possibly also broken) state.+ *+ * Run: npx playwright test e2e/no-refusals-mark.spec.ts+ */+test('a measured unfiltered model shows the No refusals mark in the picker', async ({ page }) => {+ await page.addInitScript(tauriMockInit, { assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: DEFAULT_MODEL_NAME })+ await seedOnboardingDone(page)+ await routeCloud(page, { license: 'active', access: true, mediaLive: true })+ const cors = { 'access-control-allow-origin': '*', 'access-control-allow-headers': 'authorization, content-type' }+ await page.route('**/api/inference/v1/models', (route) => route.fulfill({+ status: 200, headers: cors, contentType: 'application/json', body: JSON.stringify({+ object: 'list',+ data: [+ { id: 'measured-full', name: 'Measured Full', context_length: 32768, unfiltered: 'full' },+ // Deliberately fully mainstream and NOT measured, in the same+ // response: a mark that showed for every row regardless of the+ // field would pass the first assertion alone.+ { id: 'measured-partial', name: 'Measured Partial', context_length: 32768, unfiltered: 'partial' },+ { id: 'unmeasured', name: 'Unmeasured', context_length: 32768 },+ ],+ }),+ }))+ await page.goto('/')+ await expect(cloudSwitch(page)).toBeVisible()+ await signInViaGate(page)+ await expect(cloudSwitch(page)).toBeChecked()+ await page.getByRole('button', { name: /New Chat/i }).first().click()+ await page.getByRole('button', { name: 'Select chat model', exact: true }).click()++ const fullRow = page.getByRole('button', { name: /Measured Full/ })+ await fullRow.scrollIntoViewIfNeeded()+ const mark = fullRow.getByText('No refusals', { exact: true })+ await expect(mark).toBeVisible()+ await expect(mark).toHaveAttribute(+ 'title',+ "Measured: this model answers without refusing. Your account's content policy still applies.",+ )++ // Gegenprobe: 'partial' is deliberately never marked (ModelRowMarks.tsx),+ // and a server that says nothing gets no mark either. Both rows sit in the+ // SAME response as the passing one, so a mark that leaked onto every row+ // would fail here, not just be absent from a separate run.+ const partialRow = page.getByRole('button', { name: /Measured Partial/ })+ await partialRow.scrollIntoViewIfNeeded()+ await expect(partialRow.getByText('No refusals', { exact: true })).toHaveCount(0)++ const unmeasuredRow = page.getByRole('button', { name: /^Unmeasured/ })+ await unmeasuredRow.scrollIntoViewIfNeeded()+ await expect(unmeasuredRow.getByText('No refusals', { exact: true })).toHaveCount(0)+})diff --git a/src/api/providers/__tests__/unfiltered-through-listmodels.test.ts b/src/api/providers/__tests__/unfiltered-through-listmodels.test.tsnew file mode 100644index 00000000..eb8c0429--- /dev/null+++ b/src/api/providers/__tests__/unfiltered-through-listmodels.test.ts@@ -0,0 +1,62 @@+/**+ * C10 (Testfenster-Bericht 34501513, e2e/testfenster/BERICHT.md): the "No+ * refusals" mark never showed for cloud models in the desktop picker.+ *+ * Cause: `toModelEntry()` in `../openai-provider.ts` copied `flash` and+ * `usage_class` from the raw `/v1/models` row into the intermediate+ * `OpenAIModelEntry`, but not `unfiltered`. Every reader downstream+ * (`listModels()` itself, then `lib/cloud-model-row.ts`, then+ * `ModelRowMarks.tsx`) already read `m.unfiltered`, so the value was+ * `undefined` at every one of those places, not just the mark.+ *+ * This test drives the real adapter path (`provider.listModels()`), the same+ * one `flash-metadata.test.ts` drives for the sibling `flash` field, so a+ * future literal that rebuilds the row and drops a field again fails here+ * before it reaches the picker.+ */+import { afterEach, describe, expect, it, vi } from 'vitest'+import { OpenAIProvider } from '../openai-provider'++vi.mock('../../backend', () => ({+ localFetch: vi.fn(async () => new Response('{}', { status: 404 })),+ localFetchStream: vi.fn(), isPrivateOrLanHost: () => false,+ isDirectFetchAllowed: () => true, hostnameOf: (url: string) => new URL(url).hostname,+ ensureProxyAllowsHost: vi.fn(), backendCall: vi.fn(), isTauri: () => false,+}))++const base = 'https://lu-labs.ai/api/inference/v1'+const provider = () => new OpenAIProvider({+ id: 'openai', name: 'LU Cloud', enabled: true, isLocal: false, apiKey: '', baseUrl: base,+})++afterEach(() => vi.unstubAllGlobals())++describe('unfiltered through the real provider adapter', () => {+ it('full and partial both reach the model row', async () => {+ vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({+ data: [+ { id: 'model-full', name: 'Full', unfiltered: 'full' },+ { id: 'model-partial', name: 'Partial', unfiltered: 'partial' },+ ],+ }))))+ const models = await provider().listModels()+ expect(models.find((m) => m.id === 'model-full')?.unfiltered).toBe('full')+ expect(models.find((m) => m.id === 'model-partial')?.unfiltered).toBe('partial')+ })++ it('a garbage value is dropped, not passed through', async () => {+ vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({+ data: [{ id: 'model-garbage', name: 'Garbage', unfiltered: 'nonsense' }],+ }))))+ const models = await provider().listModels()+ expect(models.find((m) => m.id === 'model-garbage')?.unfiltered).toBeUndefined()+ })++ it('a missing field stays undefined, nothing is invented', async () => {+ vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({+ data: [{ id: 'model-none', name: 'None' }],+ }))))+ const models = await provider().listModels()+ expect(models.find((m) => m.id === 'model-none')?.unfiltered).toBeUndefined()+ })+})diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex e0c81ba2..f31d2506 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -184,6 +184,7 @@ function toModelEntry(m: Record<string, unknown>): OpenAIModelEntry {name: asString(m.name),flash: m.flash,usage_class: m.usage_class,+ unfiltered: m.unfiltered,/** GH #129: dieselbe Zahl, wie der jeweilige Server sie nennt, gelesen vom* selben Leser wie die Kaskade (context-probe). Das kostet keine einzige@@ -217,6 +218,15 @@ function toModelEntry(m: Record<string, unknown>): OpenAIModelEntry {}}+/**+ * Only the two measured values survive. Anything else a foreign server+ * writes into this field is dropped, same rule at both call sites, one+ * place to keep it right (see the shared literal these two used to be).+ */+function asUnfiltered(u: unknown): 'full' | 'partial' | undefined {+ return u === 'full' || u === 'partial' ? u : undefined+}+// ── Known context lengths for popular models ───────────────────const KNOWN_CONTEXT: Record<string, number> = {@@ -1108,9 +1118,7 @@ export class OpenAIProvider implements ProviderClient {supportsVision: m.input_modalities?.includes('image') || undefined,thinkMode: m.think,flash: this.config.apiKey?.startsWith('lu_') ? undefined : parseFlashPolicy(m.flash, m.usage_class, this.catalogKey(m.id)),- // Nur die beiden gemessenen Werte werden uebernommen. Alles andere,- // was ein fremder Server in dieses Feld schreibt, faellt weg.- unfiltered: m.unfiltered === 'full' || m.unfiltered === 'partial' ? m.unfiltered : undefined,+ unfiltered: asUnfiltered(m.unfiltered),effortLevels: m.reasoning_effort_levels,effortDefault: m.reasoning_effort_default,}@@ -1136,9 +1144,7 @@ export class OpenAIProvider implements ProviderClient {supportsVision: m.input_modalities?.includes('image') || undefined,thinkMode: m.think,flash: this.config.apiKey?.startsWith('lu_') ? undefined : parseFlashPolicy(m.flash, m.usage_class, this.catalogKey(m.id)),- // Nur die beiden gemessenen Werte werden uebernommen. Alles andere,- // was ein fremder Server in dieses Feld schreibt, faellt weg.- unfiltered: m.unfiltered === 'full' || m.unfiltered === 'partial' ? m.unfiltered : undefined,+ unfiltered: asUnfiltered(m.unfiltered),// Straight through, no invention: a server that does not declare the// ladder leaves both undefined, and undefined is what switches the// whole effort feature off for this model.