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
test(e2e): cloud onboarding/gate/create specs + the 3 real bugs they caught
purplee59d362d9052
diff --git a/e2e/cloud-create.spec.ts b/e2e/cloud-create.spec.tsnew file mode 100644index 00000000..e5214645--- /dev/null+++ b/e2e/cloud-create.spec.ts@@ -0,0 +1,55 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate, type CloudScenario } from './support/cloud-mock'++/**+ * 2.5.7 cloud create — hosted rendering through the global Cloud mode.+ *+ * (a) happy path: prompt → POST /api/jobs → poll → succeeded → the result+ * lands in the gallery strip; the credits meter is visible; the+ * cloud-only utility intents (Upscale/Erase) are offered.+ * (b) media_live:false from the catalog → generate degrades to the honest+ * "coming soon" error instead of submitting.+ */++async function bootIntoCloudCreate(page: Page, scenario: CloudScenario) {+ await page.addInitScript(tauriMockInit, {+ assistantReply: DEFAULT_ASSISTANT_REPLY,+ modelName: DEFAULT_MODEL_NAME,+ })+ await seedOnboardingDone(page)+ await routeCloud(page, scenario)+ await page.goto('/')+ await expect(page.getByRole('radio', { name: /Local/i })).toBeVisible({ timeout: 20_000 })+ await signInViaGate(page)+ await expect(page.getByRole('radio', { name: /Cloud/i })).toBeChecked({ timeout: 20_000 })+ await page.getByRole('button', { name: /^Create$/ }).click()+}++test('cloud render: submit → poll → gallery, meter + utility intents present', async ({ page }) => {+ await bootIntoCloudCreate(page, { license: 'active', access: true, mediaLive: true })++ // Cloud-only utility intents are offered on the cloud backend.+ await expect(page.getByRole('radio', { name: /Upscale/i })).toBeVisible({ timeout: 15_000 })+ await expect(page.getByRole('radio', { name: /Erase Object/i })).toBeVisible()++ // Credits meter reflects the mocked quota (remaining = 2,550,000 − 12,345).+ await expect(page.getByText('2537655')).toBeVisible()++ const composer = page.locator('textarea').first()+ await composer.fill('a lighthouse at dusk, cinematic')+ await page.getByRole('button', { name: /^Create$/ }).last().click()++ // The mocked job succeeds on the first poll; the image lands in the gallery.+ await expect(page.locator('img[src^="data:image"]').first()).toBeVisible({ timeout: 30_000 })+})++test('media_live=false: generate shows the honest coming-soon message', async ({ page }) => {+ await bootIntoCloudCreate(page, { license: 'active', access: true, mediaLive: false })++ const composer = page.locator('textarea').first()+ await composer.fill('a lighthouse at dusk, cinematic')+ await page.getByRole('button', { name: /^Create$/ }).last().click()++ await expect(page.getByText(/coming soon/i)).toBeVisible({ timeout: 15_000 })+})diff --git a/e2e/cloud-gate.spec.ts b/e2e/cloud-gate.spec.tsnew file mode 100644index 00000000..a81ec7ec--- /dev/null+++ b/e2e/cloud-gate.spec.ts@@ -0,0 +1,46 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate, type CloudScenario } from './support/cloud-mock'++/**+ * 2.5.7 cloud gate — the wall in front of Cloud mode.+ *+ * (a) signed in without a plan → plan CTA opens lu-labs.ai/pricing in the+ * SYSTEM browser (asserted via the mocked shell-open recorder), the mode+ * stays Local;+ * (b) licensed but behind the Max-only launch gate (access:false) → the+ * closed-beta wall, mode stays Local.+ */++async function boot(page: Page, scenario: CloudScenario) {+ await page.addInitScript(tauriMockInit, {+ assistantReply: DEFAULT_ASSISTANT_REPLY,+ modelName: DEFAULT_MODEL_NAME,+ })+ await seedOnboardingDone(page)+ await routeCloud(page, scenario)+ await page.goto('/')+ await expect(page.getByRole('radio', { name: /Local/i })).toBeVisible({ timeout: 20_000 })+}++test('signed in without a plan: plan CTA → browser, mode stays Local', async ({ page }) => {+ await boot(page, { license: 'none' })+ await signInViaGate(page)++ await expect(page.getByText(/no active plan/i)).toBeVisible({ timeout: 20_000 })+ await page.getByRole('button', { name: /View plans/i }).click()++ const opened = await page.evaluate(() => (window as unknown as { __E2E_OPENED_URLS__?: string[] }).__E2E_OPENED_URLS__ ?? [])+ expect(opened.some((u) => u.includes('lu-labs.ai/pricing'))).toBe(true)++ // Gate holds: the switch is still on Local.+ await expect(page.getByRole('radio', { name: /Local/i })).toBeChecked()+})++test('licensed but beta-gated (access:false): closed-beta wall, mode stays Local', async ({ page }) => {+ await boot(page, { license: 'active', tier: 'hosted-pro', access: false })+ await signInViaGate(page)++ await expect(page.getByText(/closed beta/i)).toBeVisible({ timeout: 20_000 })+ await expect(page.getByRole('radio', { name: /Local/i })).toBeChecked()+})diff --git a/e2e/cloud-onboarding.spec.ts b/e2e/cloud-onboarding.spec.tsnew file mode 100644index 00000000..349ce6b4--- /dev/null+++ b/e2e/cloud-onboarding.spec.ts@@ -0,0 +1,49 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate } from './support/cloud-mock'++/**+ * 2.5.7 cloud onboarding — header switch → gate login → cloud mode.+ *+ * A Max-plan account flips the global switch to Cloud through the gate modal:+ * login (email+password against the mocked Supabase), /api/me grants access,+ * the modal closes itself, and the chat picker surfaces ONLY the hosted+ * catalog (the mocked /api/inference/v1/models list) while the local-hardware+ * tabs disappear. Flipping back to Local restores today's app.+ */++async function boot(page: Page) {+ await page.addInitScript(tauriMockInit, {+ assistantReply: DEFAULT_ASSISTANT_REPLY,+ modelName: DEFAULT_MODEL_NAME,+ })+ await seedOnboardingDone(page)+ await routeCloud(page, { license: 'active', tier: 'hosted-max', access: true })+ await page.goto('/')+ await expect(page.getByRole('radio', { name: /Local/i })).toBeVisible({ timeout: 20_000 })+}++test('Max account: switch → login → cloud mode with the hosted catalog', async ({ page }) => {+ await boot(page)++ // Local-hardware tabs exist in local mode.+ await expect(page.getByRole('button', { name: /^Models$/ })).toBeVisible()++ await signInViaGate(page)++ // The gate flips the mode itself once the account clears every check.+ await expect(page.getByRole('radio', { name: /Cloud/i })).toBeChecked({ timeout: 20_000 })++ // Local-hardware surfaces are gone in cloud mode.+ await expect(page.getByRole('button', { name: /^Models$/ })).toBeHidden()+ await expect(page.getByRole('button', { name: /^Benchmark$/ })).toBeHidden()++ // The chat picker lists the hosted catalog (and only it).+ await page.getByRole('button', { name: /New Chat/i }).click()+ const picker = page.getByText(/Llama 3\.1 8B Turbo/i).first()+ await expect(picker).toBeVisible({ timeout: 20_000 })++ // Flipping back to Local always works and restores the local tabs.+ await page.getByRole('radio', { name: /Local/i }).click()+ await expect(page.getByRole('button', { name: /^Models$/ })).toBeVisible()+})diff --git a/e2e/support/cloud-mock.ts b/e2e/support/cloud-mock.tsnew file mode 100644index 00000000..93504391--- /dev/null+++ b/e2e/support/cloud-mock.ts@@ -0,0 +1,208 @@+import type { Page } from '@playwright/test'++/**+ * Network mock for the LU Cloud e2e specs: intercepts the Supabase auth host+ * and every lu-labs.ai API the desktop client calls, so the full account →+ * gate → cloud-mode flow runs with zero real accounts or credits.+ *+ * Fulfilled responses still pass the browser's CORS checks (the app origin is+ * localhost:5173, the APIs are cross-origin), so every response carries+ * wildcard CORS headers and OPTIONS preflights are answered.+ */++export interface CloudScenario {+ /** /api/me license.status — 'active' or 'none' (signed in, no plan). */+ license: 'active' | 'none'+ /** Launch gate: false = licensed but closed-beta walled. Default true. */+ access?: boolean+ /** Server MEDIA_LIVE switch surfaced via the catalog. Default true. */+ mediaLive?: boolean+ tier?: string+}++const CORS: Record<string, string> = {+ 'access-control-allow-origin': '*',+ 'access-control-allow-headers': '*',+ 'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',+}++const USER = { id: 'e2e-user-1', email: '[email protected]', aud: 'authenticated', role: 'authenticated' }++// 1×1 transparent PNG for the mocked render result.+const PNG_1PX = Buffer.from(+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',+ 'base64',+)++export async function routeCloud(page: Page, scenario: CloudScenario): Promise<void> {+ const access = scenario.access !== false+ const tier = scenario.tier ?? 'hosted-max'++ const json = (status: number, body: unknown) => ({+ status,+ headers: { ...CORS, 'content-type': 'application/json' },+ body: JSON.stringify(body),+ })++ // ── Supabase auth (password grant + user probe) ────────────────────────+ await page.route('**/auth/v1/**', async (route) => {+ const req = route.request()+ if (req.method() === 'OPTIONS') return route.fulfill({ status: 204, headers: CORS })+ const url = req.url()+ if (url.includes('/token')) {+ return route.fulfill(+ json(200, {+ access_token: 'e2e-access-token',+ token_type: 'bearer',+ expires_in: 3600,+ expires_at: Math.floor(Date.now() / 1000) + 3600,+ refresh_token: 'e2e-refresh-token',+ user: USER,+ }),+ )+ }+ if (url.includes('/user')) return route.fulfill(json(200, USER))+ if (url.includes('/logout')) return route.fulfill(json(204, {}))+ return route.fulfill(json(200, {}))+ })++ // ── lu-labs.ai API surface ─────────────────────────────────────────────+ await page.route('https://lu-labs.ai/**', async (route) => {+ const req = route.request()+ if (req.method() === 'OPTIONS') return route.fulfill({ status: 204, headers: CORS })+ const path = new URL(req.url()).pathname++ if (path === '/api/me') {+ return route.fulfill(+ json(200, {+ user: { id: USER.id, email: USER.email },+ license:+ scenario.license === 'active'+ ? { status: 'active', tier, access }+ : { status: 'none' },+ profile: null,+ }),+ )+ }++ if (path === '/api/jobs/quota') {+ return route.fulfill(+ json(200, {+ tier,+ period: '2026-07',+ limits: { credits: 2_550_000 },+ costs: { image: 1200, video: 40000 },+ used: { credits_used: 12_345 },+ remaining: { credits: 2_537_655 },+ }),+ )+ }++ if (path === '/api/jobs/catalog') {+ return route.fulfill(+ json(200, {+ models: [+ { id: 'flux-schnell', label: 'Flux Schnell (fast)', kind: 'image', edit: false, cfg: true, negative_prompt: false, credits: { base: 300 } },+ { id: 'flux-dev', label: 'Flux Dev (quality)', kind: 'image', edit: true, cfg: true, negative_prompt: false, credits: { base: 1200 } },+ { id: 'wan-2.2-720p', label: 'Wan 2.2 720p', kind: 'video', edit: false, cfg: false, negative_prompt: true, clip: { short: 5, long: 8 }, credits: { base: 40000, long: 64000 } },+ ],+ ops: { removebg: 1000, eraser: 2500, upscale_image: 1000, upscale_video_per_s: 500, upscale_video_min: 2500 },+ voice: { stt: 600, tts_per_1k_chars: 8000 },+ media_live: scenario.mediaLive !== false,+ tier,+ monthly_credits: 2_550_000,+ }),+ )+ }++ if (path === '/api/inference/v1/models') {+ return route.fulfill(+ json(200, {+ object: 'list',+ tier,+ data: [+ {+ id: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',+ object: 'model',+ owned_by: 'lu-labs',+ name: 'Llama 3.1 8B Turbo',+ context_length: 131072,+ max_output_length: 8192,+ input_modalities: ['text'],+ think: 'never',+ },+ {+ id: 'Qwen/Qwen3-30B-A3B',+ object: 'model',+ owned_by: 'lu-labs',+ name: 'Qwen3 30B A3B',+ context_length: 40960,+ max_output_length: 8192,+ input_modalities: ['text'],+ think: 'toggle',+ },+ ],+ }),+ )+ }++ if (path === '/api/jobs' && req.method() === 'POST') {+ return route.fulfill(+ json(202, {+ id: 'job-e2e-1',+ status: 'queued',+ created_at: new Date().toISOString(),+ quota: { kind: 'image', cost: 300, used: 12_645, limit: 2_550_000 },+ }),+ )+ }++ if (path === '/api/jobs/job-e2e-1') {+ return route.fulfill(+ json(200, {+ job: {+ id: 'job-e2e-1',+ kind: 'image',+ model: 'flux-schnell',+ provider: 'wavespeed',+ status: 'succeeded',+ result_url: 'https://lu-labs.ai/e2e/result.png',+ attestation: null,+ cost_units: 300,+ created_at: new Date().toISOString(),+ completed_at: new Date().toISOString(),+ error: null,+ },+ }),+ )+ }++ if (path === '/e2e/result.png') {+ return route.fulfill({ status: 200, headers: { ...CORS, 'content-type': 'image/png' }, body: PNG_1PX })+ }++ return route.fulfill(json(404, { error: `unmocked path ${path}` }))+ })+}++/**+ * Pre-seed the persisted settings so the app boots straight into chat (no+ * onboarding walk) in LOCAL mode. The settingsStore merge() backfills every+ * missing field from defaults, so the minimal shape is enough.+ */+export async function seedOnboardingDone(page: Page): Promise<void> {+ await page.addInitScript(() => {+ window.localStorage.setItem(+ 'chat-settings',+ JSON.stringify({ state: { settings: { onboardingDone: true, appMode: 'local' }, _version: 10 }, version: 10 }),+ )+ })+}++/** Sign in through the CloudGateModal that the header switch opens. */+export async function signInViaGate(page: Page): Promise<void> {+ await page.getByRole('radio', { name: /Cloud/i }).click()+ await page.getByPlaceholder('Email').fill('[email protected]')+ await page.getByPlaceholder('Password').fill('e2e-password')+ await page.getByRole('button', { name: /^Sign in$/i }).click()+}diff --git a/e2e/support/tauri-mock.ts b/e2e/support/tauri-mock.tsindex d2c81650..60110b24 100644--- a/e2e/support/tauri-mock.ts+++ b/e2e/support/tauri-mock.ts@@ -181,7 +181,28 @@ export function tauriMockInit(opts: TauriMockOptions) {return Promise.reject('error sending request: connection refused (e2e)')}+ // ── LU Cloud keychain session (secret_* → in-memory map) ─────+ // Real keychain semantics: set stores, get returns the stored value+ // (or null), delete removes. Lets the Supabase session survive within+ // a page session and keeps the PKCE verifier separate from it.+ case 'secret_set': {+ ;(w.__E2E_SECRETS__ = w.__E2E_SECRETS__ || {})[args?.account] = args?.value+ return Promise.resolve(null)+ }+ case 'secret_get':+ return Promise.resolve((w.__E2E_SECRETS__ || {})[args?.account] ?? null)+ case 'secret_delete': {+ if (w.__E2E_SECRETS__) delete w.__E2E_SECRETS__[args?.account]+ return Promise.resolve(null)+ }+default:+ // Record system-browser opens so specs can assert redirect targets+ // (pricing CTA, closed-beta link) without leaving the page.+ if (cmd === 'plugin:shell|open') {+ ;(w.__E2E_OPENED_URLS__ = w.__E2E_OPENED_URLS__ || []).push(args?.path)+ return Promise.resolve(null)+ }// Tauri plugin channels (event listen/unlisten, window, etc.) and any// unmodeled command: resolve benignly so nothing throws on boot.if (cmd.startsWith('plugin:')) return Promise.resolve(0)diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsxindex 705172c8..cf3265a7 100644--- a/src/components/layout/AppShell.tsx+++ b/src/components/layout/AppShell.tsx@@ -62,20 +62,24 @@ export function AppShell() {// Never leave an out-of-mode model active: flipping the switch moves the// chat selection onto the first model of the new mode (cloud ↔ local).+ // Depends on the model list too — the hosted catalog arrives ASYNC after+ // the lu-cloud provider gets enabled, so the reselect must fire again the+ // moment those models land.+ const allModels = useModelStore((s) => s.models)useEffect(() => {- const { models, activeModel, setActiveModel } = useModelStore.getState()+ const { activeModel, setActiveModel } = useModelStore.getState()const inMode = (name: string | null) => {if (!name) return false- const m = models.find((x) => x.name === name)+ const m = allModels.find((x) => x.name === name)const isCloud = m?.provider === 'lu-cloud'return appMode === 'cloud' ? isCloud : !isCloud}if (inMode(activeModel)) return- const fallback = models.find((m) =>+ const fallback = allModels.find((m) =>appMode === 'cloud' ? m.provider === 'lu-cloud' : m.provider !== 'lu-cloud',)if (fallback) setActiveModel(fallback.name)- }, [appMode])+ }, [appMode, allModels])// Local-hardware views (Models/Benchmark) don't exist in cloud mode — the// header hides them, this guard covers a view that was already open.diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 626558d1..35fcaecc 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -547,8 +547,11 @@ export function ModelSelector() {return () => document.removeEventListener('mousedown', handler)}, [])- const activeDisplayName = activeModel ? displayModelName(activeModel).split(':')[0] : 'Select Model'const activeModelObj = models.find((m) => m.name === activeModel)+ const activeDisplayName = activeModel+ ? (activeModelObj && 'displayName' in activeModelObj && activeModelObj.displayName) ||+ displayModelName(activeModel).split(':')[0]+ : 'Select Model'const activeType = activeModelObj?.type || 'text'// Chat dropdown shows TEXT models only — image/video live in the// Create view's own picker. Everything here is grouped by the model@@ -635,7 +638,8 @@ export function ModelSelector() {)}{groupModels.map((model: AIModel) => {- const modelDisplayName = displayModelName(model.name)+ const modelDisplayName =+ ('displayName' in model && model.displayName) || displayModelName(model.name)const modelProvider = ('provider' in model && model.provider) || 'ollama'const providerBadge = getProviderBadge(model)const isActive = model.name === activeModeldiff --git a/src/hooks/useCloudAuth.ts b/src/hooks/useCloudAuth.tsindex d3e2e475..76a64d20 100644--- a/src/hooks/useCloudAuth.ts+++ b/src/hooks/useCloudAuth.ts@@ -63,6 +63,10 @@ function syncChatProvider(): void {const current = useProviderStore.getState().providers['lu-cloud']if (current && current.enabled !== enabled) {useProviderStore.getState().setProviderConfig('lu-cloud', { enabled })+ // setProviderConfig alone doesn't refetch anyone's model list — kick the+ // shared refresh event so the hosted catalog appears in the chat picker+ // the moment the account signs in (and vanishes on sign-out).+ window.dispatchEvent(new CustomEvent('lu-models-refresh'))}}diff --git a/src/hooks/useCloudSession.ts b/src/hooks/useCloudSession.tsindex 5a5fc21b..971f571e 100644--- a/src/hooks/useCloudSession.ts+++ b/src/hooks/useCloudSession.ts@@ -11,7 +11,7 @@ export interface CloudSession {user: { id: string; email?: string } | nulllicenseActive: booleanquota: CloudQuota | null- /** true ⇔ signed in + active license + a tier with a media-credit budget. */+ /** true ⇔ signed in + active license + launch gate + a credit budget. */cloudAvailable: booleanrefreshQuota: () => Promise<void>}@@ -19,6 +19,7 @@ export interface CloudSession {export function useCloudSession(): CloudSession {const user = useCloudAuthStore((s) => s.user)const licenseActive = useCloudAuthStore((s) => s.licenseActive)+ const access = useCloudAuthStore((s) => s.access)const quota = useCloudAuthStore((s) => s.quota)const refreshQuota = useCallback(async () => {@@ -34,7 +35,7 @@ export function useCloudSession(): CloudSession {user,licenseActive,quota,- cloudAvailable: deriveCloudAvailable({ user, licenseActive, quota }),+ cloudAvailable: deriveCloudAvailable({ user, licenseActive, access, quota }),refreshQuota,}}diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.tsindex 270a1da6..020a3c4e 100644--- a/src/hooks/useModels.ts+++ b/src/hooks/useModels.ts@@ -96,6 +96,8 @@ export function useModels() {provider: pm.provider, providerName: pm.providerName,contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,thinkMode: pm.thinkMode,+ // Friendly server label (LU Cloud) — pickers prefer it over the id.+ displayName: pm.name !== pm.id ? pm.name : undefined,} satisfies CloudModel})})diff --git a/src/types/models.ts b/src/types/models.tsindex f0cd7485..4bee92d4 100644--- a/src/types/models.ts+++ b/src/types/models.ts@@ -34,6 +34,9 @@ export interface CloudModel {supportsTools?: booleansupportsVision?: booleanthinkMode?: 'toggle' | 'always' | 'never'+ /** Friendly picker label when the server provides one (LU Cloud /models+ * `name`) — pickers fall back to the raw id otherwise. */+ displayName?: string}// Image model (e.g. Stable Diffusion, SDXL, Fooocus, ComfyUI)