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
feat(cloud): sync the desktop contract to the live lu-labs.ai backend
purple37ac23a580ab
diff --git a/src/api/cloud/catalog.ts b/src/api/cloud/catalog.tsnew file mode 100644index 00000000..8b3b2a9a--- /dev/null+++ b/src/api/cloud/catalog.ts@@ -0,0 +1,28 @@+// GET /api/jobs/catalog — the server-authoritative render/voice catalog+// (models, per-op credit costs, media-live switch). Pure HTTP; the persisted+// cache + fallback ordering live in stores/cloudCatalogStore.++import { cloudFetch, jsonOrError } from './client'+import type { CloudModel } from '../../lib/render/cloud-models'++export interface CatalogOps {+ removebg: number+ eraser: number+ upscale_image: number+ upscale_video_per_s: number+ upscale_video_min: number+}++export interface CloudCatalog {+ models: CloudModel[]+ ops: CatalogOps+ voice: { stt: number; tts_per_1k_chars: number }+ media_live: boolean+ tier: string+ monthly_credits: number+}++export async function getCatalog(): Promise<CloudCatalog> {+ const res = await cloudFetch('/api/jobs/catalog')+ return jsonOrError<CloudCatalog>(res)+}diff --git a/src/api/cloud/jobs.ts b/src/api/cloud/jobs.tsindex 14074581..8b15594a 100644--- a/src/api/cloud/jobs.ts+++ b/src/api/cloud/jobs.ts@@ -48,7 +48,14 @@ export interface CloudJob {export interface CloudMe {user: { id: string; email?: string } | null- license: { status: string }+ license: {+ status: string+ /** Canonical tier slug (hosted | hosted-pro | hosted-max | self-host). */+ tier?: string+ /** Launch gate (Max-only closed beta): false = licensed but not yet+ * allowed in. Absent on older servers = allowed. */+ access?: boolean+ }}/** Stage a source image or mask; returns the render-inputs storage path. */diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex 60a4fd5b..54abf822 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -61,6 +61,13 @@ interface OpenAIModelEntry {object: stringcreated?: numberowned_by?: string+ // Catalogue metadata some OpenAI-compat servers attach (LU Cloud does):+ // display name, real context window, vision modality, think capability.+ // Absent everywhere else — the mapping below falls back to heuristics.+ name?: string+ context_length?: number+ input_modalities?: string[]+ think?: 'toggle' | 'always' | 'never'}// ── Known context lengths for popular models ───────────────────@@ -395,11 +402,13 @@ export class OpenAIProvider implements ProviderClient {return models.map(m => ({id: m.id,- name: m.id,+ name: m.name ?? m.id,provider: 'openai' as const,providerName: this.config.name,- contextLength: KNOWN_CONTEXT[m.id] ?? guessContextFromName(m.id),+ contextLength: m.context_length ?? KNOWN_CONTEXT[m.id] ?? guessContextFromName(m.id),supportsTools: true,+ supportsVision: m.input_modalities?.includes('image') || undefined,+ thinkMode: m.think,}))}diff --git a/src/api/providers/types.ts b/src/api/providers/types.tsindex 46b989bc..c6295180 100644--- a/src/api/providers/types.ts+++ b/src/api/providers/types.ts@@ -81,6 +81,10 @@ export interface ProviderModel {contextLength?: numbersupportsTools?: booleansupportsVision?: boolean+ /** Think-button capability (LU Cloud /models `think` field): 'toggle' shows+ * the switch, 'always' reasons regardless, 'never' hides it. Absent =+ * fall back to the local name-heuristic. */+ thinkMode?: 'toggle' | 'always' | 'never'}// ── Chat Messages (unified format) ────────────────────────────diff --git a/src/components/auth/AccountPanel.tsx b/src/components/auth/AccountPanel.tsxindex f5965f37..1962df6a 100644--- a/src/components/auth/AccountPanel.tsx+++ b/src/components/auth/AccountPanel.tsx@@ -127,18 +127,13 @@ export function AccountPanel() {{licenseActive && quota ? (<div className="space-y-2">+ {/* One shared compute-credit wallet — chat, images, video and voice+ all draw from the same monthly budget. */}<Meter- label="Media credits (this month)"+ label="Cloud credits (this month)"used={Number(quota.used.credits_used)}limit={quota.limits.credits}/>- {quota.limits.tokens > 0 && (- <Meter- label="Chat tokens (this month)"- used={Number(quota.used.tokens_used)}- limit={quota.limits.tokens}- />- )}</div>) : (<p className="text-[0.7rem] text-gray-600 dark:text-gray-400">diff --git a/src/components/create/experimental/ModelChip.tsx b/src/components/create/experimental/ModelChip.tsxindex 4dc7315b..65cba2e1 100644--- a/src/components/create/experimental/ModelChip.tsx+++ b/src/components/create/experimental/ModelChip.tsx@@ -1,11 +1,51 @@import { useCreateStore } from '../../../stores/createStore'+import { useCloudCatalogStore, defaultCloudModel } from '../../../stores/cloudCatalogStore'import { Select, type SelectOption } from '../ui/Select'import { TYPE_BADGE } from './badges'-// Badge-aware model picker (replaces the raw <select>). Desktop build: only-// the locally installed checkpoints — the web app's hosted-catalog branch-// (backend === 'cloud') does not exist here.+const CLOUD_BADGE = { label: 'Cloud', color: 'bg-violet-500/15 text-violet-300' }++// Badge-aware model picker (replaces the raw <select>). Local backend lists+// the installed checkpoints; the cloud backend lists the hosted catalog+// (server-driven via cloudCatalogStore) and writes the cloud model slugs.export function ModelChip() {+ const backend = useCreateStore((s) => s.backend)+ return backend === 'cloud' ? <CloudModelChip /> : <LocalModelChip />+}++function CloudModelChip() {+ const mode = useCreateStore((s) => s.mode)+ const cloudImageModel = useCreateStore((s) => s.cloudImageModel)+ const cloudVideoModel = useCreateStore((s) => s.cloudVideoModel)+ const setCloudImageModel = useCreateStore((s) => s.setCloudImageModel)+ const setCloudVideoModel = useCreateStore((s) => s.setCloudVideoModel)+ const models = useCloudCatalogStore((s) => s.models)++ const isVideo = mode === 'video'+ const kind = isVideo ? 'video' : 'image'+ const list = models.filter((m) => m.kind === kind)+ const value = (isVideo ? cloudVideoModel : cloudImageModel) || defaultCloudModel(kind)?.id || ''++ const options: SelectOption[] = list.map((m) => ({+ value: m.id,+ label: m.label,+ badge: CLOUD_BADGE,+ }))++ return (+ <Select+ size="sm"+ searchable+ align="right"+ className="min-w-[150px] max-w-[230px]"+ options={options}+ value={value}+ onChange={(v) => (isVideo ? setCloudVideoModel(v) : setCloudImageModel(v))}+ />+ )+}++function LocalModelChip() {const mode = useCreateStore((s) => s.mode)const imageModel = useCreateStore((s) => s.imageModel)const videoModel = useCreateStore((s) => s.videoModel)diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsxindex e6f39889..e4dd7cd6 100644--- a/src/components/layout/AppShell.tsx+++ b/src/components/layout/AppShell.tsx@@ -52,7 +52,7 @@ export function AppShell() {'locally-uncensored-agent-mode', 'locally-uncensored-memory','locally-uncensored-agent-workflows', 'locally-uncensored-agent','locally-uncensored-voice', 'lu-benchmark-store', 'lu-update-checker-v2',- 'rag-store', 'workflow-store',+ 'rag-store', 'workflow-store', 'lu-cloud-catalog',// v2.5.0 launch teasers — back these up so an auto-updater who clicked// "Don't show me again" / dismissed the image-tool noti keeps that choice// across the NSIS update (which wipes WebView2 localStorage).diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex 8393a61e..48ec23e0 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -257,7 +257,14 @@ export function useChat() {// the tags silently and keepThinking=false below drops the native// thinking field, so the user sees a clean answer without a// planning preamble.- const canThink = isThinkingCompatible(activeModel)+ // Server-declared think capability (LU Cloud models carry thinkMode from+ // /models): 'always'/'never' models get no reasoning_effort at all — the+ // upstream reasons (or not) regardless, and forcing 'minimal' on an+ // always-thinker can 4xx. 'toggle' and unknown fall through to the+ // name-heuristic + settings switch.+ const activeMeta = useModelStore.getState().models.find((m) => m.name === activeModel)+ const thinkMode = activeMeta && 'thinkMode' in activeMeta ? activeMeta.thinkMode : undefined+ const canThink = thinkMode ? thinkMode === 'toggle' : isThinkingCompatible(activeModel)const plainTextPlanner = isPlainTextPlanner(activeModel)const useThinking: boolean | undefined = canThink? (settings.thinkingEnabled === false && plainTextPlannerdiff --git a/src/hooks/useCloudAuth.ts b/src/hooks/useCloudAuth.tsindex 6577be6a..07d516ab 100644--- a/src/hooks/useCloudAuth.ts+++ b/src/hooks/useCloudAuth.ts@@ -7,7 +7,8 @@import { useCallback, useEffect, useRef } from 'react'import { supabaseCloud } from '../api/cloud/supabase'import { getMe, getQuota } from '../api/cloud/jobs'-import { useCloudAuthStore } from '../stores/cloudAuthStore'+import { useCloudAuthStore, deriveCloudAvailable } from '../stores/cloudAuthStore'+import { refreshCatalog } from '../stores/cloudCatalogStore'import { useProviderStore } from '../stores/providerStore'import type { CloudQuota } from '../lib/render/cloud-jobs'@@ -19,28 +20,34 @@ async function probeAccount(): Promise<void> {const me = await getMe()if (!me.user) {store.setSignedOut()- syncChatProvider(null)+ syncChatProvider()return}const licenseActive = me.license?.status === 'active'+ // Launch gate (Max-only closed beta): absent on older servers = allowed.+ const access = me.license?.access !== false+ const tier = me.license?.tier ?? nulllet quota: CloudQuota | null = null- if (licenseActive) {+ if (licenseActive && access) {+ // Gated accounts would just 403 here — skip the round-trip.quota = await getQuota().catch(() => null)+ void refreshCatalog()}- store.setSignedIn({ id: me.user.id, email: me.user.email }, licenseActive, quota)- syncChatProvider(quota)+ store.setSignedIn({ id: me.user.id, email: me.user.email }, { licenseActive, tier, access, quota })+ syncChatProvider()} catch {// 401 = no/expired session; network = cloud unreachable. Either way the// cloud axis is off for now — local features are unaffected.store.setSignedOut()- syncChatProvider(null)+ syncChatProvider()}}// Chat side of the account: the lu-cloud provider is enabled exactly when the-// tier has a token budget. Uses the store action so the registry cache clears.-function syncChatProvider(quota: CloudQuota | null): void {- const enabled = (quota?.limits.tokens ?? 0) > 0+// whole cloud axis is (signed in + licensed + gate + credit budget). Uses the+// store action so the registry cache clears.+function syncChatProvider(): void {+ const enabled = deriveCloudAvailable(useCloudAuthStore.getState())const current = useProviderStore.getState().providers['lu-cloud']if (current && current.enabled !== enabled) {useProviderStore.getState().setProviderConfig('lu-cloud', { enabled })@@ -78,7 +85,7 @@ export function useCloudAuth() {const logout = useCallback(async (): Promise<void> => {await supabaseCloud().auth.signOut().catch(() => {})useCloudAuthStore.getState().setSignedOut()- syncChatProvider(null)+ syncChatProvider()}, [])const refresh = useCallback(async (): Promise<void> => {diff --git a/src/hooks/useCloudCreate.ts b/src/hooks/useCloudCreate.tsindex 3de138f3..d1cbe169 100644--- a/src/hooks/useCloudCreate.ts+++ b/src/hooks/useCloudCreate.ts@@ -21,7 +21,7 @@ import {CloudJobError,type CloudJobParams,} from '../api/cloud/jobs'-import { defaultCloudModel } from '../lib/render/cloud-models'+import { defaultCloudModel, cloudMediaLive } from '../stores/cloudCatalogStore'import { checkPromptSafety, SAFETY_BLOCK_MESSAGE } from '../lib/render/safety'async function dataUrlToBlob(dataUrl: string): Promise<Blob> {@@ -59,6 +59,12 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {(kind === 'video' ? s.cloudVideoModel : s.cloudImageModel) || defaultCloudModel(kind).ids.setError(null)+ if (!cloudMediaLive()) {+ // Server MEDIA_LIVE switch is off — the GPU fleet isn't up, a submit+ // would only 503. Mirror the server's honest "coming soon".+ s.setError('Cloud rendering is coming soon — the GPU fleet is not live yet.')+ return+ }if (op === 'generate' && s.prompt.trim().length === 0) {s.setError('Please enter a prompt.')returndiff --git a/src/hooks/useModels.ts b/src/hooks/useModels.tsindex 23a9cdab..f185226d 100644--- a/src/hooks/useModels.ts+++ b/src/hooks/useModels.ts@@ -85,6 +85,7 @@ export function useModels() {name: prefixedName, model: pm.id, size: 0, type: 'text' as const,provider: pm.provider, providerName: pm.providerName,contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,+ thinkMode: pm.thinkMode,} satisfies CloudModel})})diff --git a/src/lib/render/cloud-jobs.ts b/src/lib/render/cloud-jobs.tsindex d6c2b898..e44f5a92 100644--- a/src/lib/render/cloud-jobs.ts+++ b/src/lib/render/cloud-jobs.ts@@ -9,13 +9,15 @@ export type RenderKind = 'image' | 'video'// a follow-up port.export type RenderOp = 'generate' | 'edit' | 'removebg' | 'animate' | 'upscale' | 'eraser'+// One shared compute-credit wallet — text + media draw from the same budget+// (server shape: uselu /api/jobs/quota).export interface CloudQuota {tier: stringperiod: string- limits: { tokens: number; credits: number }+ limits: { credits: number }costs: { image: number; video: number }- used: { tokens_used: number; credits_used: number }- remaining: { tokens: number; credits: number }+ used: { credits_used: number }+ remaining: { credits: number }}/** Which queue kind + workflow op a Create intent renders as. */diff --git a/src/lib/render/cloud-models.ts b/src/lib/render/cloud-models.tsindex b15f43f5..f17a19c9 100644--- a/src/lib/render/cloud-models.ts+++ b/src/lib/render/cloud-models.ts@@ -1,8 +1,8 @@-// The hosted render fleet's model catalog (keep in sync with uselu-// apps/web/lib/render/cloud-models.ts — the desktop cloud tier submits to the-// same lu-labs.ai backend, so these ids must match what it accepts). The cloud-// path renders on WaveSpeed's hosted endpoints; `file` is unused on the desktop-// (kept only for parity with the web catalog shape).+// Static SEED of the hosted render catalog — the offline/never-fetched+// fallback only. The live truth is GET /api/jobs/catalog (fetched into+// cloudCatalogStore on every account probe), so a shipped build picks up+// fleet/pricing changes without an app update. Keep the ids in sync with+// uselu apps/web/lib/render/cloud-models.ts when touching this file.import type { RenderKind } from './cloud-jobs'@@ -10,34 +10,34 @@ export interface CloudModel {id: stringlabel: stringkind: RenderKind- file?: string+ /** Supports the masked img2img 'edit' op (flux-dev only today). */+ edit?: boolean+ /** Whether the hosted endpoint honours guidance_scale (CFG). */+ cfg?: boolean+ /** Whether the hosted endpoint honours negative_prompt. */+ negative_prompt?: boolean+ /** Video: clip lengths the model books (5s short / 8s long). */+ clip?: { short: number; long?: number }+ /** Per-run credit cost (base = image or 5s clip, long = 8s clip). */+ credits?: { base: number; long?: number }}-export const CLOUD_MODELS: CloudModel[] = [- { id: 'flux-schnell', label: 'Flux Schnell (fast)', kind: 'image', file: 'flux1-schnell-fp8.safetensors' },- { id: 'flux-dev', label: 'Flux Dev (quality)', kind: 'image', file: 'flux1-dev-fp8.safetensors' },- { id: 'flux-1.1-pro', label: 'Flux 1.1 Pro', kind: 'image', file: 'flux1.1-pro.safetensors' },- { id: 'qwen-image', label: 'Qwen Image', kind: 'image', file: 'qwen_image_fp8.safetensors' },- { id: 'seedream-v4', label: 'Seedream 4', kind: 'image', file: 'seedream_v4.safetensors' },- { id: 'hidream', label: 'HiDream', kind: 'image', file: 'hidream_i1_dev.safetensors' },- { id: 'wan-2.2-720p', label: 'Wan 2.2 720p', kind: 'video', file: 'wan2.2_a14b_fp8.safetensors' },- { id: 'wan-2.2-fast', label: 'Wan 2.2 Fast', kind: 'video', file: 'wan2.2_5b_fp8.safetensors' },- // Premium hosted video menu (2026-07-07), cheap → pricey; wan stays first so- // the default video model keeps the lowest per-clip cost.- { id: 'seedance-lite', label: 'Seedance Lite', kind: 'video' },- { id: 'hailuo-2.3', label: 'Hailuo 2.3', kind: 'video' },- { id: 'seedance-pro', label: 'Seedance Pro', kind: 'video' },- { id: 'hailuo-2.3-pro', label: 'Hailuo 2.3 Pro (1080p)', kind: 'video' },- { id: 'kling-turbo', label: 'Kling Turbo (720p)', kind: 'video' },- { id: 'kling-turbo-pro', label: 'Kling Turbo Pro (1080p)', kind: 'video' },- { id: 'veo-3.1-fast', label: 'Veo 3.1 Fast (Audio)', kind: 'video' },- { id: 'veo-3.1', label: 'Veo 3.1 (Audio)', kind: 'video' },-]--export function cloudModelsFor(kind: RenderKind): CloudModel[] {- return CLOUD_MODELS.filter((m) => m.kind === kind)-}+const CLIP = { short: 5, long: 8 }-export function defaultCloudModel(kind: RenderKind): CloudModel {- return cloudModelsFor(kind)[0]-}+export const CLOUD_MODEL_SEED: CloudModel[] = [+ { id: 'flux-schnell', label: 'Flux Schnell (fast)', kind: 'image', cfg: true },+ { id: 'flux-dev', label: 'Flux Dev (quality)', kind: 'image', edit: true, cfg: true },+ { id: 'flux-2-dev', label: 'Flux 2 Dev', kind: 'image' },+ { id: 'qwen-image', label: 'Qwen Image', kind: 'image' },+ { id: 'hidream', label: 'HiDream', kind: 'image' },+ { id: 'hunyuan-image', label: 'HunyuanImage 2.1', kind: 'image' },+ { id: 'z-image-turbo', label: 'Z-Image Turbo (fast)', kind: 'image' },+ { id: 'chroma', label: 'Chroma', kind: 'image' },+ { id: 'prefect-pony', label: 'Prefect Pony XL', kind: 'image' },+ { id: 'neta-lumina', label: 'Neta Lumina (anime)', kind: 'image' },+ { id: 'wan-2.2-720p', label: 'Wan 2.2 720p', kind: 'video', negative_prompt: true, clip: CLIP },+ { id: 'wan-2.2-fast', label: 'Wan 2.2 Fast', kind: 'video', negative_prompt: true, clip: CLIP },+ { id: 'ltx-2', label: 'LTX-2 (with audio)', kind: 'video', clip: CLIP },+ { id: 'hunyuan-video', label: 'HunyuanVideo 1.5', kind: 'video', negative_prompt: true, clip: CLIP },+ { id: 'ltx-2.3', label: 'LTX 2.3', kind: 'video', clip: CLIP },+]diff --git a/src/stores/__tests__/cloudAuthStore.test.ts b/src/stores/__tests__/cloudAuthStore.test.tsindex d7d954c9..2d2c1af3 100644--- a/src/stores/__tests__/cloudAuthStore.test.ts+++ b/src/stores/__tests__/cloudAuthStore.test.ts@@ -2,13 +2,20 @@ import { describe, it, expect, beforeEach } from 'vitest'import { useCloudAuthStore, deriveCloudAvailable } from '../cloudAuthStore'import type { CloudQuota } from '../../lib/render/cloud-jobs'-const quota = (credits: number, tokens = 0): CloudQuota => ({+const quota = (credits: number): CloudQuota => ({tier: 'hosted',period: '2026-07',- limits: { tokens, credits },+ limits: { credits },costs: { image: 5, video: 80 },- used: { tokens_used: 0, credits_used: 0 },- remaining: { tokens, credits },+ used: { credits_used: 0 },+ remaining: { credits },+})++const account = (over: Partial<Parameters<typeof deriveCloudAvailable>[0]> & { quota: CloudQuota | null }) => ({+ licenseActive: true,+ tier: 'hosted-max',+ access: true,+ ...over,})beforeEach(() => {@@ -16,33 +23,45 @@ beforeEach(() => {})describe('cloudAuthStore', () => {- it('setSignedIn stores user, license and quota', () => {- useCloudAuthStore.getState().setSignedIn({ id: 'u1', email: '[email protected]' }, true, quota(800))+ it('setSignedIn stores user, license, tier, gate and quota', () => {+ useCloudAuthStore+ .getState()+ .setSignedIn(+ { id: 'u1', email: '[email protected]' },+ { licenseActive: true, tier: 'hosted-max', access: true, quota: quota(800) },+ )const s = useCloudAuthStore.getState()expect(s.status).toBe('signed-in')expect(s.user?.email).toBe('[email protected]')expect(s.licenseActive).toBe(true)+ expect(s.tier).toBe('hosted-max')+ expect(s.access).toBe(true)expect(s.quota?.limits.credits).toBe(800)})it('setSignedOut clears everything', () => {- useCloudAuthStore.getState().setSignedIn({ id: 'u1' }, true, quota(800))+ useCloudAuthStore+ .getState()+ .setSignedIn({ id: 'u1' }, { licenseActive: true, tier: 'hosted-max', access: true, quota: quota(800) })useCloudAuthStore.getState().setSignedOut()const s = useCloudAuthStore.getState()expect(s.status).toBe('signed-out')expect(s.user).toBeNull()expect(s.licenseActive).toBe(false)+ expect(s.tier).toBeNull()expect(s.quota).toBeNull()})})describe('deriveCloudAvailable', () => {- it('requires signed-in + active license + credit budget', () => {- expect(deriveCloudAvailable({ user: null, licenseActive: false, quota: null })).toBe(false)- expect(deriveCloudAvailable({ user: { id: 'u' }, licenseActive: false, quota: quota(800) })).toBe(false)- expect(deriveCloudAvailable({ user: { id: 'u' }, licenseActive: true, quota: null })).toBe(false)+ it('requires signed-in + active license + launch gate + credit budget', () => {+ expect(deriveCloudAvailable({ user: null, ...account({ licenseActive: false, quota: null }) })).toBe(false)+ expect(deriveCloudAvailable({ user: { id: 'u' }, ...account({ licenseActive: false, quota: quota(800) }) })).toBe(false)+ expect(deriveCloudAvailable({ user: { id: 'u' }, ...account({ quota: null }) })).toBe(false)// self-host tier: licensed but 0 media credits- expect(deriveCloudAvailable({ user: { id: 'u' }, licenseActive: true, quota: quota(0) })).toBe(false)- expect(deriveCloudAvailable({ user: { id: 'u' }, licenseActive: true, quota: quota(800) })).toBe(true)+ expect(deriveCloudAvailable({ user: { id: 'u' }, ...account({ quota: quota(0) }) })).toBe(false)+ // Max-only closed beta: licensed non-max account is gated out+ expect(deriveCloudAvailable({ user: { id: 'u' }, ...account({ access: false, quota: quota(800) }) })).toBe(false)+ expect(deriveCloudAvailable({ user: { id: 'u' }, ...account({ quota: quota(800) }) })).toBe(true)})})diff --git a/src/stores/__tests__/cloudCatalogStore.test.ts b/src/stores/__tests__/cloudCatalogStore.test.tsnew file mode 100644index 00000000..9f2d5f58--- /dev/null+++ b/src/stores/__tests__/cloudCatalogStore.test.ts@@ -0,0 +1,62 @@+import { describe, it, expect, beforeEach } from 'vitest'+import {+ useCloudCatalogStore,+ cloudModelsFor,+ defaultCloudModel,+ isEditCapable,+ cloudMediaLive,+} from '../cloudCatalogStore'+import { CLOUD_MODEL_SEED } from '../../lib/render/cloud-models'+import type { CloudCatalog } from '../../api/cloud/catalog'++const serverCatalog: CloudCatalog = {+ models: [+ { id: 'flux-9', label: 'Flux 9', kind: 'image', edit: true, cfg: true, credits: { base: 300 } },+ { id: 'wan-9', label: 'Wan 9', kind: 'video', clip: { short: 5, long: 8 }, credits: { base: 8000, long: 13000 } },+ ],+ 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: false,+ tier: 'hosted-max',+ monthly_credits: 2_550_000,+}++beforeEach(() => {+ useCloudCatalogStore.setState({+ fetchedAt: null,+ models: CLOUD_MODEL_SEED,+ ops: null,+ voice: null,+ mediaLive: null,+ })+})++describe('cloudCatalogStore', () => {+ it('falls back to the static seed before any fetch', () => {+ expect(cloudModelsFor('image').length).toBeGreaterThan(0)+ expect(defaultCloudModel('image').id).toBe('flux-schnell')+ expect(defaultCloudModel('video').id).toBe('wan-2.2-720p')+ expect(isEditCapable('flux-dev')).toBe(true)+ expect(isEditCapable('flux-schnell')).toBe(false)+ // never fetched → unknown → treat as live (don't false-block)+ expect(cloudMediaLive()).toBe(true)+ })++ it('setCatalog replaces the seed with the server truth', () => {+ useCloudCatalogStore.getState().setCatalog(serverCatalog)+ expect(defaultCloudModel('image').id).toBe('flux-9')+ expect(defaultCloudModel('video').id).toBe('wan-9')+ expect(isEditCapable('flux-9')).toBe(true)+ expect(useCloudCatalogStore.getState().ops?.eraser).toBe(2500)+ expect(useCloudCatalogStore.getState().fetchedAt).not.toBeNull()+ // server said media is off → honest coming-soon+ expect(cloudMediaLive()).toBe(false)+ })++ it('seed ids match the wired flags (edit only on flux-dev, neg-prompt on wan/hunyuan)', () => {+ const editCapable = CLOUD_MODEL_SEED.filter((m) => m.edit).map((m) => m.id)+ expect(editCapable).toEqual(['flux-dev'])+ const negPrompt = CLOUD_MODEL_SEED.filter((m) => m.negative_prompt).map((m) => m.id)+ expect(negPrompt).toEqual(['wan-2.2-720p', 'wan-2.2-fast', 'hunyuan-video'])+ })+})diff --git a/src/stores/cloudAuthStore.ts b/src/stores/cloudAuthStore.tsindex 79980766..335b059c 100644--- a/src/stores/cloudAuthStore.ts+++ b/src/stores/cloudAuthStore.ts@@ -11,15 +11,23 @@ export interface CloudUser {email?: string}-interface CloudAuthState {+export interface CloudAccount {+ licenseActive: boolean+ /** Canonical tier slug from /api/me, null while signed out/unknown. */+ tier: string | null+ /** Launch gate (Max-only closed beta). Licensed-but-gated users get the+ * closed-beta wall instead of the cloud. */+ access: boolean+ quota: CloudQuota | null+}++interface CloudAuthState extends CloudAccount {/** 'probing' until the keychain session restore + first /api/me resolve. */status: 'probing' | 'signed-out' | 'signed-in'user: CloudUser | null- licenseActive: boolean- quota: CloudQuota | nullsetSignedOut: () => void- setSignedIn: (user: CloudUser, licenseActive: boolean, quota: CloudQuota | null) => void+ setSignedIn: (user: CloudUser, account: CloudAccount) => voidsetQuota: (quota: CloudQuota | null) => void}@@ -27,21 +35,24 @@ export const useCloudAuthStore = create<CloudAuthState>()((set) => ({status: 'probing',user: null,licenseActive: false,+ tier: null,+ access: true,quota: null,setSignedOut: () =>- set({ status: 'signed-out', user: null, licenseActive: false, quota: null }),- setSignedIn: (user, licenseActive, quota) =>- set({ status: 'signed-in', user, licenseActive, quota }),+ set({ status: 'signed-out', user: null, licenseActive: false, tier: null, access: true, quota: null }),+ setSignedIn: (user, account) => set({ status: 'signed-in', user, ...account }),setQuota: (quota) => set({ quota }),}))-/** The whole cloud axis in one predicate: signed in, actively licensed, and- * on a tier whose monthly media budget is > 0 (self-host tiers report 0). */+/** The whole cloud axis in one predicate: signed in, actively licensed,+ * through the launch gate, and on a tier whose monthly credit budget is > 0+ * (self-host tiers report 0). */export function deriveCloudAvailable(state: {user: CloudUser | nulllicenseActive: boolean+ access: booleanquota: CloudQuota | null}): boolean {- return Boolean(state.user && state.licenseActive && (state.quota?.limits.credits ?? 0) > 0)+ return Boolean(state.user && state.licenseActive && state.access && (state.quota?.limits.credits ?? 0) > 0)}diff --git a/src/stores/cloudCatalogStore.ts b/src/stores/cloudCatalogStore.tsnew file mode 100644index 00000000..1ffdcc38--- /dev/null+++ b/src/stores/cloudCatalogStore.ts@@ -0,0 +1,76 @@+// Persisted cache of GET /api/jobs/catalog — the hosted render/voice catalog.+// Refreshed on every successful account probe (useCloudAuth); offline or+// never-fetched falls back to the static CLOUD_MODEL_SEED so the Create UI+// always has a model list. Persist key is in AppShell's STORE_KEYS so the+// cache survives the NSIS-update WebView2 wipe like every other store.++import { create } from 'zustand'+import { persist } from 'zustand/middleware'+import { CLOUD_MODEL_SEED, type CloudModel } from '../lib/render/cloud-models'+import type { RenderKind } from '../lib/render/cloud-jobs'+import { getCatalog, type CatalogOps, type CloudCatalog } from '../api/cloud/catalog'++interface CloudCatalogState {+ fetchedAt: number | null+ models: CloudModel[]+ ops: CatalogOps | null+ voice: { stt: number; tts_per_1k_chars: number } | null+ /** null = unknown (never fetched) — treat as live so we don't false-block. */+ mediaLive: boolean | null++ setCatalog: (c: CloudCatalog) => void+}++export const useCloudCatalogStore = create<CloudCatalogState>()(+ persist(+ (set) => ({+ fetchedAt: null,+ models: CLOUD_MODEL_SEED,+ ops: null,+ voice: null,+ mediaLive: null,++ setCatalog: (c) =>+ set({+ fetchedAt: Date.now(),+ models: c.models,+ ops: c.ops,+ voice: c.voice,+ mediaLive: c.media_live,+ }),+ }),+ { name: 'lu-cloud-catalog' },+ ),+)++/** Fetch the live catalog into the store. Fire-and-forget on account probes —+ * a failure just keeps the last persisted (or seed) catalog. */+export async function refreshCatalog(): Promise<void> {+ try {+ useCloudCatalogStore.getState().setCatalog(await getCatalog())+ } catch {+ // offline / gated — the persisted or seed catalog stays in effect+ }+}++export function cloudModelsFor(kind: RenderKind): CloudModel[] {+ return useCloudCatalogStore.getState().models.filter((m) => m.kind === kind)+}++export function defaultCloudModel(kind: RenderKind): CloudModel {+ return cloudModelsFor(kind)[0]+}++export function cloudModelById(id: string): CloudModel | undefined {+ return useCloudCatalogStore.getState().models.find((m) => m.id === id)+}++export function isEditCapable(id: string): boolean {+ return cloudModelById(id)?.edit === true+}++/** Media-live switch from the server (MEDIA_LIVE env). Unknown = live so the+ * first-ever session doesn't false-block before the catalog arrives. */+export function cloudMediaLive(): boolean {+ return useCloudCatalogStore.getState().mediaLive !== false+}diff --git a/src/types/models.ts b/src/types/models.tsindex a8f2ff5c..f0cd7485 100644--- a/src/types/models.ts+++ b/src/types/models.ts@@ -33,6 +33,7 @@ export interface CloudModel {contextLength?: numbersupportsTools?: booleansupportsVision?: boolean+ thinkMode?: 'toggle' | 'always' | 'never'}// Image model (e.g. Stable Diffusion, SDXL, Fooocus, ComfyUI)