Skip to content

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.

feat(cloud): global Local/Cloud switch + gate modal + Google/GitHub OAuth

purple28180e2df7b4
diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs
index 835309b5..611ea95c 100644
--- a/src-tauri/src/commands/mod.rs
+++ b/src-tauri/src/commands/mod.rs
@@ -8,6 +8,7 @@ pub mod filesystem;
pub mod gpu;
pub mod health;
pub mod install;
+pub mod oauth;
pub mod process;
pub mod proxy;
pub mod remote;
diff --git a/src-tauri/src/commands/oauth.rs b/src-tauri/src/commands/oauth.rs
new file mode 100644
index 00000000..528e4f02
--- /dev/null
+++ b/src-tauri/src/commands/oauth.rs
@@ -0,0 +1,84 @@
+// OAuth loopback listener for the LU Cloud login (Google/GitHub via the
+// system browser). No deep links: the frontend binds a 127.0.0.1 port from a
+// fixed ladder (registered in the Supabase redirect allow-list), opens the
+// provider URL in the system browser, and Supabase redirects back to
+// http://127.0.0.1:<port>/callback?code=… — this module catches that single
+// request and hands the query string to the frontend, which exchanges the
+// PKCE code for a session. The code alone is useless without the PKCE
+// verifier held app-side, so a local port-sniffing race gains nothing.
+
+use std::collections::HashMap;
+use std::sync::Mutex;
+use tokio::io::{AsyncReadExt, AsyncWriteExt};
+use tokio::net::TcpListener;
+use tokio::sync::oneshot;
+
+// Fixed port ladder — Supabase's uri_allow_list has no port wildcards, so
+// these three exact URIs are registered. Three tries ride out a collision
+// with another app or a lingering listener.
+const PORT_LADDER: [u16; 3] = [17872, 17873, 17874];
+
+#[derive(Default)]
+pub struct OauthPending(pub Mutex<HashMap<u16, oneshot::Receiver<String>>>);
+
+const CALLBACK_BODY: &str = "<!doctype html><html><body style=\"font-family:-apple-system,system-ui,sans-serif;background:#161616;color:#e5e5e5;display:flex;align-items:center;justify-content:center;height:100vh;margin:0\"><p>Signed in — you can close this tab and return to LU.</p></body></html>";
+
+/// Bind the first free ladder port and arm a single-shot accept. Returns the
+/// port so the frontend can build the redirect URI before opening the browser.
+#[tauri::command]
+pub async fn oauth_start(state: tauri::State<'_, OauthPending>) -> Result<u16, String> {
+ for port in PORT_LADDER {
+ let listener = match TcpListener::bind(("127.0.0.1", port)).await {
+ Ok(l) => l,
+ Err(_) => continue, // port taken — try the next rung
+ };
+ let (tx, rx) = oneshot::channel::<String>();
+ state.0.lock().unwrap().insert(port, rx);
+ tauri::async_runtime::spawn(async move {
+ // One request only; the listener drops with this task. If oauth_wait
+ // times out first, tx.send just errs into the void — harmless.
+ let Ok((mut stream, _)) = listener.accept().await else { return };
+ let mut buf = vec![0u8; 8192];
+ let n = stream.read(&mut buf).await.unwrap_or(0);
+ let req = String::from_utf8_lossy(&buf[..n]);
+ // Request line: GET /callback?code=…&state=… HTTP/1.1
+ let query = req
+ .lines()
+ .next()
+ .and_then(|l| l.split_whitespace().nth(1))
+ .and_then(|path| path.split_once('?').map(|(_, q)| q.to_string()))
+ .unwrap_or_default();
+ let resp = format!(
+ "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",
+ CALLBACK_BODY.len(),
+ CALLBACK_BODY
+ );
+ let _ = stream.write_all(resp.as_bytes()).await;
+ let _ = stream.shutdown().await;
+ let _ = tx.send(query);
+ });
+ return Ok(port);
+ }
+ Err("no loopback port available (17872-17874) — close the app using them and retry".into())
+}
+
+/// Await the browser round-trip on a port armed by oauth_start. Returns the
+/// raw callback query string (code=…, or error=…&error_description=…).
+#[tauri::command]
+pub async fn oauth_wait(
+ port: u16,
+ timeout_secs: u64,
+ state: tauri::State<'_, OauthPending>,
+) -> Result<String, String> {
+ let rx = state
+ .0
+ .lock()
+ .unwrap()
+ .remove(&port)
+ .ok_or("no pending oauth listener on that port")?;
+ match tokio::time::timeout(std::time::Duration::from_secs(timeout_secs.clamp(10, 900)), rx).await {
+ Ok(Ok(query)) => Ok(query),
+ Ok(Err(_)) => Err("oauth listener closed before the browser returned".into()),
+ Err(_) => Err("sign-in timed out — the browser never came back".into()),
+ }
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index d0502bf8..a55e5e15 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -89,7 +89,11 @@ fn main() {
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.manage(app_state)
+ .manage(commands::oauth::OauthPending::default())
.invoke_handler(tauri::generate_handler![
+ // LU Cloud OAuth loopback (Google/GitHub via system browser)
+ commands::oauth::oauth_start,
+ commands::oauth::oauth_wait,
// Process management
commands::process::start_ollama,
commands::process::start_comfyui,
diff --git a/src/api/backend.ts b/src/api/backend.ts
index f1120d72..8e9dc33c 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -659,6 +659,21 @@ export async function secretDelete(account: string): Promise<void> {
await invoke('secret_delete', { account })
}
+// OAuth loopback (LU Cloud Google/GitHub login): bind a 127.0.0.1 port from
+// the fixed ladder, then await the browser round-trip. Rust side single-shots
+// the accept; the returned string is the raw callback query (code=… / error=…).
+export async function oauthStart(): Promise<number> {
+ if (!isTauri()) throw new Error('OAuth loopback unavailable (web build)')
+ const invoke = await getInvoke()
+ return (await invoke('oauth_start')) as number
+}
+
+export async function oauthWait(port: number, timeoutSecs: number): Promise<string> {
+ if (!isTauri()) throw new Error('OAuth loopback unavailable (web build)')
+ const invoke = await getInvoke()
+ return (await invoke('oauth_wait', { port, timeoutSecs })) as string
+}
+
/** Fetch an external URL as text — works in both Tauri and dev mode */
export async function fetchExternal(url: string): Promise<string> {
if (isTauri()) {
diff --git a/src/api/cloud/supabase.ts b/src/api/cloud/supabase.ts
index 0b3a9db5..093d36f2 100644
--- a/src/api/cloud/supabase.ts
+++ b/src/api/cloud/supabase.ts
@@ -1,6 +1,7 @@
// Supabase auth client for the LU Cloud tier. Desktop authenticates directly
-// against Supabase (email+password) with the public anon key; the resulting
-// access token is sent as `Authorization: Bearer` to the lu-labs.ai APIs.
+// against Supabase — email+password in-app, Google/GitHub via the system
+// browser (PKCE + 127.0.0.1 loopback, see loginWithProvider) — and the
+// resulting access token is sent as `Authorization: Bearer` to lu-labs.ai.
//
// Session storage: OS keychain via the existing Rust `secret_*` commands
// (Windows Credential Manager / macOS Keychain) — survives the NSIS-update
@@ -8,7 +9,7 @@
// browser dev build fall back to localStorage (same tiering as providerStore).
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
-import { secretGet, secretSet, secretDelete } from '../backend'
+import { secretGet, secretSet, secretDelete, oauthStart, oauthWait, openExternal } from '../backend'
import { SUPABASE_URL, SUPABASE_ANON_KEY } from './config'
const SESSION_ACCOUNT = 'lu-cloud-session'
@@ -18,14 +19,20 @@ const LOCAL_KEY = 'lu-cloud-session'
// the adapter to localStorage for the rest of the session (Linux, web dev).
let keychainBroken = false
-// There is exactly one session per app: the keychain path stores under a
-// fixed account; the localStorage fallback keys by the (equally fixed)
-// storageKey supabase passes in.
+// The PKCE flow stores TWO keys through this adapter: the session under the
+// storageKey and the code verifier under `${storageKey}-code-verifier`. Map
+// each supabase key to its own keychain account (suffix-preserving, so the
+// pre-2.5.7 session account stays exactly SESSION_ACCOUNT) — a single fixed
+// account would let the verifier write clobber the session.
+function keychainAccount(key: string): string {
+ return key.startsWith(LOCAL_KEY) ? SESSION_ACCOUNT + key.slice(LOCAL_KEY.length) : key
+}
+
const keychainStorage = {
async getItem(key: string): Promise<string | null> {
if (!keychainBroken) {
try {
- return await secretGet(SESSION_ACCOUNT)
+ return await secretGet(keychainAccount(key))
} catch {
keychainBroken = true
}
@@ -35,7 +42,7 @@ const keychainStorage = {
async setItem(key: string, value: string): Promise<void> {
if (!keychainBroken) {
try {
- await secretSet(SESSION_ACCOUNT, value)
+ await secretSet(keychainAccount(key), value)
return
} catch {
keychainBroken = true
@@ -46,7 +53,7 @@ const keychainStorage = {
async removeItem(key: string): Promise<void> {
if (!keychainBroken) {
try {
- await secretDelete(SESSION_ACCOUNT)
+ await secretDelete(keychainAccount(key))
return
} catch {
keychainBroken = true
@@ -70,6 +77,9 @@ export function supabaseCloud(): SupabaseClient {
// via getSession() on every use instead.
autoRefreshToken: true,
detectSessionInUrl: false,
+ // OAuth via the system browser needs PKCE — the browser only ever
+ // sees the code, the verifier stays in the app (keychain adapter).
+ flowType: 'pkce',
},
})
}
@@ -83,3 +93,32 @@ export async function getAccessToken(): Promise<string | null> {
const { data } = await supabaseCloud().auth.getSession()
return data.session?.access_token ?? null
}
+
+export type OAuthProvider = 'google' | 'github'
+
+/** Google/GitHub sign-in, same identities as lu-labs.ai. Flow: bind a
+ * 127.0.0.1 loopback port (Rust, fixed ladder registered in the Supabase
+ * redirect allow-list) → open the provider consent in the SYSTEM browser →
+ * Supabase redirects to the loopback with ?code= → exchange the PKCE code
+ * for a session. Rejects with a readable message on timeout/denial. */
+export async function loginWithProvider(provider: OAuthProvider): Promise<void> {
+ const port = await oauthStart()
+ const { data, error } = await supabaseCloud().auth.signInWithOAuth({
+ provider,
+ options: {
+ redirectTo: `http://127.0.0.1:${port}/callback`,
+ skipBrowserRedirect: true,
+ },
+ })
+ if (error) throw new Error(error.message)
+ if (!data?.url) throw new Error('OAuth start failed — no provider URL')
+ await openExternal(data.url)
+ const query = await oauthWait(port, 300)
+ const params = new URLSearchParams(query)
+ const code = params.get('code')
+ if (!code) {
+ throw new Error(params.get('error_description') || params.get('error') || 'Sign-in was cancelled in the browser.')
+ }
+ const { error: exchangeError } = await supabaseCloud().auth.exchangeCodeForSession(code)
+ if (exchangeError) throw new Error(exchangeError.message)
+}
diff --git a/src/components/auth/AccountPanel.tsx b/src/components/auth/AccountPanel.tsx
index 1962df6a..03d84cbb 100644
--- a/src/components/auth/AccountPanel.tsx
+++ b/src/components/auth/AccountPanel.tsx
@@ -28,6 +28,57 @@ function Meter({ label, used, limit }: { label: string; used: number; limit: num
)
}
+// Same identities as lu-labs.ai/login — email+password inline, Google/GitHub
+// via the system browser (PKCE loopback in useCloudAuth.loginOAuth).
+function OAuthButtons({ onError }: { onError: (msg: string | null) => void }) {
+ const { loginOAuth } = useCloudAuth()
+ const [waiting, setWaiting] = useState<'google' | 'github' | null>(null)
+
+ const start = async (provider: 'google' | 'github') => {
+ if (waiting) return
+ setWaiting(provider)
+ onError(null)
+ try {
+ await loginOAuth(provider)
+ } catch (err) {
+ onError(err instanceof Error ? err.message : String(err))
+ } finally {
+ setWaiting(null)
+ }
+ }
+
+ const btn =
+ 'flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 rounded text-[0.7rem] font-medium border border-gray-200 dark:border-white/10 bg-gray-100 dark:bg-white/5 text-gray-800 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-white/10 transition-colors disabled:opacity-40'
+
+ return (
+ <div className="flex items-center gap-2">
+ <button type="button" disabled={waiting !== null} onClick={() => void start('google')} className={btn}>
+ {waiting === 'google' ? (
+ <Loader2 size={11} className="animate-spin" />
+ ) : (
+ <svg width="11" height="11" viewBox="0 0 24 24" aria-hidden>
+ <path fill="#4285F4" d="M23.5 12.3c0-.9-.1-1.5-.3-2.2H12v4.1h6.5c-.1 1.1-.8 2.7-2.4 3.8l3.7 2.9c2.3-2.1 3.7-5.2 3.7-8.6z" />
+ <path fill="#34A853" d="M12 24c3.2 0 6-1.1 8-2.9l-3.8-2.9c-1 .7-2.4 1.2-4.2 1.2-3.2 0-6-2.1-6.9-5.1H1.2v3C3.2 21.3 7.3 24 12 24z" />
+ <path fill="#FBBC05" d="M5.1 14.3c-.2-.7-.4-1.5-.4-2.3s.1-1.6.4-2.3v-3H1.2C.4 8.3 0 10.1 0 12s.4 3.7 1.2 5.3l3.9-3z" />
+ <path fill="#EA4335" d="M12 4.7c1.8 0 3 .8 3.7 1.4L19 3C17 1.1 14.7 0 12 0 7.3 0 3.2 2.7 1.2 6.7l3.9 3C6 6.8 8.8 4.7 12 4.7z" />
+ </svg>
+ )}
+ Google
+ </button>
+ <button type="button" disabled={waiting !== null} onClick={() => void start('github')} className={btn}>
+ {waiting === 'github' ? (
+ <Loader2 size={11} className="animate-spin" />
+ ) : (
+ <svg width="11" height="11" viewBox="0 0 16 16" fill="currentColor" aria-hidden>
+ <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.42 7.42 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z" />
+ </svg>
+ )}
+ GitHub
+ </button>
+ </div>
+ )
+}
+
export function AccountPanel() {
const { status, login, signup, logout } = useCloudAuth()
const user = useCloudAuthStore((s) => s.user)
@@ -104,6 +155,12 @@ export function AccountPanel() {
{mode === 'signin' ? 'No account yet? Sign up' : 'Have an account? Sign in'}
</button>
</div>
+ <div className="flex items-center gap-2">
+ <div className="flex-1 h-px bg-gray-200 dark:bg-white/10" />
+ <span className="text-[0.6rem] text-gray-400 dark:text-gray-600">or continue with</span>
+ <div className="flex-1 h-px bg-gray-200 dark:bg-white/10" />
+ </div>
+ <OAuthButtons onError={setError} />
</form>
)
}
diff --git a/src/components/cloud/CloudGateModal.tsx b/src/components/cloud/CloudGateModal.tsx
new file mode 100644
index 00000000..8188ff1b
--- /dev/null
+++ b/src/components/cloud/CloudGateModal.tsx
@@ -0,0 +1,99 @@
+// The gate in front of the global Cloud mode. Opened by the header's
+// Local/Cloud switch whenever the cloud axis isn't usable yet; walks the
+// account through its actual blocker and flips the mode the moment
+// deriveCloudAvailable passes:
+// signed-out → login (email+password + Google/GitHub)
+// licensed? no → plan CTA → lu-labs.ai/pricing in the browser
+// beta gate (access=no) → closed-beta copy → lu-labs.ai
+// Payment stays on lu-labs.ai (browser) — the app never touches Stripe.
+
+import { useEffect, useRef } from 'react'
+import { Cloud, ExternalLink, RefreshCw } from 'lucide-react'
+import { Modal } from '../ui/Modal'
+import { useUIStore } from '../../stores/uiStore'
+import { useSettingsStore } from '../../stores/settingsStore'
+import { useCloudAuthStore, deriveCloudAvailable } from '../../stores/cloudAuthStore'
+import { useCloudAuth } from '../../hooks/useCloudAuth'
+import { AccountPanel } from '../auth/AccountPanel'
+import { CLOUD_BASE } from '../../api/cloud/config'
+import { openExternal } from '../../api/backend'
+
+export function CloudGateModal() {
+ const open = useUIStore((s) => s.cloudGateOpen)
+ const setOpen = useUIStore((s) => s.setCloudGateOpen)
+ const updateSettings = useSettingsStore((s) => s.updateSettings)
+ const { refresh } = useCloudAuth()
+
+ const status = useCloudAuthStore((s) => s.status)
+ 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 available = deriveCloudAvailable({ user, licenseActive, access, quota })
+
+ // The moment the account clears every gate (fresh login, re-check after
+ // subscribing), flip the global switch and get out of the way.
+ const wasOpen = useRef(false)
+ useEffect(() => {
+ wasOpen.current = open
+ }, [open])
+ useEffect(() => {
+ if (wasOpen.current && available) {
+ updateSettings({ appMode: 'cloud' })
+ setOpen(false)
+ }
+ }, [available, setOpen, updateSettings])
+
+ const linkBtn =
+ 'flex items-center gap-1.5 px-3 py-1.5 rounded text-[0.7rem] font-medium bg-gray-900 text-white dark:bg-white dark:text-gray-900 hover:opacity-90 transition-opacity'
+ const ghostBtn =
+ 'flex items-center gap-1.5 px-3 py-1.5 rounded text-[0.7rem] font-medium border border-gray-200 dark:border-white/10 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors'
+
+ return (
+ <Modal open={open} onClose={() => setOpen(false)} title="LU Cloud">
+ {status === 'signed-out' || !user ? (
+ <div className="space-y-3">
+ <p className="text-[0.75rem] text-gray-600 dark:text-gray-400 flex items-start gap-2">
+ <Cloud size={14} className="mt-0.5 shrink-0" />
+ Cloud mode runs chat, image and video on LU's hosted GPUs with your
+ lu-labs.ai account. Local mode stays free and never needs one.
+ </p>
+ <AccountPanel />
+ </div>
+ ) : !licenseActive ? (
+ <div className="space-y-3">
+ <p className="text-[0.75rem] text-gray-600 dark:text-gray-400">
+ You're signed in as <span className="text-gray-900 dark:text-gray-100">{user.email ?? user.id}</span>,
+ but this account has no active plan yet. LU Cloud is part of the paid plans on lu-labs.ai.
+ </p>
+ <div className="flex items-center gap-2">
+ <button className={linkBtn} onClick={() => void openExternal(`${CLOUD_BASE}/pricing`)}>
+ <ExternalLink size={11} /> View plans on lu-labs.ai
+ </button>
+ <button className={ghostBtn} onClick={() => void refresh()}>
+ <RefreshCw size={11} /> I subscribed — re-check
+ </button>
+ </div>
+ </div>
+ ) : !access ? (
+ <div className="space-y-3">
+ <p className="text-[0.75rem] text-gray-600 dark:text-gray-400">
+ LU Cloud is in a closed beta right now (Max plan only). Your plan is
+ active, but the beta hasn't opened for it yet — you'll get in the
+ moment it does, nothing to reinstall.
+ </p>
+ <div className="flex items-center gap-2">
+ <button className={linkBtn} onClick={() => void openExternal(`${CLOUD_BASE}/pricing`)}>
+ <ExternalLink size={11} /> Open lu-labs.ai
+ </button>
+ <button className={ghostBtn} onClick={() => void refresh()}>
+ <RefreshCw size={11} /> Re-check
+ </button>
+ </div>
+ </div>
+ ) : (
+ <p className="text-[0.75rem] text-gray-600 dark:text-gray-400">Checking your account…</p>
+ )}
+ </Modal>
+ )
+}
diff --git a/src/components/cloud/ModeSwitch.tsx b/src/components/cloud/ModeSwitch.tsx
new file mode 100644
index 00000000..c0cf7346
--- /dev/null
+++ b/src/components/cloud/ModeSwitch.tsx
@@ -0,0 +1,43 @@
+// The global Local/Cloud switch (header, brand cluster). Flipping to Cloud
+// only succeeds when the whole cloud axis is usable (signed in + licensed +
+// beta gate + credit budget) — otherwise it opens the CloudGateModal, which
+// flips the mode itself once the account clears. Flipping to Local always
+// works. Everything mode-dependent (chat picker, Create backend, hidden
+// local-hardware tabs) hangs off settings.appMode.
+
+import { HardDrive, Cloud } from 'lucide-react'
+import { Segmented } from '../create/ui/Segmented'
+import { useSettingsStore } from '../../stores/settingsStore'
+import { useUIStore } from '../../stores/uiStore'
+import { useCloudAuthStore, deriveCloudAvailable } from '../../stores/cloudAuthStore'
+import type { AppMode } from '../../types/settings'
+
+export function ModeSwitch() {
+ const appMode = useSettingsStore((s) => s.settings.appMode)
+ const updateSettings = useSettingsStore((s) => s.updateSettings)
+ const setCloudGateOpen = useUIStore((s) => s.setCloudGateOpen)
+ const available = useCloudAuthStore(deriveCloudAvailable)
+
+ const change = (mode: AppMode) => {
+ if (mode === appMode) return
+ if (mode === 'cloud' && !available) {
+ setCloudGateOpen(true)
+ return
+ }
+ updateSettings({ appMode: mode })
+ }
+
+ return (
+ <Segmented<AppMode>
+ size="sm"
+ layoutId="app-mode"
+ ariaLabel="Local or Cloud mode"
+ value={appMode}
+ onChange={change}
+ options={[
+ { value: 'local', label: 'Local', icon: HardDrive, title: 'Run everything on this machine' },
+ { value: 'cloud', label: 'Cloud', icon: Cloud, title: "Run on LU's hosted GPUs (lu-labs.ai account)" },
+ ]}
+ />
+ )
+}
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsx
index d6b8a147..72885c4a 100644
--- a/src/components/create/experimental/Composer.tsx
+++ b/src/components/create/experimental/Composer.tsx
@@ -31,8 +31,7 @@ export function Composer({ onOpenAdvanced }: Props) {
const source = useCreateStore((s) => s.source)
const isGenerating = useCreateStore((s) => s.isGenerating)
const backend = useCreateStore((s) => s.backend)
- const setBackend = useCreateStore((s) => s.setBackend)
- const { generate, cancel, cloudAvailable, quota } = useCreateExp()
+ const { generate, cancel, quota } = useCreateExp()
// The Create button turns into Cancel in place — a double-click's second
// press would instantly cancel the run it just started. Ignore cancel
@@ -112,19 +111,8 @@ export function Composer({ onOpenAdvanced }: Props) {
)}
{meta.needsPrompt && <PromptHistory onPick={setPrompt} />}
<div className="flex-1" />
- {cloudAvailable && (
- <Tooltip content="Render on your own machine or on LU's confidential cloud GPUs.">
- <div>
- <Segmented
- size="sm"
- layoutId="backend-axis"
- value={backend}
- onChange={(v) => setBackend(v as 'local' | 'cloud')}
- options={[{ value: 'local', label: 'Local' }, { value: 'cloud', label: 'Cloud' }]}
- />
- </div>
- </Tooltip>
- )}
+ {/* The backend axis moved to the global header switch (2.5.7) —
+ the Composer just reflects it via the CreditsMeter. */}
{backend === 'cloud' && <CreditsMeter />}
{meta.id !== 'removebg' && (
<>
diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx
index e4dd7cd6..705172c8 100644
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@ -24,6 +24,9 @@ import { detectLocalBackends, type DetectedBackend } from '../../lib/backend-det
import { backendCall, isTauri } from '../../api/backend'
import { useKeyboardShortcuts } from '../../hooks/useKeyboardShortcuts'
import { useCloudAuth } from '../../hooks/useCloudAuth'
+import { useCloudAuthStore, deriveCloudAvailable } from '../../stores/cloudAuthStore'
+import { useCreateStore } from '../../stores/createStore'
+import { CloudGateModal } from '../cloud/CloudGateModal'
import { ShortcutsModal } from './ShortcutsModal'
import { Titlebar } from './Titlebar'
@@ -44,6 +47,45 @@ export function AppShell() {
// the cloud Create axis and the lu-cloud chat provider in sync.
useCloudAuth()
+ // ── Global Local/Cloud mode (2.5.7) — appMode drives everything ──
+ const appMode = settings.appMode
+ const cloudAvailable = useCloudAuthStore(deriveCloudAvailable)
+
+ // Create renders where the mode says: the global switch owns the axis the
+ // Composer's per-surface toggle used to.
+ useEffect(() => {
+ const target = appMode === 'cloud' && cloudAvailable ? 'cloud' : 'local'
+ if (useCreateStore.getState().backend !== target) {
+ useCreateStore.getState().setBackend(target)
+ }
+ }, [appMode, cloudAvailable])
+
+ // 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).
+ useEffect(() => {
+ const { models, activeModel, setActiveModel } = useModelStore.getState()
+ const inMode = (name: string | null) => {
+ if (!name) return false
+ const m = models.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) =>
+ appMode === 'cloud' ? m.provider === 'lu-cloud' : m.provider !== 'lu-cloud',
+ )
+ if (fallback) setActiveModel(fallback.name)
+ }, [appMode])
+
+ // Local-hardware views (Models/Benchmark) don't exist in cloud mode — the
+ // header hides them, this guard covers a view that was already open.
+ useEffect(() => {
+ const ui = useUIStore.getState()
+ if (appMode === 'cloud' && (ui.currentView === 'models' || ui.currentView === 'benchmark')) {
+ ui.setView('chat')
+ }
+ }, [appMode])
+
// ── Store backup/restore: survive NSIS updates that wipe WebView2 data ──
const STORE_KEYS = [
'chat-conversations', 'chat-settings', 'chat-models', 'lu-providers',
@@ -614,6 +656,8 @@ export function AppShell() {
backends={detectedBackends}
onClose={() => setShowSelector(false)}
/>
+ {/* Cloud gate: login → plan → beta wall, opened by the header switch. */}
+ <CloudGateModal />
<ShortcutsModal />
</div>
)
diff --git a/src/components/layout/CloudWaitlistBadge.tsx b/src/components/layout/CloudWaitlistBadge.tsx
deleted file mode 100644
index a3b46e6a..00000000
--- a/src/components/layout/CloudWaitlistBadge.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import { useState, useRef, useEffect, type KeyboardEvent } from 'react'
-import { motion, AnimatePresence } from 'framer-motion'
-import { Cloud, Check, Loader2 } from 'lucide-react'
-import { useCloudTeaserStore } from '../../stores/cloudTeaserStore'
-import { submitWaitlist, isValidEmail } from '../../api/waitlist'
-import { log } from '../../lib/logger'
-
-/**
- * Cloud "Hosted LU Workflows" waitlist teaser — a subtle purple badge next to
- * the brand monogram (top-left). Click opens a small popover with one optional
- * email field.
- *
- * Deliberately NOT naggy (the adversarial call): no pulsing/animation on the
- * dot, the network call fires ONLY on the explicit "Notify me" click (never on
- * render or launch), and there is honest microcopy that this is the one thing
- * LU sends off-device. The badge disappears for good once the user clicks
- * "Don't show me again", or on the next launch after they join the waitlist
- * (a fresh submit still shows the "you're on the list" confirmation first).
- * Closing the popover or clicking outside leaves it.
- *
- * The popover is a self-contained dark gradient card (black → dark-grey) in
- * both themes — David 2026-06-06 wanted it distinct from the flat grey panels,
- * so all inner text is light regardless of light/dark mode.
- */
-export function CloudWaitlistBadge() {
- const dismissed = useCloudTeaserStore((s) => s.dismissed)
- const submitted = useCloudTeaserStore((s) => s.submitted)
- const setDismissed = useCloudTeaserStore((s) => s.setDismissed)
- const setSubmitted = useCloudTeaserStore((s) => s.setSubmitted)
-
- // A user who joined the waitlist in a PREVIOUS session (incl. v2.5.0) should
- // not see the badge again (David 2026-06-07: gone for people who already
- // submitted OR dismissed). `submitted` persists in lu_cloud_teaser (a
- // STORE_KEY, so it survives updates). Snapshot it once at mount so a fresh
- // same-session submit still shows the confirmation before it's gone next launch.
- const [submittedBeforeThisSession] = useState(() => useCloudTeaserStore.getState().submitted)
-
- const [open, setOpen] = useState(false)
- const [email, setEmail] = useState('')
- const [busy, setBusy] = useState(false)
- const [error, setError] = useState<string | null>(null)
- const ref = useRef<HTMLDivElement>(null)
-
- // Click outside closes the popover (does NOT dismiss the badge).
- useEffect(() => {
- const handler = (e: MouseEvent) => {
- if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false)
- }
- document.addEventListener('mousedown', handler)
- return () => document.removeEventListener('mousedown', handler)
- }, [])
-
- // Gone for good once the user opts out, or if they already joined the
- // waitlist in an earlier session (see snapshot above).
- if (dismissed || submittedBeforeThisSession) return null
-
- const handleSubmit = async () => {
- if (busy) return
- const value = email.trim()
- if (!isValidEmail(value)) {
- setError('Please enter a valid email address.')
- return
- }
- setBusy(true)
- setError(null)
- try {
- await submitWaitlist(value, 'app-badge')
- setSubmitted(true) // popover flips to the "you're on the list" state
- } catch (err) {
- log.error('[waitlist] submit failed', { err })
- setError(err instanceof Error ? err.message : 'Something went wrong. Please try again.')
- } finally {
- setBusy(false)
- }
- }
-
- const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
- if (e.key === 'Enter') { e.preventDefault(); void handleSubmit() }
- }
-
- return (
- <div ref={ref} className="relative">
- {/* Trigger — subtle, no pulse */}
- <button
- onClick={() => setOpen((v) => !v)}
- className="relative p-1 rounded-md text-purple-500 hover:text-purple-400 hover:bg-purple-500/10 transition-colors"
- title="LU in the cloud — early access"
- aria-label="Cloud early access"
- >
- <Cloud size={14} />
- <span className="absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] flex items-center justify-center rounded-full bg-purple-500 text-[0.5rem] font-bold text-white leading-none px-0.5">
- {submitted ? <Check size={8} strokeWidth={3} /> : '1'}
- </span>
- </button>
-
- <AnimatePresence>
- {open && (
- <motion.div
- className="absolute left-0 top-full mt-1.5 w-72 rounded-lg overflow-hidden z-50 bg-gradient-to-br from-black via-neutral-900 to-neutral-700 border border-white/10 shadow-2xl shadow-black/60"
- initial={{ opacity: 0, y: -6, scale: 0.98 }}
- animate={{ opacity: 1, y: 0, scale: 1 }}
- exit={{ opacity: 0, y: -6, scale: 0.98 }}
- transition={{ duration: 0.12, ease: 'easeOut' }}
- >
- <div className="p-3.5">
- <div className="flex items-center gap-1.5 mb-1.5">
- <Cloud size={13} className="text-purple-400" />
- <span className="text-[0.72rem] font-semibold text-white">
- LU in the cloud is coming
- </span>
- </div>
-
- {submitted ? (
- <div className="py-1">
- <div className="flex items-center gap-1.5 text-green-400">
- <Check size={13} strokeWidth={3} />
- <span className="text-[0.72rem] font-medium">You're on the list.</span>
- </div>
- <p className="mt-1 text-[0.64rem] leading-relaxed text-gray-300">
- We'll email you once early access opens. Nothing else.
- </p>
- </div>
- ) : (
- <>
- <p className="text-[0.64rem] leading-relaxed text-gray-300 mb-2.5">
- Run LU from your phone or any light setup — hosted workflows.
- Local stays free &amp; private.
- </p>
- <div className="flex items-center gap-1.5">
- <input
- type="email"
- inputMode="email"
- autoComplete="off"
- value={email}
- onChange={(e) => { setEmail(e.target.value); if (error) setError(null) }}
- onKeyDown={onKeyDown}
- placeholder="[email protected]"
- disabled={busy}
- className="flex-1 min-w-0 px-2 py-1 rounded-md text-[0.7rem] bg-white/10 border border-white/15 text-white placeholder:text-gray-400 focus:outline-none focus:border-purple-400/70 disabled:opacity-50"
- />
- <button
- onClick={() => void handleSubmit()}
- disabled={busy}
- className="shrink-0 flex items-center gap-1 px-2 py-1 rounded-md text-[0.68rem] font-medium bg-purple-500 hover:bg-purple-400 text-white disabled:opacity-60 transition-colors"
- >
- {busy ? <Loader2 size={11} className="animate-spin" /> : null}
- Notify me
- </button>
- </div>
- {error && (
- <p className="mt-1.5 text-[0.62rem] text-red-400">{error}</p>
- )}
- <p className="mt-2 text-[0.58rem] leading-relaxed text-gray-400">
- This is the only thing LU sends off your device.
- </p>
- </>
- )}
- </div>
-
- {/* Explicit opt-out — the ONLY way the badge goes away for good. */}
- <div className="border-t border-white/10 px-3.5 py-1.5">
- <button
- onClick={() => { setDismissed(true); setOpen(false) }}
- className="text-[0.6rem] text-gray-400 hover:text-gray-200 transition-colors"
- >
- Don't show me again
- </button>
- </div>
- </motion.div>
- )}
- </AnimatePresence>
- </div>
- )
-}
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx
index 07e4c664..85d677f7 100644
--- a/src/components/layout/Header.tsx
+++ b/src/components/layout/Header.tsx
@@ -9,7 +9,7 @@ import { ModelSelector } from '../models/ModelSelector'
import { MemoryDebugToggle } from '../chat/MemoryDebugPanel'
import { UpdateBadge } from './UpdateBadge'
import { DownloadBadge } from './DownloadBadge'
-import { CloudWaitlistBadge } from './CloudWaitlistBadge'
+import { ModeSwitch } from '../cloud/ModeSwitch'
import { loadModel } from '../../api/ollama'
import { getProviderIdFromModel } from '../../api/providers'
import { ModelLoadError } from '../../lib/ollama-errors'
@@ -190,10 +190,10 @@ export function Header() {
inverted per theme. Matches the web companion. */}
<img src="/LU-monogram-bw.png" alt="" width={33} height={33} className="dark:invert-0 invert opacity-80" />
</button>
- {/* Cloud "Hosted LU Workflows" waitlist teaser — subtle opt-in badge
- in the brand area (David 2026-06-06). Sends nothing unless the user
- explicitly joins; hidden for good only via "Don't show me again". */}
- <CloudWaitlistBadge />
+ {/* Global Local/Cloud switch (2.5.7) — replaced the waitlist teaser
+ the moment the cloud tier became real. Gated: flipping to Cloud
+ without a usable account opens the CloudGateModal instead. */}
+ <ModeSwitch />
</div>
{/* Center: model picker, geometrically centered between the logo (left)
@@ -283,8 +283,10 @@ export function Header() {
Compare
</button>
- {textNav('benchmark', 'Benchmark')}
- {textNav('models', 'Models')}
+ {/* Local-hardware surfaces — meaningless against hosted GPUs, so
+ cloud mode hides them (the AppShell guard also redirects). */}
+ {settings.appMode !== 'cloud' && textNav('benchmark', 'Benchmark')}
+ {settings.appMode !== 'cloud' && textNav('models', 'Models')}
{textNav('settings', 'Settings')}
</div>
@@ -323,8 +325,8 @@ export function Header() {
Compare
</button>
- {dropdownNav('benchmark', 'Benchmark')}
- {dropdownNav('models', 'Models')}
+ {settings.appMode !== 'cloud' && dropdownNav('benchmark', 'Benchmark')}
+ {settings.appMode !== 'cloud' && dropdownNav('models', 'Models')}
{dropdownNav('settings', 'Settings')}
</div>
diff --git a/src/hooks/useCloudAuth.ts b/src/hooks/useCloudAuth.ts
index 07d516ab..d3e2e475 100644
--- a/src/hooks/useCloudAuth.ts
+++ b/src/hooks/useCloudAuth.ts
@@ -5,11 +5,12 @@
// any manual provider setup.
import { useCallback, useEffect, useRef } from 'react'
-import { supabaseCloud } from '../api/cloud/supabase'
+import { supabaseCloud, loginWithProvider, type OAuthProvider } from '../api/cloud/supabase'
import { getMe, getQuota } from '../api/cloud/jobs'
import { useCloudAuthStore, deriveCloudAvailable } from '../stores/cloudAuthStore'
import { refreshCatalog } from '../stores/cloudCatalogStore'
import { useProviderStore } from '../stores/providerStore'
+import { useSettingsStore } from '../stores/settingsStore'
import type { CloudQuota } from '../lib/render/cloud-jobs'
const REFRESH_MS = 5 * 60_000
@@ -35,11 +36,22 @@ async function probeAccount(): Promise<void> {
}
store.setSignedIn({ id: me.user.id, email: me.user.email }, { licenseActive, tier, access, quota })
syncChatProvider()
+ syncAppMode()
} catch {
// 401 = no/expired session; network = cloud unreachable. Either way the
// cloud axis is off for now — local features are unaffected.
store.setSignedOut()
syncChatProvider()
+ syncAppMode()
+ }
+}
+
+// Never strand the app in cloud mode without a usable cloud: sign-out,
+// license loss or the beta gate flips the global switch back to Local.
+function syncAppMode(): void {
+ const settings = useSettingsStore.getState()
+ if (settings.settings.appMode === 'cloud' && !deriveCloudAvailable(useCloudAuthStore.getState())) {
+ settings.updateSettings({ appMode: 'local' })
}
}
@@ -82,15 +94,24 @@ export function useCloudAuth() {
await probeAccount()
}, [])
+ // Google/GitHub via system browser + PKCE loopback (same identities as
+ // lu-labs.ai). The browser round-trip can take a while — callers show a
+ // "waiting for browser" state until this resolves.
+ const loginOAuth = useCallback(async (provider: OAuthProvider): Promise<void> => {
+ await loginWithProvider(provider)
+ await probeAccount()
+ }, [])
+
const logout = useCallback(async (): Promise<void> => {
await supabaseCloud().auth.signOut().catch(() => {})
useCloudAuthStore.getState().setSignedOut()
syncChatProvider()
+ syncAppMode()
}, [])
const refresh = useCallback(async (): Promise<void> => {
await probeAccount()
}, [])
- return { status, user, login, signup, logout, refresh }
+ return { status, user, login, signup, loginOAuth, logout, refresh }
}
diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.ts
index f185226d..270a1da6 100644
--- a/src/hooks/useModels.ts
+++ b/src/hooks/useModels.ts
@@ -1,10 +1,11 @@
-import { useCallback, useEffect } from 'react'
+import { useCallback, useEffect, useMemo } from 'react'
import { listModels, pullModel as pullModelApi, pullModelTauri, deleteModel as deleteModelApi } from '../api/ollama'
import { isTauri } from '../api/backend'
import { getCheckpoints as getComfyCheckpoints, getDiffusionModels as getComfyDiffusionModels, checkComfyConnection, filterPartialFiles } from '../api/comfyui'
import { parseNDJSONStream } from '../api/stream'
import { useModelStore } from '../stores/modelStore'
import { useProviderStore } from '../stores/providerStore'
+import { useSettingsStore } from '../stores/settingsStore'
import { getEnabledProviders, prefixModelName, getProviderIdFromModel } from '../api/providers'
import { listBundledModels, bundledToAIModels, activateBuiltinModel, isManagedBuiltinActive } from '../api/engine'
import type { PullProgress, AIModel, ModelCategory, ImageModel, VideoModel, CloudModel } from '../types/models'
@@ -26,11 +27,20 @@ function isEmbeddingModel(name: string): boolean {
export function useModels() {
const {
- models, activeModel, activePulls, categoryFilter,
+ models: allModels, activeModel, activePulls, categoryFilter,
setModels, setActiveModel, startPull, updatePullProgress,
pausePull, completePull, dismissPull, setCategoryFilter,
} = useModelStore()
+ // Global Local/Cloud switch: one choke point for every picker — cloud mode
+ // surfaces only the hosted catalog, local mode hides it. The store keeps
+ // the full list (no refetch on flip); this is a view, not a mutation.
+ const appMode = useSettingsStore((s) => s.settings.appMode)
+ const models = useMemo(
+ () => allModels.filter((m) => (appMode === 'cloud' ? m.provider === 'lu-cloud' : m.provider !== 'lu-cloud')),
+ [allModels, appMode],
+ )
+
const isPulling = Object.keys(activePulls).length > 0
// Refresh trigger: any code path that just installed a model (onboarding,
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index c9f39b1c..54f16c6b 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -14,6 +14,8 @@ export const DEFAULT_SETTINGS: Settings = {
maxTokens: 0,
theme: 'dark',
onboardingDone: false,
+ // Global Local/Cloud switch (2.5.7) — local is and stays the default.
+ appMode: 'local',
personasEnabled: true,
thinkingEnabled: true,
// Small-Model Mode (v2.5.0) — lean profile for 3B-8B local models.
diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.ts
index 55950da3..525e49bc 100644
--- a/src/stores/uiStore.ts
+++ b/src/stores/uiStore.ts
@@ -5,14 +5,19 @@ export type View = 'chat' | 'models' | 'settings' | 'create' | 'benchmark'
interface UIState {
currentView: View
sidebarOpen: boolean
+ /** CloudGateModal (login → plan → beta gate) — opened by the header's
+ * Local/Cloud switch when the cloud side isn't usable yet. */
+ cloudGateOpen: boolean
setView: (view: View) => void
toggleSidebar: () => void
setSidebarOpen: (open: boolean) => void
+ setCloudGateOpen: (open: boolean) => void
}
export const useUIStore = create<UIState>()((set) => ({
currentView: 'chat',
sidebarOpen: true,
+ cloudGateOpen: false,
// Sidebar visibility follows the view: it's the conversation list, which
// only makes sense in Chat. The hamburger toggle still works on other views;
@@ -20,4 +25,5 @@ export const useUIStore = create<UIState>()((set) => ({
setView: (view) => set({ currentView: view, sidebarOpen: view === 'chat' }),
toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
setSidebarOpen: (open) => set({ sidebarOpen: open }),
+ setCloudGateOpen: (open) => set({ cloudGateOpen: open }),
}))
diff --git a/src/types/settings.ts b/src/types/settings.ts
index ade58c36..1820d30d 100644
--- a/src/types/settings.ts
+++ b/src/types/settings.ts
@@ -4,6 +4,8 @@ export type SearchProvider = 'auto' | 'brave' | 'tavily'
export type CavemanMode = 'off' | 'lite' | 'full' | 'ultra'
+export type AppMode = 'local' | 'cloud'
+
export interface Settings {
apiEndpoint: string
temperature: number
@@ -12,6 +14,15 @@ export interface Settings {
maxTokens: number
theme: 'light' | 'dark'
onboardingDone: boolean
+ /**
+ * Global Local/Cloud switch (2.5.7). 'local' = today's app (own hardware,
+ * every local provider). 'cloud' = the LU Cloud tier: chat/create/voice run
+ * on lu-labs.ai with the signed-in account, local-hardware surfaces hide.
+ * The header switch flips it; the CloudGateModal guards the cloud side
+ * (login → subscription → closed-beta gate). Persisted: reopen in the mode
+ * you left. Auto-falls back to 'local' when the account signs out.
+ */
+ appMode: AppMode
/** Master switch for personas. When off, new chats get no persona system
* prompt (raw model). Default true. Ported from the uselu web companion. */
personasEnabled: boolean