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): count every way into LU Cloud, pack next to the subscription, way back after the checkout
purple002622d8e101
diff --git a/e2e/cloud-gate-scrolls-in-a-low-window.spec.ts b/e2e/cloud-gate-scrolls-in-a-low-window.spec.tsindex 55b65fee..396283ef 100644--- a/e2e/cloud-gate-scrolls-in-a-low-window.spec.ts+++ b/e2e/cloud-gate-scrolls-in-a-low-window.spec.ts@@ -56,13 +56,19 @@ test('the gate is taller than a 230 px window, and every button is reached by scconst dialog = page.getByRole('dialog')const panel = await dialog.boundingBox()expect(panel!.height, 'the gate fits into the window, this spec tests nothing').toBeGreaterThan(LOW.height)- const toLogin = page.getByRole('button', { name: /Already subscribed\? Sign in/i })+ // Since 3.1.0 the sign in sits at the top of the panel (funnel Nr. 11), so+ // the button below the window edge is the last one, "See all plans".+ const toLogin = page.getByRole('button', { name: /Already bought\? Sign in/i })+ const allPlans = page.getByRole('button', { name: /See all plans/i })// The top of the dialog is not cut off: the wheel brings the X into the- // window, and from up there the way to the sign in form is below the edge.+ // window, and from up there the end of the panel is below the edge.await wheelTo(page, dialog.locator('[data-dialog-close]'))- expect(await insideWindow(toLogin)).toBe(false)+ expect(await insideWindow(allPlans)).toBe(false)+ await wheelTo(page, allPlans)+ await allPlans.click({ trial: true })+ // And back up to the sign in.await wheelTo(page, toLogin)await toLogin.click()@@ -77,7 +83,7 @@ test('the gate is taller than a 230 px window, and every button is reached by sc// The click arrived: the account has no plan, and the gate says so.await expect(page.getByText(/no active plan/i)).toBeAttached({ timeout: 20_000 })// The last button of that wall is reachable too.- const again = page.getByRole('button', { name: /I subscribed, check again/i })+ const again = page.getByRole('button', { name: /I bought, check again/i })await wheelTo(page, again)await again.click({ trial: true })})diff --git a/e2e/cloud-gate.spec.ts b/e2e/cloud-gate.spec.tsindex ae6c7356..0f76d9d2 100644--- a/e2e/cloud-gate.spec.ts+++ b/e2e/cloud-gate.spec.ts@@ -31,16 +31,18 @@ test('signed in without a plan: plan buttons → browser, switch stays off', asyawait expect(page.getByText(/no active plan/i)).toBeVisible({ timeout: 20_000 })- // The owner's 4 options: three plans (with the monthly price up front) + back- // to Local. `€` in the pattern keeps "Max" from matching the window's- // Maximize button.- await expect(page.getByRole('button', { name: /^Hosted €19/ })).toBeVisible()+ // The options: subscription and pack side by side (3.1.0), the two bigger+ // plans with the monthly price up front, and back to Local. `€` in the+ // pattern keeps "Max" from matching the window's Maximize button.+ await expect(page.getByTestId('buy-sub')).toBeVisible()+ await expect(page.getByTestId('buy-pack')).toBeVisible()+ await expect(page.getByRole('button', { name: /^Hosted €19/ })).toHaveCount(0)await expect(page.getByRole('button', { name: /^Pro €49/ })).toBeVisible()await expect(page.getByRole('button', { name: /Stay on Local/i })).toBeVisible()await page.getByRole('button', { name: /^Max €99/ }).click()const opened = await page.evaluate(() => (window as unknown as { __E2E_OPENED_URLS__?: string[] }).__E2E_OPENED_URLS__ ?? [])- expect(opened.some((u) => u.includes('/pricing#max'))).toBe(true)+ expect(opened.some((u) => new URL(u).pathname === '/pricing' && new URL(u).hash === '#max')).toBe(true)// Gate holds: the switch is still off. Read through the modal-proof locator —// the gate is still open here, and an open dialog marks the rest of the pagediff --git a/e2e/cloud-sales-panel.spec.ts b/e2e/cloud-sales-panel.spec.tsindex fa51a0ec..1bf23c84 100644--- a/e2e/cloud-sales-panel.spec.ts+++ b/e2e/cloud-sales-panel.spec.ts@@ -46,7 +46,8 @@ test('without a session one click opens the sales panel, not a login form', asyn).toBeVisible()await expect(panel(page)).toContainText('Turn on Cloud to reach the full catalogue from any machine.')await expect(panel(page)).toContainText('Your local models keep working exactly as they do now.')- await expect(panel(page)).toContainText('Cancel anytime. Local mode stays free and offline.')+ await expect(panel(page)).toContainText('Local mode stays free and offline.')+ await expect(panel(page)).toContainText('Cancel anytime')// Die drei gezaehlten Zeilen.const lines = page.getByTestId('cloud-sales-lines')@@ -66,31 +67,45 @@ test('without a session one click opens the sales panel, not a login form', asynawait expect(cloudSwitchBehindModal(page)).toHaveAttribute('aria-checked', 'false')})-test('the purchase button carries the price and leaves for the browser', async ({ page }) => {+test('subscription and pack stand side by side and leave for the checkout page', async ({ page }) => {await boot(page, { license: 'none' })await cloudSwitch(page).click()await expect(panel(page)).toBeVisible({ timeout: 20_000 })- const buy = page.getByRole('button', { name: 'Start Cloud for 19 EUR / month' })- await expect(buy).toBeVisible()- await buy.click()+ // Funnel 3.1.0 (Nr. 4): two equal ways in, the price on the subscription.+ await expect(page.getByTestId('buy-price-sub')).toHaveText('€19 / month')+ await expect(page.getByText('No subscription')).toBeVisible()+ const sub = page.getByTestId('buy-sub')+ const pack = page.getByTestId('buy-pack')+ const [a, b] = [await sub.boundingBox(), await pack.boundingBox()]+ expect(Math.abs(a!.width - b!.width), 'the two buttons are not the same size').toBeLessThan(2)+ expect(Math.abs(a!.y - b!.y), 'the two buttons are not side by side').toBeLessThan(2)+ await sub.click()+ await pack.click()const opened = await page.evaluate(() => (window as unknown as { __E2E_OPENED_URLS__?: string[] }).__E2E_OPENED_URLS__ ?? [],)- expect(opened.some((u) => u.endsWith('/pricing'))).toBe(true)- // Gekauft wird auf der Website. Die App hat nie eine Zahlung angefasst.- expect(opened.some((u) => /stripe|checkout\/start/i.test(u))).toBe(false)+ const starts = opened.filter((u) => u.includes('/checkout/start')).map((u) => new URL(u))+ expect(starts.map((u) => u.searchParams.get('plan') ?? u.searchParams.get('pack'))).toEqual(['hosted', 'pack-15'])+ for (const u of starts) {+ expect(u.searchParams.get('src')).toBe('app-gate-main')+ expect(u.searchParams.get('utm_source')).toBe('desktop')+ expect(u.searchParams.get('utm_medium')).toBe('gate')+ expect(u.searchParams.get('return')).toBe('app')+ }+ // Gekauft wird auf der Website, nie direkt beim Zahlungsanbieter.+ expect(opened.some((u) => /stripe/i.test(u))).toBe(false)// Und der Schalter ist davon nicht umgesprungen.await expect(cloudSwitchBehindModal(page)).toHaveAttribute('aria-checked', 'false')})-test('Already subscribed? Sign in reaches the existing login form', async ({ page }) => {+test('Already bought? Sign in reaches the existing login form', async ({ page }) => {await boot(page, { license: 'none' })await cloudSwitch(page).click()await expect(panel(page)).toBeVisible({ timeout: 20_000 })- await page.getByRole('button', { name: /Already subscribed\? Sign in/i }).click()+ await page.getByRole('button', { name: /Already bought\? Sign in/i }).click()await expect(page.getByPlaceholder('Email')).toBeVisible()await expect(page.getByPlaceholder('Password')).toBeVisible()diff --git a/e2e/support/cloud-mock.ts b/e2e/support/cloud-mock.tsindex cb62dffc..f0f90448 100644--- a/e2e/support/cloud-mock.ts+++ b/e2e/support/cloud-mock.ts@@ -453,7 +453,7 @@ export function cloudSwitchBehindModal(page: Page) {* zahlt, nimmt den Textlink darunter. */export async function signInViaGate(page: Page): Promise<void> {await cloudSwitch(page).click()- await page.getByRole('button', { name: /Already subscribed\? Sign in/i }).click()+ await page.getByRole('button', { name: /Already bought\? Sign in/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/src-tauri/src/commands/funnel.rs b/src-tauri/src/commands/funnel.rsindex f360da24..22d17212 100644--- a/src-tauri/src/commands/funnel.rs+++ b/src-tauri/src/commands/funnel.rs@@ -16,8 +16,9 @@ const LUC_SUPABASE_URL: &str = "https://lrrhheztdytyfpizvuup.supabase.co";const LUC_SUPABASE_ANON_KEY: &str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxycmhoZXp0ZHl0eWZwaXp2dXVwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODMxNDkwNzUsImV4cCI6MjA5ODcyNTA3NX0.1AuX4tmup82d3NHLAgQx1KdXhwlCkPcX7liB6eNSkAU";/// The four things a press on the Cloud switch can do (lib/cloud-switch-guard-/// on the frontend), and the three clicks in the pop-up behind it: a model,-/// a plan, a pack. The SQL function carries the same list.+/// on the frontend), the three clicks in the pop-up behind it (a model, a+/// plan, a pack) and, since 3.1.0, the other buttons into LU Cloud+/// (api/funnel.ts names each one). The SQL function carries the same list.pub(crate) const FUNNEL_EVENTS: &[&str] = &["cloud_switch_gate","cloud_switch_arm",@@ -26,6 +27,17 @@ pub(crate) const FUNNEL_EVENTS: &[&str] = &["cloud_gate_model_click","cloud_gate_pick_sub","cloud_gate_pick_credits",+ // 3.1.0 (funnel Nr. 3): the main buttons, the sign in, the plan buttons,+ // the Create sheet, the cloud offer and the onboarding hint.+ "cloud_gate_main_sub",+ "cloud_gate_main_pack",+ "cloud_gate_signin",+ "cloud_gate_plan_click",+ "cloud_teaser_sub",+ "cloud_teaser_pack",+ "cloud_teaser_hide",+ "cloud_offer_click",+ "cloud_onboarding_hint",];pub(crate) fn funnel_event_allowed(event: &str) -> bool {@@ -97,8 +109,8 @@ mod tests {for e in FUNNEL_EVENTS {assert!(funnel_event_allowed(e), "{e}");}- assert_eq!(FUNNEL_EVENTS.len(), 7);- for e in ["", "cloud_switch_seen", "cloud_gate_model", "cloud_gate_pick_sub ", "app_start", "cloud_switch_gate'; drop table x; --", "CLOUD_SWITCH_GATE"] {+ assert_eq!(FUNNEL_EVENTS.len(), 16);+ for e in ["", "cloud_switch_seen", "cloud_gate_model", "cloud_gate_pick_sub ", "cloud_teaser", "cloud_gate_main", "app_start", "cloud_switch_gate'; drop table x; --", "CLOUD_SWITCH_GATE"] {assert!(!funnel_event_allowed(e), "{e:?} must not count");}}diff --git a/src-tauri/src/hf_link.rs b/src-tauri/src/hf_link.rsindex 4e8f7325..67a8dcb3 100644--- a/src-tauri/src/hf_link.rs+++ b/src-tauri/src/hf_link.rs@@ -12,6 +12,13 @@//!//! The webview gets no permission of the deep-link plugin. It reads the inbox//! through `hf_link_take` and nothing else.+//!+//! Since 3.1.0 the same door takes a second link,+//! `locallyuncensored://cloud/open?status=paid|cancelled`: the way back from a+//! checkout on lu-labs.ai into the app (funnel Nr. 11). It carries no account+//! and no order, only whether the payment went through. The app then opens the+//! Cloud gate on the sign in; it never treats the link as proof of a purchase,+//! the account check on the server decides that as before.use serde::Serialize;use std::sync::Mutex;@@ -41,6 +48,9 @@ pub struct HfModelLink {#[serde(tag = "kind", rename_all = "camelCase")]pub enum Inbound {Model(HfModelLink),+ /// The way back from a checkout in the browser. `status` is `paid` or+ /// `cancelled`, nothing else passes.+ CloudReturn { status: String },/// A link with our scheme that failed a check. The page says so instead/// of the click going nowhere; the reason never echoes the link itself.Rejected { reason: String },@@ -141,23 +151,83 @@ pub fn parse(raw: &str) -> Result<HfModelLink, String> {Ok(HfModelLink { repo, file })}+/// The checkout's way back: `locallyuncensored://cloud/open?status=…`, with+/// the gate model and its category the web page may add (both checked, then+/// dropped: the app keeps its own pick). Err carries a sentence for the user.+pub fn parse_cloud_return(raw: &str) -> Result<String, String> {+ if raw.len() > MAX_LINK_LEN {+ return Err("The link is too long.".into());+ }+ let url = url::Url::parse(raw).map_err(|_| "The link is not a valid address.".to_string())?;+ if url.scheme() != SCHEME || url.host_str() != Some("cloud") {+ return Err("The link is not meant for this app.".into());+ }+ if !url.username().is_empty() || url.password().is_some() || url.port().is_some() {+ return Err("The link carries parts it must not have.".into());+ }+ if url.path() != "/open" || url.fragment().is_some() {+ return Err("The link asks for something this version cannot do.".into());+ }+ let mut status: Option<String> = None;+ let mut model: Option<String> = None;+ let mut category: Option<String> = None;+ for (key, value) in url.query_pairs() {+ let slot = match key.as_ref() {+ "status" => &mut status,+ "model" => &mut model,+ "category" => &mut category,+ _ => return Err("The link carries a parameter this version does not know.".into()),+ };+ if slot.is_some() {+ return Err("The link names a parameter twice.".into());+ }+ *slot = Some(value.into_owned());+ }+ if let Some(m) = &model {+ let ok = !m.is_empty() && m.len() <= 80 && m.bytes().all(|b| b.is_ascii_alphanumeric() || b"._:/-".contains(&b));+ if !ok {+ return Err("The link names no model this app knows.".into());+ }+ }+ if let Some(c) = &category {+ if !matches!(c.as_str(), "chat" | "code" | "create") {+ return Err("The link names no model this app knows.".into());+ }+ }+ match status.as_deref() {+ Some("paid") | Some("cancelled") => Ok(status.unwrap_or_default()),+ _ => Err("The link does not say how the checkout ended.".into()),+ }+}++/// Which of the two links this is, read by its host.+pub fn parse_inbound(raw: &str) -> Inbound {+ let cloud = url::Url::parse(raw).ok().map(|u| u.host_str() == Some("cloud")).unwrap_or(false);+ if cloud {+ return match parse_cloud_return(raw) {+ Ok(status) => Inbound::CloudReturn { status },+ Err(reason) => Inbound::Rejected { reason },+ };+ }+ match parse(raw) {+ Ok(link) => Inbound::Model(link),+ Err(reason) => Inbound::Rejected { reason },+ }+}+/// One link from the system: checked, put in the inbox (a newer link replaces/// an older one nobody took yet), the page told, the window brought forward.#[cfg(desktop)]pub fn accept(app: &tauri::AppHandle, raw: &str) {use tauri::{Emitter, Manager};- let inbound = match parse(raw) {- Ok(link) => {- tracing::info!(repo = %link.repo, file = ?link.file, "Hugging Face link received");- Inbound::Model(link)- }- Err(reason) => {- // The link itself stays out of the log: it is whatever a page- // chose to send.- tracing::warn!(%reason, "Hugging Face link rejected");- Inbound::Rejected { reason }- }- };+ let inbound = parse_inbound(raw);+ match &inbound {+ Inbound::Model(link) => tracing::info!(repo = %link.repo, file = ?link.file, "Hugging Face link received"),+ Inbound::CloudReturn { status } => tracing::info!(%status, "checkout return link received"),+ // The link itself stays out of the log: it is whatever a page chose+ // to send.+ Inbound::Rejected { reason } => tracing::warn!(%reason, "app link rejected"),+ }if let Some(inbox) = app.try_state::<HfLinkInbox>() {*inbox.0.lock().unwrap_or_else(|e| e.into_inner()) = Some(inbound);}@@ -350,6 +420,48 @@ mod tests {assert_eq!(serde_json::to_value(rejected).unwrap(), serde_json::json!({ "kind": "rejected", "reason": "x" }));}+ #[test]+ fn reads_the_way_back_from_a_checkout() {+ assert_eq!(parse_cloud_return("locallyuncensored://cloud/open?status=paid").unwrap(), "paid");+ assert_eq!(parse_cloud_return("locallyuncensored://cloud/open?status=cancelled").unwrap(), "cancelled");+ // What the web page builds (appReturnLink), with model and category.+ assert_eq!(+ parse_cloud_return("locallyuncensored://cloud/open?model=direct%2Fv-1.2&category=chat&status=paid").unwrap(),+ "paid"+ );+ assert!(matches!(+ parse_inbound("locallyuncensored://cloud/open?status=paid"),+ Inbound::CloudReturn { ref status } if status == "paid"+ ));+ // The model link still goes its own way.+ assert!(matches!(parse_inbound("locallyuncensored://open-model?repo=a/b"), Inbound::Model(_)));+ }++ #[test]+ fn refuses_every_other_cloud_link() {+ for raw in [+ "locallyuncensored://cloud/open",+ "locallyuncensored://cloud/open?status=",+ "locallyuncensored://cloud/open?status=refunded",+ "locallyuncensored://cloud/open?status=paid&status=paid",+ "locallyuncensored://cloud/open?status=paid&token=abc",+ "locallyuncensored://cloud/open?status=paid&next=https://evil.example",+ "locallyuncensored://cloud/open?status=paid&category=admin",+ "locallyuncensored://cloud/open?status=paid&model=a%20b",+ "locallyuncensored://cloud/open?status=paid#x",+ "locallyuncensored://cloud/buy?status=paid",+ "locallyuncensored://cloud/open/../x?status=paid",+ "locallyuncensored://user@cloud/open?status=paid",+ "locallyuncensored://cloud:9/open?status=paid",+ "lu://cloud/open?status=paid",+ ] {+ assert!(parse_cloud_return(raw).is_err(), "accepted {raw}");+ }+ assert!(matches!(parse_inbound("locallyuncensored://cloud/open?status=x"), Inbound::Rejected { .. }));+ let cloud = Inbound::CloudReturn { status: "paid".into() };+ assert_eq!(serde_json::to_value(cloud).unwrap(), serde_json::json!({ "kind": "cloudReturn", "status": "paid" }));+ }+/// The scheme the code answers to is the scheme the bundles register.#[test]fn every_desktop_config_registers_the_scheme() {diff --git a/src/api/funnel.ts b/src/api/funnel.tsindex d3719831..6116edbf 100644--- a/src/api/funnel.ts+++ b/src/api/funnel.ts@@ -27,6 +27,34 @@ export type GateFunnelEvent =| 'cloud_gate_model_click'| 'cloud_gate_pick_sub'| 'cloud_gate_pick_credits'+ | OfferFunnelEvent++/** The rest of the ways into LU Cloud (funnel 3.1.0, Nr. 3). Until then only+ * the model dropdowns of the gate were counted; the main button, the sign in+ * and the Create sheet were not, and 97 percent of the gate stayed blind.+ * Each name is one click on one button, nothing about who or which model:+ * cloud_gate_main_sub gate, signed out: Subscribe+ * cloud_gate_main_pack gate, signed out: Credit pack, no subscription+ * cloud_gate_signin gate, signed out: Already bought? Sign in+ * cloud_gate_plan_click gate: a plan button or See all plans+ * cloud_teaser_sub Create sheet: Subscribe+ * cloud_teaser_pack Create sheet: Credit pack+ * cloud_teaser_hide Create sheet: Don't show Cloud features+ * cloud_offer_click a model tile or Create: Try LU Cloud+ * cloud_onboarding_hint onboarding, small card: Run it in LU Cloud+ * Opening the gate is not a name of its own: the switch already counts it+ * (cloud_switch_gate), and a second count of the same visit would make the+ * steps after it look rarer than they are. */+export type OfferFunnelEvent =+ | 'cloud_gate_main_sub'+ | 'cloud_gate_main_pack'+ | 'cloud_gate_signin'+ | 'cloud_gate_plan_click'+ | 'cloud_teaser_sub'+ | 'cloud_teaser_pack'+ | 'cloud_teaser_hide'+ | 'cloud_offer_click'+ | 'cloud_onboarding_hint'export function funnelEventFor(action: CloudSwitchAction): FunnelEvent {switch (action) {diff --git a/src/components/auth/AccountPanel.tsx b/src/components/auth/AccountPanel.tsxindex ed107ac5..3a9de823 100644--- a/src/components/auth/AccountPanel.tsx+++ b/src/components/auth/AccountPanel.tsx@@ -9,7 +9,7 @@ import { Loader2, LogOut, ExternalLink } from 'lucide-react'import { useCloudAuth } from '../../hooks/useCloudAuth'import { useCloudAuthStore } from '../../stores/cloudAuthStore'import { loginWithProvider } from '../../api/cloud/supabase'-import { CLOUD_BASE } from '../../api/cloud/config'+import { cloudLink } from '../../lib/cloud-links'import { MONOGRAM } from '../layout/brand'import { openExternal } from '../../api/backend'import { formatCount } from '../../lib/formatters'@@ -321,7 +321,7 @@ export function AccountPanel() {{licenseActive ? ` ${PAST_DUE_WALLET_LINE}` : ''}</Hinweis><button- onClick={() => void openExternal(`${CLOUD_BASE}/account`)}+ onClick={() => void openExternal(cloudLink('/account', 'account'))}className="flex items-center gap-1 px-2 py-1 rounded text-[0.65rem] 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"><ExternalLink size={10} /> {PAST_DUE_ACTION}@@ -356,7 +356,7 @@ export function AccountPanel() {invoice is settled, and its button already leads to the account. */}{!(pastDue && !licenseActive) && (<button- onClick={() => void openExternal(`${CLOUD_BASE}/${licenseActive ? 'account' : 'pricing'}`)}+ onClick={() => void openExternal(cloudLink(licenseActive ? '/account' : '/pricing', 'account'))}className="flex items-center gap-1 text-[0.65rem] text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 transition-colors"><ExternalLink size={10} /> {licenseActive ? 'Manage subscription' : 'View plans'} on lu-labs.aidiff --git a/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx b/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsxindex 814bd67f..fe5514df 100644--- a/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx+++ b/src/components/auth/__tests__/a-failed-payment-is-shown-as-one.test.tsx@@ -62,7 +62,7 @@ describe('a failed renewal without credits', () => {fireEvent.click(screen.getByText('Pay open invoice'))expect(openExternal).toHaveBeenCalledTimes(1)- expect(openExternal).toHaveBeenCalledWith('https://lu-labs.ai/account')+ expect(openExternal).toHaveBeenCalledWith('https://lu-labs.ai/account?utm_source=desktop&utm_medium=account')})it('says "your plan" when the server does not name one', () => {diff --git a/src/components/cloud/BuyChoice.tsx b/src/components/cloud/BuyChoice.tsxnew file mode 100644index 00000000..440b41b9--- /dev/null+++ b/src/components/cloud/BuyChoice.tsx@@ -0,0 +1,97 @@+// The two ways into LU Cloud side by side, the same size and the same weight+// (funnel 3.1.0, Nr. 4): a subscription, and a credit pack that is no+// subscription. Until 3.1.0 the gate's one big button said "19 EUR / month"+// and the Create sheet sold only the subscription; the pack sat three clicks+// deep. 539 of 718 pack buyers never took a subscription, so the pack is a+// way in of its own, not a footnote.+//+// Both buttons go to the checkout start on lu-labs.ai (lib/cloud-links), which+// shows the order before anybody pays. The app takes no payment.+//+// The pack's price is read from the catalogue the gate loads; without an+// answer from the server the card names no number (lib/cloud-pitch keeps no+// pack sizes). The subscription's monthly price is the one CLOUD_PITCH holds.++import { ExternalLink } from 'lucide-react'+import { useEffect } from 'react'+import { CLOUD_PITCH } from '../../lib/cloud-pitch'+import { gatePackEur } from '../../lib/cloud-gate'+import type { CheckoutOrder } from '../../lib/cloud-links'+import { useCloudGateStore, refreshGateCatalog } from '../../stores/cloudGateStore'++export interface BuyChoiceProps {+ onPick: (order: CheckoutOrder) => void+ /** The gate is light and dark, the Create sheet is always dark. */+ tone?: 'gate' | 'sheet'+}++const eur = (n: number) => `€${n.toLocaleString('en-US')}`++/** The words of the two cards, for the panel and its tests. */+export function buyChoiceCards(packEur: number | null): { order: CheckoutOrder; title: string; price: string; note: string; button: string }[] {+ return [+ {+ order: 'sub',+ title: 'Subscription',+ price: `${eur(CLOUD_PITCH.hostedMonthlyEUR)} / month`,+ note: 'Cancel anytime',+ button: 'Subscribe',+ },+ {+ order: 'pack',+ title: 'Credit pack',+ price: packEur !== null ? `${eur(packEur)} once` : 'One payment',+ note: 'No subscription',+ button: 'Buy pack',+ },+ ]+}++export function BuyChoice({ onPick, tone = 'gate' }: BuyChoiceProps) {+ const offers = useCloudGateStore((s) => s.catalog?.offers ?? null)+ // The gate loads the catalogue with its model lists (GateModels); the+ // Create sheet has none, so it asks here. A failure keeps the card without+ // a pack price.+ useEffect(() => {+ if (tone === 'sheet') void refreshGateCatalog().catch(() => {})+ }, [tone])+ const cards = buyChoiceCards(gatePackEur(offers))+ const sheet = tone === 'sheet'+ return (+ <div className="grid grid-cols-2 gap-2" data-testid="buy-choice">+ {cards.map((c) => (+ <div+ key={c.order}+ data-order={c.order}+ className={+ sheet+ ? 'rounded-lg border border-white/10 p-2.5 flex flex-col gap-2'+ : 'rounded-lg border border-gray-200 dark:border-white/10 p-2.5 flex flex-col gap-2'+ }+ >+ <div className="text-center">+ <p className={sheet ? 't-micro font-semibold uppercase tracking-wide text-gray-400' : 't-micro font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400'}>+ {c.title}+ </p>+ <p className={sheet ? 't-body font-semibold text-white' : 't-body font-semibold text-gray-900 dark:text-white'} data-testid={`buy-price-${c.order}`}>+ {c.price}+ </p>+ <p className={sheet ? 't-micro text-gray-400' : 't-micro text-gray-500 dark:text-gray-400'}>{c.note}</p>+ </div>+ <button+ type="button"+ onClick={() => onPick(c.order)}+ data-testid={`buy-${c.order}`}+ className={+ sheet+ ? 'mt-auto w-full flex items-center justify-center gap-1.5 h-8 rounded-lg bg-white text-black t-control font-semibold hover:bg-gray-200 transition-colors'+ : 'mt-auto w-full flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg t-control bg-lu-cloud text-white hover:opacity-90 transition-opacity'+ }+ >+ <ExternalLink size={12} /> {c.button}+ </button>+ </div>+ ))}+ </div>+ )+}diff --git a/src/components/cloud/CloudGateModal.tsx b/src/components/cloud/CloudGateModal.tsxindex 447bfbad..76831024 100644--- a/src/components/cloud/CloudGateModal.tsx+++ b/src/components/cloud/CloudGateModal.tsx@@ -20,22 +20,24 @@// lu-labs.ai, die App fasst keine Zahlung an.import { useEffect, useState } from 'react'-import { ExternalLink, HardDrive, RefreshCw, ArrowLeft, ArrowRight, Check } from 'lucide-react'+import { ExternalLink, HardDrive, RefreshCw, ArrowLeft, ArrowRight, Check, LogIn } 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, isMacOS } from '../../api/backend'import { MONOGRAM, MONOGRAM_INVERT } from '../layout/brand'-import { CLOUD_PITCH, CLOUD_SUBSCRIBER_LINE, cloudSalesLines } from '../../lib/cloud-pitch'+import { CLOUD_SUBSCRIBER_LINE, cloudSalesLines } from '../../lib/cloud-pitch'import { PAST_DUE_ACTION, pastDueLine } from '../../lib/past-due'import { Hinweis } from '../ui/Hinweis'import { cloudGateHeadline } from '../../lib/mac-pc-words'import { GateModels } from './GateModels'import { landOnGatePick } from '../../lib/cloud-gate-landing'+import { BuyChoice } from './BuyChoice'+import { reportCloudGate } from '../../api/funnel'+import { checkoutStartUrl, cloudLink, type CheckoutOrder, type CloudGateOpener, type CloudLinkMedium } from '../../lib/cloud-links'const PLANS = [{ anchor: 'hosted', name: 'Hosted', price: '€19' },@@ -45,14 +47,22 @@ const PLANS = [/** Three plan buttons → pricing in the browser. Price shown up front (monthly,* EUR — mirrors lib/pricing on lu-labs.ai); the click still leaves for the- * browser to actually subscribe. */+ * browser to actually subscribe. Counted since 3.1.0 (cloud_gate_plan_click)+ * and tagged with where it came from (lib/cloud-links). */function PlanGrid() {+ const from = useUIStore((s) => s.cloudGateFrom)+ // Hosted is the subscription card of BuyChoice right above (3.1.0), so the+ // grid keeps the two bigger plans and does not offer Hosted twice.+ const bigger = PLANS.filter((p) => p.anchor !== 'hosted')return (- <div className="grid grid-cols-3 gap-2">- {PLANS.map((p) => (+ <div className="grid grid-cols-2 gap-2" data-testid="gate-plan-grid">+ {bigger.map((p) => (<buttonkey={p.anchor}- onClick={() => void openExternal(`${CLOUD_BASE}/pricing#${p.anchor}`)}+ onClick={() => {+ reportCloudGate('cloud_gate_plan_click')+ void openExternal(cloudLink(`/pricing#${p.anchor}`, 'gate-plans', from))+ }}className="flex flex-col items-center gap-0.5 px-2 py-3 rounded-lg border border-lu-cloud/40 bg-lu-cloud/5 hover:bg-lu-cloud/15 transition-colors"><span className="text-[0.8rem] font-semibold text-lu-cloud dark:text-lu-cloud-lift">{p.name}</span>@@ -65,6 +75,13 @@ function PlanGrid() {)}+/** One of the two buttons of the gate (signed out, or signed in without a+ * plan): counted, then the checkout start with where it came from. */+function openGateCheckout(order: CheckoutOrder, src: 'app-gate-main' | 'app-gate-plans', medium: CloudLinkMedium, from: CloudGateOpener): void {+ reportCloudGate(order === 'sub' ? 'cloud_gate_main_sub' : 'cloud_gate_main_pack')+ void openExternal(checkoutStartUrl({ order, src, medium, opener: from }))+}+/** Deliberately big (2026-07-18): the way back to Local must be as* unmissable as the plans, in every gate state. */function StayLocalButton({ onLocal }: { onLocal: () => void }) {@@ -89,7 +106,7 @@ function PastDueNotice({ tier }: { tier: string | null }) {return (<div className="space-y-3" data-testid="cloud-gate-past-due"><Hinweis ton="fehler">{pastDueLine(tier)}</Hinweis>- <button className={primaryBtn} onClick={() => void openExternal(`${CLOUD_BASE}/account`)}>+ <button className={primaryBtn} onClick={() => void openExternal(cloudLink('/account', 'gate'))}><ExternalLink size={12} /> {PAST_DUE_ACTION}</button></div>@@ -114,18 +131,39 @@ const linkRow =* Bis hierher zeigte derselbe Klick ein Login-Fenster. Das ist die falsche* Frage an dieser Stelle: wer noch nichts gekauft hat, kann sich nicht* anmelden, und ein Anmeldefeld sagt ihm nicht, wofuer. Das Panel beantwortet- * zuerst, was hinter dem Schalter liegt, und laesst die Anmeldung als- * Nebenweg fuer den stehen, der schon Kunde ist.+ * zuerst, was hinter dem Schalter liegt.+ *+ * Seit 3.1.0 (Funnel 13.11.2026):+ * * Ganz oben, gut sichtbar, der Rueckweg fuer den, der schon gekauft hat+ * (Nr. 11). Bis dahin stand er als kleiner Textlink unter dem Kaufknopf,+ * und wer aus dem Browser zurueckkam, fand zuerst wieder das Angebot.+ * * Statt eines Knopfs "19 EUR / month", der auf die Preisseite ging, zwei+ * gleich grosse Wege: Abo und Paket ohne Abo (Nr. 4). Beide gehen auf+ * die Kaufseite `/checkout/start`, nie direkt zum Zahlungsanbieter.+ * * Jeder Klick hier wird gezaehlt (api/funnel.ts) und jeder Link sagt,+ * woher er kommt (lib/cloud-links).*- * Gekauft wird im Browser, nicht hier: der Knopf oeffnet `/pricing`. Die App- * hat nie eine Zahlung angefasst und faengt damit auch jetzt nicht an.+ * Gekauft wird im Browser, nicht hier. Die App hat nie eine Zahlung+ * angefasst und faengt damit auch jetzt nicht an.*- * Schlicht mit Absicht (Auftrag): dieselben Tailwind-Marken wie die uebrigen- * Dialoge, derselbe Knopfstil, kein Verlauf, kein Leuchten, kein Emoji.+ * Schlicht mit Absicht: dieselben Tailwind-Marken wie die uebrigen Dialoge,+ * derselbe Knopfstil, kein Verlauf, kein Leuchten, kein Emoji.*/function CloudSalesPanel({ onSignIn }: { onSignIn: () => void }) {+ const from = useUIStore((s) => s.cloudGateFrom)return (<div className="space-y-5 pt-2" data-testid="cloud-sales-panel">+ <button+ type="button"+ onClick={() => {+ reportCloudGate('cloud_gate_signin')+ onSignIn()+ }}+ className={ghostBtn + ' max-w-xs mx-auto'}+ data-testid="cloud-gate-signin-top"+ >+ <LogIn size={12} /> Already bought? Sign in+ </button><div className="flex flex-col items-center text-center gap-2"><span className="text-[0.6rem] font-semibold uppercase tracking-widest text-lu-cloud dark:text-lu-cloud-lift">Cloud@@ -155,23 +193,22 @@ function CloudSalesPanel({ onSignIn }: { onSignIn: () => void }) {two ways in; GateModels has the rest. */}<GateModels /><div className="space-y-2 max-w-xs mx-auto">- <button- onClick={() => void openExternal(`${CLOUD_BASE}/pricing`)}- className={primaryBtn}- >- Start Cloud for {CLOUD_PITCH.hostedMonthlyEUR} EUR / month- </button>+ <BuyChoice onPick={(order) => openGateCheckout(order, 'app-gate-main', 'gate', from)} /><p className="text-[0.62rem] leading-relaxed text-center text-gray-500 dark:text-gray-400">{CLOUD_SUBSCRIBER_LINE}</p>- {/* Der Weg fuer den, der schon zahlt. Er fuehrt in denselben- Anmeldeschritt wie vorher, nur heisst der Einstieg jetzt, was er- ist. */}- <button onClick={onSignIn} className={linkRow + ' w-full pt-1'}>- Already subscribed? Sign in <ArrowRight size={11} />+ <button+ type="button"+ onClick={() => {+ reportCloudGate('cloud_gate_plan_click')+ void openExternal(cloudLink('/pricing', 'gate', from))+ }}+ className={linkRow + ' w-full'}+ >+ See all plans <ArrowRight size={11} /></button><p className="text-[0.6rem] leading-relaxed text-center text-gray-400 dark:text-gray-500">- Cancel anytime. Local mode stays free and offline.+ Local mode stays free and offline.</p></div></div>@@ -232,11 +269,22 @@ export function CloudGateModal() {// documented "adjust state while rendering" shape. As an effect it was a// cascading render (React 19 `set-state-in-effect`) that landed after paint,// so a re-open showed one frame of the step the gate was last left on.- const [step, setStep] = useState<Step>('sales')+ // A checkout that came back through the app's link (HfLinkInbox,+ // locallyuncensored://cloud/open?status=paid) opens the gate on the sign in:+ // the purchase is done, what is missing is the account in the app (Nr. 11).+ const checkoutReturn = useUIStore((s) => s.cloudGateReturn)+ const setCheckoutReturn = useUIStore((s) => s.setCloudGateReturn)+ const from = useUIStore((s) => s.cloudGateFrom)+ const [step, setStep] = useState<Step>(() => (open && checkoutReturn === 'paid' ? 'login' : 'sales'))const [wasOpen, setWasOpen] = useState(open)+ const [seenReturn, setSeenReturn] = useState(checkoutReturn)if (wasOpen !== open) {setWasOpen(open)- if (open) setStep('sales')+ if (open) setStep(checkoutReturn === 'paid' ? 'login' : 'sales')+ }+ if (seenReturn !== checkoutReturn) {+ setSeenReturn(checkoutReturn)+ if (checkoutReturn === 'paid') setStep('login')}// The moment the account clears every gate — already provisioned when the@@ -272,6 +320,7 @@ export function CloudGateModal() {const setPendingCloudModel = useUIStore((s) => s.setPendingCloudModel)const close = () => {setPendingCloudModel(null)+ setCheckoutReturn(null)setOpen(false)}@@ -296,7 +345,11 @@ export function CloudGateModal() {) : (/* step === 'login' */<div className="space-y-4 pt-2">- <CloudHero subtitle="Sign in with the account you subscribed with." />+ <CloudHero+ subtitle={checkoutReturn === 'paid'+ ? 'Thanks for your purchase. Sign in with the same account you used in the browser, and Cloud turns on.'+ : 'Sign in with the account you bought with.'}+ /><div className="max-w-xs mx-auto"><AccountPanel />{/* Zurueck fuehrt an die einzige Stelle, von der man hierher@@ -326,13 +379,14 @@ export function CloudGateModal() {<div className="space-y-3 max-w-xs mx-auto"><p className="text-[0.72rem] text-center 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.+ but this account has no active plan yet. LU Cloud runs on a subscription or on a credit pack.</p>+ <BuyChoice onPick={(order) => openGateCheckout(order, 'app-gate-plans', 'gate-plans', from)} /><PlanGrid /><GateModels /><StayLocalButton onLocal={stayLocal} /><button className={ghostBtn} onClick={() => void refresh()}>- <RefreshCw size={12} /> I subscribed, check again+ <RefreshCw size={12} /> I bought, check again</button></div>)}@@ -382,7 +436,7 @@ export function CloudGateModal() {budget, so there's nothing for Cloud mode to run on. Plans withcloud credits are on lu-labs.ai.</p>- <button className={primaryBtn} onClick={() => void openExternal(`${CLOUD_BASE}/account`)}>+ <button className={primaryBtn} onClick={() => void openExternal(cloudLink('/account', 'gate'))}><ExternalLink size={12} /> Open your account</button></>diff --git a/src/components/cloud/CloudOffer.tsx b/src/components/cloud/CloudOffer.tsxindex 8ea66fa2..cad15f0a 100644--- a/src/components/cloud/CloudOffer.tsx+++ b/src/components/cloud/CloudOffer.tsx@@ -11,6 +11,7 @@import { Cloud } from 'lucide-react'import { useUIStore } from '../../stores/uiStore'+import { reportCloudGate } from '../../api/funnel'import { useSettingsStore } from '../../stores/settingsStore'import { useCreateStore } from '../../stores/createStore'import { useCloudAuthStore, deriveCloudAvailable } from '../../stores/cloudAuthStore'@@ -37,7 +38,7 @@ export function openCloudFor(task: CloudOfferTask): void {if (deriveCloudAvailable(useCloudAuthStore.getState())) ui.setView('create')}ui.setPendingCloudModel(null)- ui.setCloudGateOpen(true)+ ui.setCloudGateOpen(true, 'cloud-offer')}/**@@ -86,7 +87,12 @@ export function CloudOfferButton({ task }: { task: CloudOfferTask }) {return (<buttontype="button"- onClick={() => openCloudFor(task)}+ onClick={() => {+ // Counted since 3.1.0 (funnel Nr. 3): the offer opens the gate, which+ // the switch's own count does not see.+ reportCloudGate('cloud_offer_click')+ openCloudFor(task)+ }}title={CLOUD_OFFER_TITLE}data-testid="cloud-offer-button"className="inline font-medium text-lu-cloud dark:text-lu-cloud-lift hover:underline underline-offset-2"diff --git a/src/components/cloud/CloudSwitch.tsx b/src/components/cloud/CloudSwitch.tsxindex d15e9fcd..062efead 100644--- a/src/components/cloud/CloudSwitch.tsx+++ b/src/components/cloud/CloudSwitch.tsx@@ -58,7 +58,7 @@ export function CloudSwitch() {updateSettings({ appMode: 'local' })returncase 'open-gate':- setCloudGateOpen(true)+ setCloudGateOpen(true, 'switch')returncase 'arm':setArmed(true)diff --git a/src/components/cloud/CloudTeaserModal.tsx b/src/components/cloud/CloudTeaserModal.tsxindex d23547e9..170008cd 100644--- a/src/components/cloud/CloudTeaserModal.tsx+++ b/src/components/cloud/CloudTeaserModal.tsx@@ -19,7 +19,9 @@ import { isMlxImageHost } from '../../api/mlx-image'import { mlxMakesMusic } from '../../lib/mac-music'import { mlxFollowsMotion, mlxTalking } from '../../api/mlx-video'import { openExternal, isMacOS } from '../../api/backend'-import { CLOUD_BASE } from '../../api/cloud/config'+import { checkoutStartUrl } from '../../lib/cloud-links'+import { reportCloudGate } from '../../api/funnel'+import { BuyChoice } from './BuyChoice'import { getMaxVramGb, getSharedMemoryGb } from '../../lib/hardware'import { sharedMemoryWording } from '../../lib/shared-memory-wording'@@ -125,6 +127,7 @@ export function CloudTeaserModal() {// that says what it does, and the switch in Settings, General.const close = () => setCloudTeaser(null)const hideCloudFeatures = () => {+ reportCloudGate('cloud_teaser_hide')updateSettings({ cloudTeasersEnabled: false })setCloudTeaser(null)// The tabs and rows vanish with this click, so Create says where they@@ -204,23 +207,23 @@ export function CloudTeaserModal() {{macMemoryGb !== null && `This Mac has ${macMemoryGb} GB of memory. `}{teaserWhereLine(localLane !== null, sharedMemory)}</p>- <div className="flex items-center gap-2 pt-1">- <button- onClick={() => {- // Straight into signup and checkout with Hosted preselected- // (2026-09-07: "die Pricing-Seite ist eine- // Entscheidung zu viel"). Until 2.6.8 this opened- // CloudGateModal, which asks for a login before it shows a- // single price. The src tag names the card size, so the- // funnel on the server can say what this button brings.- close()- const src = gpuGb !== null ? `gpu${gpuGb}` : 'gpu-unknown'- void openExternal(`${CLOUD_BASE}/checkout/start?plan=hosted&src=${src}`)- }}- className="flex-1 flex items-center justify-center gap-1.5 h-8 rounded-lg bg-white text-black text-[0.7rem] font-semibold hover:bg-gray-200 transition-colors"- >- <Sparkles size={12} /> Get LU Cloud- </button>+ {/* Abo und Paket gleichrangig (Funnel 3.1.0, Nr. 4). Bis dahin+ verkaufte dieses Blatt nur das Hosted-Abo. Beide Knoepfe gehen+ auf die Kaufseite, nicht zum Zahlungsanbieter: Hosted vorgewaehlt bzw.+ das Paket (2026-09-07: "die Pricing-Seite ist eine+ Entscheidung zu viel"). Das src-Wort nennt die Kartengroesse,+ damit der Zaehler auf dem Server sagen kann, was dieses+ Blatt bringt. */}+ <BuyChoice+ tone="sheet"+ onPick={(order) => {+ close()+ reportCloudGate(order === 'sub' ? 'cloud_teaser_sub' : 'cloud_teaser_pack')+ const src = gpuGb !== null ? `gpu${gpuGb}` : 'gpu-unknown'+ void openExternal(checkoutStartUrl({ order, src, medium: 'create-sheet' }))+ }}+ />+ <div className="flex items-center gap-2">{localLane && (<buttononClick={() => { close(); setIntent(localLane) }}@@ -231,7 +234,7 @@ export function CloudTeaserModal() {)}<buttononClick={close}- className="px-3 h-8 rounded-lg text-[0.7rem] text-gray-400 hover:text-gray-200 hover:bg-white/[0.06] transition-colors"+ className="flex-1 px-3 h-8 rounded-lg text-[0.7rem] text-gray-400 hover:text-gray-200 hover:bg-white/[0.06] transition-colors">Not now</button>diff --git a/src/components/cloud/GateModels.tsx b/src/components/cloud/GateModels.tsxindex fe625a8a..651ee449 100644--- a/src/components/cloud/GateModels.tsx+++ b/src/components/cloud/GateModels.tsx@@ -181,7 +181,7 @@ function GateBuyWindow({ model, category, offers, onBack }: {const big = category !== 'create' && tooBigForThisMachine(model.id, budget)const go = (way: GateWay) => {reportCloudGate(way === 'sub' ? 'cloud_gate_pick_sub' : 'cloud_gate_pick_credits')- void openExternal(gateCheckoutUrl(CLOUD_BASE, way, model.id, category))+ void openExternal(gateCheckoutUrl(CLOUD_BASE, way, model.id, category, useUIStore.getState().cloudGateFrom))}const ways: { way: GateWay; title: string; button: string }[] = [{ way: 'sub', title: 'Subscription', button: 'Subscribe' },diff --git a/src/components/cloud/OnboardingCloudHint.tsx b/src/components/cloud/OnboardingCloudHint.tsxnew file mode 100644index 00000000..3546b2c9--- /dev/null+++ b/src/components/cloud/OnboardingCloudHint.tsx@@ -0,0 +1,67 @@+// A quiet line under "Install ComfyUI" for a small graphics card (funnel+// 3.1.0, Nr. 14). Until then the onboarding never named the cloud: a card with+// 8 GB or less was sent into a download of several gigabytes for video that+// then runs slowly or not at all, and LU Cloud came up only after that.+//+// It is a hint, not a fork: the install button stays the first choice, the+// line sits below it in the quiet text colour, and it shows only when the card+// is known and small. No card found (0) says nothing, because a failed+// detection is not a small card. The Mac never gets here (no ComfyUI there).+// "Show Cloud features in Local mode" switched off hides it like every other+// cloud hint in local mode.+//+// The link goes to the pricing page in the browser, tagged with where it came+// from (lib/cloud-links), and the click is counted (cloud_onboarding_hint).++import { useEffect, useState } from 'react'+import { Cloud } from 'lucide-react'+import { getMaxVramGb } from '../../lib/hardware'+import { cloudLink } from '../../lib/cloud-links'+import { openExternal, isMacOS } from '../../api/backend'+import { reportCloudGate } from '../../api/funnel'+import { useSettingsStore } from '../../stores/settingsStore'++/** At or below this many GB the hint shows. */+export const SMALL_CARD_GB = 8++/** Whether a card of this size gets the hint. Unknown (0 or less) does not. */+export function smallCard(vramGb: number): boolean {+ return vramGb > 0 && vramGb <= SMALL_CARD_GB+}++export function onboardingHintLine(vramGb: number): string {+ return `Your GPU has ${Math.round(vramGb)} GB. Images run on it. The bigger video models want 12 GB or more.`+}++export function OnboardingCloudHint() {+ const enabled = useSettingsStore((s) => s.settings.cloudTeasersEnabled)+ const [vramGb, setVramGb] = useState(0)+ useEffect(() => {+ if (isMacOS()) return+ let alive = true+ void getMaxVramGb().then((gb) => { if (alive) setVramGb(gb) })+ return () => { alive = false }+ }, [])+ if (enabled === false || !smallCard(vramGb)) return null+ return (+ <p+ className="flex items-start gap-1.5 text-left t-micro leading-snug text-gray-500"+ data-testid="onboarding-cloud-hint"+ >+ <Cloud size={11} className="mt-[2px] shrink-0 text-lu-cloud dark:text-lu-cloud-lift" aria-hidden />+ <span>+ {onboardingHintLine(vramGb)}{' '}+ <button+ type="button"+ onClick={() => {+ reportCloudGate('cloud_onboarding_hint')+ void openExternal(cloudLink('/pricing', 'onboarding'))+ }}+ className="inline font-medium text-lu-cloud dark:text-lu-cloud-lift hover:underline underline-offset-2"+ >+ Run it in LU Cloud instead+ </button>+ </span>+ </p>+ )+}diff --git a/src/components/cloud/__tests__/back-from-checkout-and-onboarding-hint.test.tsx b/src/components/cloud/__tests__/back-from-checkout-and-onboarding-hint.test.tsxnew file mode 100644index 00000000..0d22e4c1--- /dev/null+++ b/src/components/cloud/__tests__/back-from-checkout-and-onboarding-hint.test.tsx@@ -0,0 +1,108 @@+// @vitest-environment jsdom+/**+ * Funnel 3.1.0:+ * Nr. 11 the way back from a checkout, locallyuncensored://cloud/open, is+ * taken out of the same inbox as the Hugging Face link and opens the+ * gate. It proves nothing about a purchase: the gate checks the+ * account as on every opening.+ * Nr. 14 a small card hears about LU Cloud in the onboarding, quietly,+ * with a tagged and counted link.+ *+ * Run: npx vitest run src/components/cloud/__tests__/back-from-checkout-and-onboarding-hint.test.tsx+ */+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'++const openExternal = vi.fn(async () => {})+const backendCall = vi.fn(async (_cmd: string, _args?: unknown): Promise<unknown> => undefined)+const mac = { on: false }+vi.mock('../../../api/backend', () => ({+ openExternal,+ backendCall: (cmd: string, args?: unknown) => backendCall(cmd, args),+ isMacOS: () => mac.on,+ isTauri: () => false,+}))+const vram = { gb: 8 }+vi.mock('../../../lib/hardware', () => ({ getMaxVramGb: () => Promise.resolve(vram.gb) }))++const { takeHfLink } = await import('../../models/HfLinkInbox')+const { readInbound } = await import('../../../lib/hf-link')+const { useUIStore } = await import('../../../stores/uiStore')+const { useSettingsStore } = await import('../../../stores/settingsStore')+const { OnboardingCloudHint, smallCard } = await import('../OnboardingCloudHint')++const events = () => backendCall.mock.calls+ .filter((c) => c[0] === 'funnel_ping')+ .map((c) => (c[1] as { event: string }).event)++beforeEach(() => {+ backendCall.mockReset()+ backendCall.mockResolvedValue(undefined)+ openExternal.mockClear()+ mac.on = false+ vram.gb = 8+ useSettingsStore.getState().updateSettings({ cloudTeasersEnabled: true })+})+afterEach(() => {+ cleanup()+ useUIStore.getState().setCloudGateOpen(false)+ useUIStore.getState().setCloudGateReturn(null)+})++describe('the way back from a checkout', () => {+ it('reads only paid or cancelled', () => {+ expect(readInbound({ kind: 'cloudReturn', status: 'paid' })).toEqual({ kind: 'cloudReturn', status: 'paid' })+ expect(readInbound({ kind: 'cloudReturn', status: 'cancelled' })).toEqual({ kind: 'cloudReturn', status: 'cancelled' })+ expect(readInbound({ kind: 'cloudReturn', status: 'refunded' })).toBeNull()+ expect(readInbound({ kind: 'cloudReturn' })).toBeNull()+ })++ it('opens the gate from the inbox, marked as a return', async () => {+ backendCall.mockImplementation(async (cmd: string) => (cmd === 'hf_link_take' ? { kind: 'cloudReturn', status: 'paid' } : undefined))+ await takeHfLink()+ const ui = useUIStore.getState()+ expect(ui.cloudGateOpen).toBe(true)+ expect(ui.cloudGateReturn).toBe('paid')+ expect(ui.cloudGateFrom).toBe('checkout-return')+ // The app never switches to Cloud on the link alone.+ expect(useSettingsStore.getState().settings.appMode).not.toBe('cloud')+ })+})++describe('the onboarding hint for a small card', () => {+ it('shows at 8 GB and below, never for an unknown or a bigger card', () => {+ expect(smallCard(8)).toBe(true)+ expect(smallCard(6)).toBe(true)+ expect(smallCard(8.5)).toBe(false)+ expect(smallCard(12)).toBe(false)+ expect(smallCard(0)).toBe(false)+ })++ it('says the size, links to the pricing page with its place and counts the click', async () => {+ await act(async () => { render(<OnboardingCloudHint />) })+ const hint = screen.getByTestId('onboarding-cloud-hint')+ expect(hint.textContent).toContain('Your GPU has 8 GB.')+ fireEvent.click(screen.getByText('Run it in LU Cloud instead'))+ expect(events()).toEqual(['cloud_onboarding_hint'])+ const u = new URL(String((openExternal.mock.calls[0] as unknown[])[0]))+ expect(u.pathname).toBe('/pricing')+ expect(u.searchParams.get('utm_source')).toBe('desktop')+ expect(u.searchParams.get('utm_medium')).toBe('onboarding')+ })++ it('stays away on a big card, on a Mac and with the Cloud features off', async () => {+ vram.gb = 16+ await act(async () => { render(<OnboardingCloudHint />) })+ expect(screen.queryByTestId('onboarding-cloud-hint')).toBeNull()+ cleanup()+ vram.gb = 6+ mac.on = true+ await act(async () => { render(<OnboardingCloudHint />) })+ expect(screen.queryByTestId('onboarding-cloud-hint')).toBeNull()+ cleanup()+ mac.on = false+ useSettingsStore.getState().updateSettings({ cloudTeasersEnabled: false })+ await act(async () => { render(<OnboardingCloudHint />) })+ expect(screen.queryByTestId('onboarding-cloud-hint')).toBeNull()+ })+})diff --git a/src/components/cloud/__tests__/cloud-path-shortened.test.ts b/src/components/cloud/__tests__/cloud-path-shortened.test.tsindex 45169cf2..1494fbfa 100644--- a/src/components/cloud/__tests__/cloud-path-shortened.test.ts+++ b/src/components/cloud/__tests__/cloud-path-shortened.test.ts@@ -50,9 +50,12 @@ describe('the example-video stage is gone', () => {it('the teaser sheet goes straight into checkout from both surfaces', () => {// The intent branch used to call setCloudExampleVideo, then both branches// went to the in-app gate. Since 2026-09-07 the one button opens- // /checkout/start in the browser with Hosted preselected and the card- // size as src, and the gate is no longer referenced from the sheet.- expect(teaser).toMatch(/openExternal\(`\$\{CLOUD_BASE\}\/checkout\/start\?plan=hosted&src=\$\{src\}`\)/)+ // /checkout/start in the browser with the card size as src, and the gate+ // is no longer referenced from the sheet. Since 3.1.0 with two equal+ // buttons, the subscription and the pack (funnel Nr. 4), both through+ // lib/cloud-links, which adds the place the click came from.+ expect(teaser).toMatch(/openExternal\(checkoutStartUrl\(\{ order, src, medium: 'create-sheet' \}\)\)/)+ expect(teaser).toMatch(/<BuyChoice/)expect(teaser).toMatch(/gpuGb !== null \? `gpu\$\{gpuGb\}` : 'gpu-unknown'/)expect(teaser).not.toMatch(/setCloudGateOpen/)expect(teaser).not.toMatch(/setCloudExampleVideo/)@@ -79,10 +82,10 @@ describe('the example-video stage is gone', () => {*/describe('the in-app login survives wherever the sales panel leads', () => {it('the sign-in entry sits on the sales panel, exactly once', () => {- const entries = gate.match(/Already subscribed\? Sign in/g) ?? []+ const entries = gate.match(/Already bought\? Sign in/g) ?? []expect(entries.length, 'sign-in entry must be on the sales panel').toBe(1)// Der alte Wortlaut darf nicht danebenstehen bleiben.- expect(gate).not.toMatch(/Already got an account/)+ expect(gate).not.toMatch(/Already got an account|Already subscribed\? Sign in/)})it('it reaches the login step', () => {@@ -101,8 +104,12 @@ describe('the in-app login survives wherever the sales panel leads', () => {expect(start, 'sales panel not found').toBeGreaterThan(-1)expect(end, 'the monogram comment no longer follows the panel').toBeGreaterThan(start)const panel = gate.slice(start, end)- expect(panel).toMatch(/Already subscribed\? Sign in/)+ expect(panel).toMatch(/Already bought\? Sign in/)expect(panel).toMatch(/onSignIn/)+ // Funnel 3.1.0 (Nr. 11): at the top, before the headline, not under the+ // buy buttons where somebody back from the browser found the offer first.+ expect(panel.indexOf('Already bought? Sign in')).toBeLessThan(panel.indexOf('cloudGateHeadline('))+ expect(panel.indexOf('Already bought? Sign in')).toBeLessThan(panel.indexOf('<BuyChoice'))})it('the login step still has a way back, and it points at the panel', () => {@@ -133,12 +140,14 @@ describe('the sales panel argues before it asks for a login', () => {expect(cloudGateHeadline(false)).toBe('Run uncensored models in the cloud, no GPU needed.')expect(flach).toContain('Turn on Cloud to reach the full catalogue from any machine.')expect(flach).toContain('Your local models keep working exactly as they do now.')- expect(flach).toContain('Cancel anytime. Local mode stays free and offline.')+ expect(flach).toContain('Local mode stays free and offline.')})it('takes the three lines and the price from the constants, never typed', () => {expect(panel).toContain('cloudSalesLines()')- expect(panel).toContain('CLOUD_PITCH.hostedMonthlyEUR')+ // The price sits on the subscription card of BuyChoice since 3.1.0.+ expect(panel).toContain('<BuyChoice')+ expect(read('src/components/cloud/BuyChoice.tsx')).toContain('CLOUD_PITCH.hostedMonthlyEUR')expect(panel).toContain('CLOUD_SUBSCRIBER_LINE')// Negativkontrolle: keine getippte Zahl im Kaufknopf. Genau so ist der// Nenner des Blatts einmal veraltet stehen geblieben.@@ -147,9 +156,15 @@ describe('the sales panel argues before it asks for a login', () => {})it('sends the purchase to the browser, never into the app', () => {- expect(panel).toMatch(/openExternal\(`\$\{CLOUD_BASE\}\/pricing`\)/)+ // Both buttons go to the checkout start on lu-labs.ai, "See all plans"+ // to the pricing page, each through lib/cloud-links.+ expect(panel).toMatch(/openGateCheckout\(order, 'app-gate-main', 'gate', from\)/)+ expect(panel).toMatch(/openExternal\(cloudLink\('\/pricing', 'gate', from\)\)/)+ const links = read('src/lib/cloud-links.ts')+ expect(links).toMatch(/cloudLink\(`\/checkout\/start\?/)// Die App hat nie eine Zahlung angefasst.- expect(panel).not.toMatch(/stripe|checkout\/start/i)+ expect(panel).not.toMatch(/stripe/i)+ expect(links).not.toMatch(/stripe\.com|checkout\.stripe/i)})it('is plain: no gradient, no glow, no emoji', () => {diff --git a/src/components/cloud/__tests__/cloud-teaser-close-keeps-setting.test.tsx b/src/components/cloud/__tests__/cloud-teaser-close-keeps-setting.test.tsxindex 0184738a..81d83c1b 100644--- a/src/components/cloud/__tests__/cloud-teaser-close-keeps-setting.test.tsx+++ b/src/components/cloud/__tests__/cloud-teaser-close-keeps-setting.test.tsx@@ -55,8 +55,8 @@ describe('closing the Cloud sheet', () => {expect(enabled()).toBe(true)})- it('"Get LU Cloud" opens the checkout and leaves the setting on', () => {- fireEvent.click(screen.getByText('Get LU Cloud'))+ it('"Subscribe" opens the checkout and leaves the setting on', () => {+ fireEvent.click(screen.getByTestId('buy-sub'))expect(openExternal).toHaveBeenCalledTimes(1)expect(open()).toBe(false)expect(enabled()).toBe(true)diff --git a/src/components/cloud/__tests__/cloud-teaser-speaks-mac.test.tsx b/src/components/cloud/__tests__/cloud-teaser-speaks-mac.test.tsxindex b55a57ed..4cbc12f7 100644--- a/src/components/cloud/__tests__/cloud-teaser-speaks-mac.test.tsx+++ b/src/components/cloud/__tests__/cloud-teaser-speaks-mac.test.tsx@@ -89,7 +89,7 @@ describe('on a Mac', () => {probe.card = 16probe.ram = 16await openSheet(UPSCALE)- fireEvent.click(screen.getByText('Get LU Cloud'))+ fireEvent.click(screen.getByTestId('buy-sub'))expect(openExternal).toHaveBeenCalledTimes(1)expect(String(openExternal.mock.calls[0][0])).toContain('src=gpu-unknown')})@@ -107,7 +107,7 @@ describe('WINDOWS CONTROL', () => {expect(screen.getByTestId('cloud-teaser-where').textContent).toMatch(/^Your GPU has 12 GB\. (Runs on your PC with downloaded models, or on LU Cloud where datacenter GPUs do the heavy lifting\.|Runs on LU Cloud, where datacenter GPUs do the heavy lifting and VRAM is not the limit\.)$/,)- fireEvent.click(screen.getByText('Get LU Cloud'))+ fireEvent.click(screen.getByTestId('buy-sub'))expect(String(openExternal.mock.calls[0][0])).toContain('src=gpu12')})})diff --git a/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts b/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.tsindex 52db76f2..84bdcc1e 100644--- a/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts+++ b/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts@@ -25,13 +25,17 @@ describe('the Cloud switch counts its presses', () => {it('names the same events in TypeScript and in Rust', () => {const ts = read('src/api/funnel.ts')const rs = read('src-tauri/src/commands/funnel.rs')- const tsEvents = [...ts.matchAll(/'(cloud_(?:switch|gate)_[a-z_]+)'/g)].map((m) => m[1])+ const tsEvents = [...ts.matchAll(/'(cloud_(?:switch|gate|teaser|offer|onboarding)_[a-z_]+)'/g)].map((m) => m[1])const rsBlock = rs.slice(rs.indexOf('FUNNEL_EVENTS'), rs.indexOf('];', rs.indexOf('FUNNEL_EVENTS')))- const rsEvents = [...rsBlock.matchAll(/"(cloud_(?:switch|gate)_[a-z_]+)"/g)].map((m) => m[1])+ const rsEvents = [...rsBlock.matchAll(/"(cloud_(?:switch|gate|teaser|offer|onboarding)_[a-z_]+)"/g)].map((m) => m[1])const uniq = (a: string[]) => [...new Set(a)].sort()expect(uniq(tsEvents)).toEqual([+ 'cloud_gate_main_pack', 'cloud_gate_main_sub','cloud_gate_model_click', 'cloud_gate_pick_credits', 'cloud_gate_pick_sub',+ 'cloud_gate_plan_click', 'cloud_gate_signin',+ 'cloud_offer_click', 'cloud_onboarding_hint','cloud_switch_arm', 'cloud_switch_enter', 'cloud_switch_gate', 'cloud_switch_leave',+ 'cloud_teaser_hide', 'cloud_teaser_pack', 'cloud_teaser_sub',])expect(uniq(rsEvents)).toEqual(uniq(tsEvents))})@@ -50,7 +54,7 @@ describe('the Cloud switch counts its presses', () => {// Signed in, the same press is counted for the account too (api/funnel.ts).expect(settings).toContain('a press of the Cloud switch is counted for your account as well')// The clicks in the gate pop-up are counted too, without the model.- expect(settings).toContain('A click in the window behind the switch counts the same way: that a model, a plan or a pack was clicked, not which model.')+ expect(settings).toContain('A click on a way into LU Cloud counts the same way (a model, a plan, a pack, the sign in, or hiding the Cloud features), never which model.')// A counter and "no telemetry" do not go on the same page.expect(settings).not.toMatch(/no telemetry/i)})diff --git a/src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsx b/src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsxindex b24c6cde..d528a875 100644--- a/src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsx+++ b/src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsx@@ -77,7 +77,7 @@ describe('a failed renewal without credits', () => {fireEvent.click(screen.getByRole('button', { name: PAST_DUE_ACTION }))expect(openExternal).toHaveBeenCalledTimes(1)- expect(openExternal).toHaveBeenCalledWith('https://lu-labs.ai/account')+ expect(openExternal).toHaveBeenCalledWith('https://lu-labs.ai/account?utm_source=desktop&utm_medium=gate')// Nothing on this state opens the pricing page.expect(openExternal.mock.calls.flat().some((u) => String(u).includes('/pricing'))).toBe(false)})@@ -109,12 +109,16 @@ describe('a failed renewal whose pack credits are used up', () => {})describe('no failed payment', () => {- it('an account without a plan sees the three plans as before', async () => {+ it('an account without a plan sees subscription, pack and the two bigger plans', async () => {await openGate({})expect(screen.getByText(/no active plan yet/)).toBeTruthy()- expect(planButtons()).toHaveLength(3)- expect(screen.getByRole('button', { name: /I subscribed, check again/ })).toBeTruthy()+ // Since 3.1.0 Hosted is the subscription card next to the pack, and the+ // grid keeps Pro and Max.+ expect(screen.getByTestId('buy-sub')).toBeTruthy()+ expect(screen.getByTestId('buy-pack')).toBeTruthy()+ expect(planButtons()).toHaveLength(2)+ expect(screen.getByRole('button', { name: /I bought, check again/ })).toBeTruthy()expect(screen.queryByTestId('cloud-gate-past-due')).toBeNull()})diff --git a/src/components/cloud/__tests__/the-gate-sells-pack-and-plan-and-counts.test.tsx b/src/components/cloud/__tests__/the-gate-sells-pack-and-plan-and-counts.test.tsxnew file mode 100644index 00000000..32d59e00--- /dev/null+++ b/src/components/cloud/__tests__/the-gate-sells-pack-and-plan-and-counts.test.tsx@@ -0,0 +1,187 @@+// @vitest-environment jsdom+/**+ * Funnel 3.1.0 on the gate and the Create sheet:+ * Nr. 3 every button into LU Cloud is counted, by name only,+ * Nr. 4 the pack stands next to the subscription, same size, same weight,+ * Nr. 11 "Already bought? Sign in" at the top, and a checkout that came+ * back through the app's link opens the gate on the sign in.+ *+ * Run: npx vitest run src/components/cloud/__tests__/the-gate-sells-pack-and-plan-and-counts.test.tsx+ */+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'++const openExternal = vi.fn(async () => {})+const backendCall = vi.fn(async () => undefined)+vi.mock('../../../api/backend', () => ({ openExternal, backendCall, isMacOS: () => false, isTauri: () => true }))+vi.mock('../../../hooks/useGraphicsMemory', () => ({ useGraphicsMemoryGb: () => 12 }))+vi.mock('../../../lib/hardware', () => ({ getMaxVramGb: () => Promise.resolve(8), getSharedMemoryGb: () => Promise.resolve(0) }))+const getPublicCatalog = vi.fn()+vi.mock('../../../api/cloud/public-catalog', () => ({ getPublicCatalog }))++const { CloudGateModal } = await import('../CloudGateModal')+const { CloudTeaserModal } = await import('../CloudTeaserModal')+const { useCloudAuthStore } = await import('../../../stores/cloudAuthStore')+const { useUIStore } = await import('../../../stores/uiStore')+const { useCloudGateStore } = await import('../../../stores/cloudGateStore')+const { useSettingsStore } = await import('../../../stores/settingsStore')+const { parseGateCatalog } = await import('../../../lib/cloud-gate')++const live = parseGateCatalog({+ version: 1,+ categories: {+ chat: [{ id: 'moonshotai/Kimi-K3', label: 'Kimi K3' }],+ code: [{ id: 'moonshotai/Kimi-K3', label: 'Kimi K3' }],+ create: [{ id: 'flux-dev', label: 'Flux Dev', kind: 'image' }],+ },+ offers: {+ plans: [{ tier: 'hosted', interval: 'month', eur: 19, images: 3000, clips: 112 }],+ packs: [{ id: 'pack-15', eur: 15, images: 1500, clips: 56 }],+ },+})!++const events = () => backendCall.mock.calls+ .filter((c) => (c as unknown[])[0] === 'funnel_ping')+ .map((c) => ((c as unknown[])[1] as { event: string }).event)+const opened = () => openExternal.mock.calls.map((c) => new URL(String((c as unknown[])[0])))++async function openGate(from?: 'switch' | 'model-picker') {+ useCloudAuthStore.getState().setSignedOut()+ useUIStore.getState().setCloudGateOpen(true, from)+ await act(async () => { render(<CloudGateModal />) })+}++beforeEach(() => {+ getPublicCatalog.mockResolvedValue(live)+ useCloudGateStore.setState({ catalog: null, pick: null })+ useSettingsStore.getState().updateSettings({ cloudTeasersEnabled: true })+})+afterEach(() => {+ cleanup()+ openExternal.mockClear()+ backendCall.mockClear()+ useUIStore.getState().setCloudGateOpen(false)+ useUIStore.getState().setCloudGateReturn(null)+ useUIStore.getState().setCloudTeaser(null)+})++describe('the gate, signed out', () => {+ it('puts "Already bought? Sign in" first and counts it', async () => {+ await openGate()+ const panel = screen.getByTestId('cloud-sales-panel')+ const signIn = screen.getByTestId('cloud-gate-signin-top')+ expect(panel.firstElementChild).toBe(signIn)+ expect(signIn.textContent).toContain('Already bought? Sign in')+ fireEvent.click(signIn)+ expect(events()).toEqual(['cloud_gate_signin'])+ expect(screen.getByText('Sign in with the account you bought with.')).toBeTruthy()+ })++ it('shows subscription and pack side by side, the pack price from the catalogue', async () => {+ await openGate()+ expect(screen.getByTestId('buy-price-sub').textContent).toBe('€19 / month')+ expect(screen.getByTestId('buy-price-pack').textContent).toBe('€15 once')+ expect(screen.getByText('No subscription')).toBeTruthy()+ const grid = screen.getByTestId('buy-choice')+ expect(grid.className).toContain('grid-cols-2')+ // Same button style on both: neither is the lesser way.+ expect(screen.getByTestId('buy-sub').className).toBe(screen.getByTestId('buy-pack').className)+ })++ it('names no pack price without an answer from the server', async () => {+ getPublicCatalog.mockResolvedValue(null)+ await openGate()+ expect(screen.getByTestId('buy-price-pack').textContent).toBe('One payment')+ })++ it('counts each buy button once and opens the checkout start with its place', async () => {+ await openGate('model-picker')+ fireEvent.click(screen.getByTestId('buy-sub'))+ fireEvent.click(screen.getByTestId('buy-pack'))+ expect(events()).toEqual(['cloud_gate_main_sub', 'cloud_gate_main_pack'])+ const [sub, pack] = opened()+ expect(sub.pathname).toBe('/checkout/start')+ expect(sub.searchParams.get('plan')).toBe('hosted')+ expect(pack.searchParams.get('pack')).toBe('pack-15')+ for (const u of [sub, pack]) {+ expect(u.searchParams.get('src')).toBe('app-gate-main')+ expect(u.searchParams.get('utm_source')).toBe('desktop')+ expect(u.searchParams.get('utm_medium')).toBe('gate')+ expect(u.searchParams.get('utm_content')).toBe('model-picker')+ expect(u.searchParams.get('scheme')).toBe('locallyuncensored')+ }+ expect(openExternal.mock.calls.flat().some((u) => /stripe/i.test(String(u)))).toBe(false)+ })++ it('counts "See all plans" as a plan click and tags the pricing page', async () => {+ await openGate()+ fireEvent.click(screen.getByText('See all plans'))+ expect(events()).toEqual(['cloud_gate_plan_click'])+ const [u] = opened()+ expect(u.pathname).toBe('/pricing')+ expect(u.searchParams.get('utm_medium')).toBe('gate')+ })++ it('does not count the opening itself: the switch already does', async () => {+ await openGate()+ expect(events()).toEqual([])+ })+})++describe('back from the checkout', () => {+ it('opens on the sign in with a thank you, not on the offer', async () => {+ useUIStore.getState().setCloudGateReturn('paid')+ await openGate()+ expect(screen.queryByTestId('cloud-sales-panel')).toBeNull()+ expect(screen.getByText(/Thanks for your purchase\. Sign in with the same account you used in the browser/)).toBeTruthy()+ })++ it('a link that arrives while the gate is open switches to the sign in', async () => {+ await openGate()+ expect(screen.getByTestId('cloud-sales-panel')).toBeTruthy()+ await act(async () => { useUIStore.getState().setCloudGateReturn('paid') })+ expect(screen.queryByTestId('cloud-sales-panel')).toBeNull()+ })++ it('a cancelled checkout shows the offer again', async () => {+ useUIStore.getState().setCloudGateReturn('cancelled')+ await openGate()+ expect(screen.getByTestId('cloud-sales-panel')).toBeTruthy()+ })+})++describe('the Create sheet', () => {+ async function openSheet() {+ useUIStore.getState().setCloudTeaser({ surface: 'intent', intent: 'upscale' })+ await act(async () => { render(<CloudTeaserModal />) })+ }++ it('sells the pack next to the subscription, both counted, both tagged', async () => {+ await openSheet()+ expect(screen.getByTestId('buy-price-pack').textContent).toBe('€15 once')+ fireEvent.click(screen.getByTestId('buy-pack'))+ expect(events()).toEqual(['cloud_teaser_pack'])+ const [u] = opened()+ expect(u.pathname).toBe('/checkout/start')+ expect(u.searchParams.get('pack')).toBe('pack-15')+ expect(u.searchParams.get('src')).toBe('gpu8')+ expect(u.searchParams.get('utm_medium')).toBe('create-sheet')+ })++ it('counts the subscription button', async () => {+ await openSheet()+ fireEvent.click(screen.getByTestId('buy-sub'))+ expect(events()).toEqual(['cloud_teaser_sub'])+ expect(opened()[0].searchParams.get('plan')).toBe('hosted')+ })++ it('counts hiding the Cloud features, and Not now stays uncounted', async () => {+ await openSheet()+ fireEvent.click(screen.getByText('Not now'))+ expect(events()).toEqual([])+ cleanup()+ await openSheet()+ fireEvent.click(screen.getByText("Don't show Cloud features in Local mode"))+ expect(events()).toEqual(['cloud_teaser_hide'])+ })+})diff --git a/src/components/create/experimental/CreditsMeter.tsx b/src/components/create/experimental/CreditsMeter.tsxindex a7ae290d..8cafb4ba 100644--- a/src/components/create/experimental/CreditsMeter.tsx+++ b/src/components/create/experimental/CreditsMeter.tsx@@ -3,7 +3,7 @@ import { useRunCredits } from './useRunCredits'import { meterState } from '../../../lib/render/credits-meter'import { Tooltip } from '../ui/Tooltip'import { openExternal } from '../../../api/backend'-import { CLOUD_BASE } from '../../../api/cloud/config'+import { cloudLink } from '../../../lib/cloud-links'import { cn } from '../ui/cn'import { HINWEIS_TEXT, PUNKT_FARBE } from '../../../lib/hinweis'@@ -36,7 +36,7 @@ export function CreditsMeter() {// Zwischenton: es haelt den Lauf an. Regel in lib/hinweis.ts.const upsell = (label: string, tab?: 'credits') => (<button- onClick={() => void openExternal(`${CLOUD_BASE}/pricing${tab ? '?tab=credits' : ''}`)}+ onClick={() => void openExternal(cloudLink(`/pricing${tab ? '?tab=credits' : ''}`, 'credits-meter'))}className={cn('t-control px-2 h-[var(--control-h-sm)] inline-flex items-center rounded-md','bg-white/[0.04] hover:bg-white/[0.08] transition-colors',diff --git a/src/components/layout/CreditsExhaustedModal.tsx b/src/components/layout/CreditsExhaustedModal.tsxindex dfe63f07..bc7eec18 100644--- a/src/components/layout/CreditsExhaustedModal.tsx+++ b/src/components/layout/CreditsExhaustedModal.tsx@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'import { Zap } from 'lucide-react'import { Modal } from '../ui/Modal'import { ModalActions, ModalButton } from '../ui/ModalActions'-import { CREDITS_EXHAUSTED_EVENT, PRICING_URL, type ExhaustedReason } from '../../lib/credits-exhausted'+import { CREDITS_EXHAUSTED_EVENT, PRICING_LINK, type ExhaustedReason } from '../../lib/credits-exhausted'import { CLOUD_SUBSCRIBER_LINE } from '../../lib/cloud-pitch'import { openExternal } from '../../api/backend'@@ -74,7 +74,7 @@ export function CreditsExhaustedModal() {variant="primary"data-autofocusonClick={() => {- void openExternal(PRICING_URL)+ void openExternal(PRICING_LINK)setOpen(false)}}>diff --git a/src/components/layout/__tests__/der-leere-beutel-fuehrt-auf-die-preisseite.test.tsx b/src/components/layout/__tests__/der-leere-beutel-fuehrt-auf-die-preisseite.test.tsxindex 80b4d767..b797968f 100644--- a/src/components/layout/__tests__/der-leere-beutel-fuehrt-auf-die-preisseite.test.tsx+++ b/src/components/layout/__tests__/der-leere-beutel-fuehrt-auf-die-preisseite.test.tsx@@ -26,7 +26,7 @@ describe('der Dialog bei leerem Guthaben', () => {render(<CreditsExhaustedModal />)act(() => { window.dispatchEvent(new Event(CREDITS_EXHAUSTED_EVENT)) })fireEvent.click(screen.getByText('See plans and packs'))- expect(geoeffnet, 'der Knopf hat nichts geoeffnet').toEqual([`${CLOUD_BASE}/pricing`])+ expect(geoeffnet, 'der Knopf hat nichts geoeffnet').toEqual([`${CLOUD_BASE}/pricing?utm_source=desktop&utm_medium=credits-empty`])// Negativkontrolle in dieselbe Richtung: kein Weg dieses Dialogs zeigt// noch auf die Aufladeseite, weder der Knopf noch der Satz im Verlauf.expect(geoeffnet[0], 'der Knopf springt wieder in den Kauf').not.toContain('/credits')diff --git a/src/components/models/HfLinkInbox.tsx b/src/components/models/HfLinkInbox.tsxindex f554c3ba..c0006a08 100644--- a/src/components/models/HfLinkInbox.tsx+++ b/src/components/models/HfLinkInbox.tsx@@ -35,13 +35,24 @@ export async function takeHfLink(): Promise<void> {store.reject(inbound.reason)return}+ if (inbound.kind === 'cloudReturn') {+ // Back from the checkout in the browser (funnel Nr. 11). The gate opens,+ // re-checks the account on its own, and after a payment it starts on the+ // sign in instead of the offer. An account that can use the cloud now+ // flips straight over, as on every opening of the gate.+ const ui = useUIStore.getState()+ ui.setCloudGateReturn(inbound.status)+ ui.setCloudGateOpen(true, 'checkout-return')+ return+ }const inCloud = useSettingsStore.getState().settings.appMode === 'cloud'store.offer(inbound.link, inCloud)if (!inCloud) openModelsForLink()}/**- * The receiving end of `locallyuncensored://open-model` links. Mounted once in+ * The receiving end of `locallyuncensored://open-model` links, and since 3.1.0+ * of `locallyuncensored://cloud/open`, the way back from a checkout. Mounted once in* the app shell. It only routes: the question about the download itself is* asked in Models (HfLinkDialog). What it shows itself is the two cases that* never get there: a link that failed the check, and a link that arrivesdiff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex f5b0b412..85d5bd9c 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -106,7 +106,7 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {const open = (model?: string) => {setPendingCloudModel(model ?? null)onOpen()- setCloudGateOpen(true)+ setCloudGateOpen(true, 'model-picker')}return (<div className="mt-1 border-t border-white/[0.05]">diff --git a/src/components/onboarding/ComfyStep.tsx b/src/components/onboarding/ComfyStep.tsxindex 58e2d7af..e0d2e6ab 100644--- a/src/components/onboarding/ComfyStep.tsx+++ b/src/components/onboarding/ComfyStep.tsx@@ -35,6 +35,7 @@ import { isRunning, formatElapsed, lastLog, type InstallerStatusResponse } fromimport type { Step } from './wizard-steps'import type { OnboardingSkin } from './onboarding-skin'import type { InstallerFleet } from './use-installer-fleet'+import { OnboardingCloudHint } from '../cloud/OnboardingCloudHint'interface ComfyStepProps {skin: OnboardingSkin@@ -484,6 +485,9 @@ export function ComfyStep({ skin, fleet, step, setStep }: ComfyStepProps) {</button></div>)}+ {/* Funnel 3.1.0 (Nr. 14): a small card hears about LU Cloud here,+ before the download, not after a slow first clip. */}+ <OnboardingCloudHint /></div>)}diff --git a/src/components/release/ReleaseNotesModal.tsx b/src/components/release/ReleaseNotesModal.tsxindex 748cb6e4..25ef8dd9 100644--- a/src/components/release/ReleaseNotesModal.tsx+++ b/src/components/release/ReleaseNotesModal.tsx@@ -69,7 +69,7 @@ export function ReleaseNotesModal() {const turnOnCloud = () => {close()if (cloudAvailable) updateSettings({ appMode: 'cloud' })- else setCloudGateOpen(true)+ else setCloudGateOpen(true, 'release-notes')}if (!note) return nulldiff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex 09736816..a27dd089 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -72,6 +72,7 @@ import { troubleshootHinweis, type TroubleshootHinweis } from './troubleshoot-meimport { isMlxImageHost } from '../../api/mlx-image'import { ArrowUpCircle, KeyRound, RefreshCw } from 'lucide-react'import { CLOUD_BASE } from '../../api/cloud/config'+import { cloudLink } from '../../lib/cloud-links'import { formatBytes } from '../../lib/formatters'import { syncCustomModelDir, type CustomModelDirResult } from '../../lib/custom-model-dir'import { listBundledModels, lastCustomScanDir, lastScanDirs, type ScannedDir } from '../../api/engine'@@ -1963,7 +1964,7 @@ export function SettingsPage() {A key spends plan tokens only; it can never read or change the account.</p><button- onClick={() => void openExternal(`${CLOUD_BASE}/account`)}+ onClick={() => void openExternal(cloudLink('/account', 'settings'))}className="flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[0.65rem] font-medium bg-violet-500/15 text-violet-500 dark:text-violet-300 hover:bg-violet-500/25 transition-colors"><KeyRound size={11} /> Generate API key on lu-labs.ai@@ -2255,7 +2256,7 @@ export function SettingsPage() {<div><p className="text-gray-700 dark:text-gray-300 font-medium mb-0.5">Local by default.</p><p>Chat, agent runs, image & video generation all execute on your machine. LU has no analytics kit and sends no crash reports.</p>- <p className="mt-1">On its own LU uses the network for two things. It asks GitHub Releases for a new version a few seconds after start and at most every six hours after that; a new version is downloaded in the background unless you switch that off under Updates, and installing always needs your click. And it counts each press of the Cloud switch with LU Labs: which way it was pressed, platform and app version, no identifier. A click in the window behind the switch counts the same way: that a model, a plan or a pack was clicked, not which model.</p>+ <p className="mt-1">On its own LU uses the network for two things. It asks GitHub Releases for a new version a few seconds after start and at most every six hours after that; a new version is downloaded in the background unless you switch that off under Updates, and installing always needs your click. And it counts each press of the Cloud switch with LU Labs: which way it was pressed, platform and app version, no identifier. A click on a way into LU Cloud counts the same way (a model, a plan, a pack, the sign in, or hiding the Cloud features), never which model.</p><p className="mt-1">While you are signed in to LU Cloud, the app also checks your account at lu-labs.ai every five minutes, and a press of the Cloud switch is counted for your account as well.</p><p className="mt-1">Everything else that goes online you start yourself: model and engine downloads, cloud providers you set up with your own API keys, web search in agent runs, and Remote Access.</p></div>diff --git a/src/components/settings/__tests__/settings-update-and-keys.test.ts b/src/components/settings/__tests__/settings-update-and-keys.test.tsindex f48e4c76..efa9d5b8 100644--- a/src/components/settings/__tests__/settings-update-and-keys.test.ts+++ b/src/components/settings/__tests__/settings-update-and-keys.test.ts@@ -48,7 +48,7 @@ describe('Settings update section uses the in-app updater', () => {describe('Cloud API Keys section', () => {it('exists and points at the account page on lu-labs.ai', () => {expect(src).toContain('<Section title="Cloud API Keys">')- expect(src).toContain('openExternal(`${CLOUD_BASE}/account`)')+ expect(src).toContain("openExternal(cloudLink('/account', 'settings'))")})it('names the OpenAI-compatible base URL', () => {diff --git a/src/lib/__tests__/cloud-gate.test.ts b/src/lib/__tests__/cloud-gate.test.tsindex 2d80d294..423aa067 100644--- a/src/lib/__tests__/cloud-gate.test.ts+++ b/src/lib/__tests__/cloud-gate.test.ts@@ -82,11 +82,15 @@ describe('the checkout link', () => {expect(sub.origin + sub.pathname).toBe('https://lu-labs.ai/checkout/start')expect(Object.fromEntries(sub.searchParams)).toEqual({plan: 'hosted', interval: 'month', src: 'app-gate', model: 'deepseek-ai/DeepSeek-V4.1-Flash', category: 'chat', return: 'app',+ scheme: 'locallyuncensored', utm_source: 'desktop', utm_medium: 'gate-models',})const pack = new URL(gateCheckoutUrl('https://lu-labs.ai', 'credits', 'flux-dev', 'create'))expect(Object.fromEntries(pack.searchParams)).toEqual({pack: 'pack-15', src: 'app-gate', model: 'flux-dev', category: 'create', return: 'app',+ scheme: 'locallyuncensored', utm_source: 'desktop', utm_medium: 'gate-models',})+ // Where the gate was opened from rides along as utm_content.+ expect(new URL(gateCheckoutUrl('https://lu-labs.ai', 'sub', 'x', 'chat', 'model-picker')).searchParams.get('utm_content')).toBe('model-picker')})})diff --git a/src/lib/__tests__/cloud-links.test.ts b/src/lib/__tests__/cloud-links.test.tsnew file mode 100644index 00000000..3bcfbdb4--- /dev/null+++ b/src/lib/__tests__/cloud-links.test.ts@@ -0,0 +1,84 @@+/**+ * Funnel 3.1.0 (Nr. 3): every link from the app to lu-labs.ai says where it+ * was clicked, and the checkout link goes to the checkout start page with the+ * order, never to the payment provider.+ *+ * Run: npx vitest run src/lib/__tests__/cloud-links.test.ts+ */+import { describe, it, expect } from 'vitest'+import { readFileSync, readdirSync, statSync } from 'node:fs'+import { join, resolve } from 'node:path'+import { cloudLink, checkoutStartUrl, APP_RETURN_SCHEME } from '../cloud-links'++const BASE = 'https://lu-labs.ai'+const params = (u: string) => Object.fromEntries(new URL(u).searchParams)++describe('cloudLink', () => {+ it('adds the source and the place, and keeps a hash at the end', () => {+ expect(cloudLink('/pricing', 'gate', undefined, BASE)).toBe('https://lu-labs.ai/pricing?utm_source=desktop&utm_medium=gate')+ expect(cloudLink('/pricing#max', 'gate-plans', 'switch', BASE))+ .toBe('https://lu-labs.ai/pricing?utm_source=desktop&utm_medium=gate-plans&utm_content=switch#max')+ expect(cloudLink('/pricing?tab=credits', 'credits-meter', undefined, BASE))+ .toBe('https://lu-labs.ai/pricing?tab=credits&utm_source=desktop&utm_medium=credits-meter')+ expect(cloudLink('account', 'settings', undefined, BASE)).toBe('https://lu-labs.ai/account?utm_source=desktop&utm_medium=settings')+ })+})++describe('checkoutStartUrl', () => {+ it('names the order, the source, the way back and the place', () => {+ const sub = new URL(checkoutStartUrl({ order: 'sub', src: 'app-gate-main', medium: 'gate', opener: 'switch', base: BASE }))+ expect(sub.origin + sub.pathname).toBe('https://lu-labs.ai/checkout/start')+ expect(params(sub.href)).toEqual({+ plan: 'hosted', interval: 'month', src: 'app-gate-main', return: 'app', scheme: APP_RETURN_SCHEME,+ utm_source: 'desktop', utm_medium: 'gate', utm_content: 'switch',+ })+ const pack = params(checkoutStartUrl({ order: 'pack', src: 'gpu8', medium: 'create-sheet', base: BASE }))+ expect(pack).toEqual({+ pack: 'pack-15', src: 'gpu8', return: 'app', scheme: 'locallyuncensored', utm_source: 'desktop', utm_medium: 'create-sheet',+ })+ })++ it('drops a source or a model that is not a plain word', () => {+ const p = params(checkoutStartUrl({ order: 'sub', src: 'Bad Source!', medium: 'gate', model: 'x y', base: BASE }))+ expect(p.src).toBeUndefined()+ expect(p.model).toBeUndefined()+ expect(params(checkoutStartUrl({ order: 'sub', src: 'app-gate', medium: 'gate-models', model: 'direct/v-1.2', category: 'chat', base: BASE })).model)+ .toBe('direct/v-1.2')+ })++ it('carries nothing about the user', () => {+ const keys = Object.keys(params(checkoutStartUrl({ order: 'sub', src: 'app-gate', medium: 'gate-models', model: 'm', category: 'code', opener: 'cloud-offer', base: BASE })))+ expect(keys.sort()).toEqual(['category', 'interval', 'model', 'plan', 'return', 'scheme', 'src', 'utm_content', 'utm_medium', 'utm_source'])+ })+})++/** No link in the desktop code opens lu-labs.ai without the place it came+ * from. Only `openExternal(` calls with the cloud address are read; fetches+ * to the API are no visits. The phone has its own links. */+describe('the desktop opens lu-labs.ai only through cloudLink', () => {+ const root = resolve(__dirname, '..', '..')+ const files: string[] = []+ const walk = (dir: string) => {+ for (const e of readdirSync(dir)) {+ const p = join(dir, e)+ if (statSync(p).isDirectory()) {+ if (e === '__tests__' || e === 'mobile') continue+ walk(p)+ } else if (/\.tsx?$/.test(e)) files.push(p)+ }+ }+ walk(root)++ it('has no bare CLOUD_BASE or PRICING_URL inside openExternal', () => {+ const bare = files.flatMap((f) => {+ const src = readFileSync(f, 'utf8')+ return [...src.matchAll(/openExternal\(([^)\n]*)\)/g)]+ .map((m) => m[1])+ .filter((arg) => /CLOUD_BASE|PRICING_URL|lu-labs\.ai/.test(arg))+ // The gate's model checkout builds its link in lib/cloud-links too.+ .filter((arg) => !/^(gateCheckoutUrl|cloudLink|checkoutStartUrl)\(/.test(arg))+ .map((arg) => `${f.slice(root.length)}: ${arg}`)+ })+ expect(bare).toEqual([])+ })+})diff --git a/src/lib/cloud-gate.ts b/src/lib/cloud-gate.tsindex b74bced6..6b6c3bf4 100644--- a/src/lib/cloud-gate.ts+++ b/src/lib/cloud-gate.ts@@ -17,6 +17,7 @@*/import seed from './cloud-gate-seed.json'import { VRAM_WORKING_GB } from './vram-fit'+import { CHECKOUT_PACK, CHECKOUT_PLAN, checkoutStartUrl, type CloudGateOpener } from './cloud-links'export type GateCategory = 'chat' | 'code' | 'create'export type GateCreateKind = 'image' | 'video' | 'edit'@@ -123,20 +124,22 @@ export type GateWay = 'sub' | 'credits'/** The one button of each way. The plan is the first plan, monthly; the pack* the smallest one. */-export const GATE_DEFAULT_PLAN = { tier: 'hosted', interval: 'month' } as const-export const GATE_DEFAULT_PACK = 'pack-15'+export const GATE_DEFAULT_PLAN = CHECKOUT_PLAN+export const GATE_DEFAULT_PACK = CHECKOUT_PACK/** The checkout in the browser. Signed out, the page signs in first and comes- * back on its own. */-export function gateCheckoutUrl(base: string, way: GateWay, model: string, category: GateCategory): string {- const q = new URLSearchParams(way === 'sub'- ? { plan: GATE_DEFAULT_PLAN.tier, interval: GATE_DEFAULT_PLAN.interval }- : { pack: GATE_DEFAULT_PACK })- q.set('src', 'app-gate')- if (MODEL_ID.test(model)) q.set('model', model)- q.set('category', category)- q.set('return', 'app')- return `${base}/checkout/start?${q.toString()}`+ * back on its own. Built by lib/cloud-links, which adds where the click came+ * from (utm_medium=gate-models) and the app's own scheme for the way back. */+export function gateCheckoutUrl(base: string, way: GateWay, model: string, category: GateCategory, opener?: CloudGateOpener): string {+ return checkoutStartUrl({+ order: way === 'sub' ? 'sub' : 'pack',+ src: 'app-gate',+ medium: 'gate-models',+ opener,+ model,+ category,+ base,+ })}const count = (n: number) => n.toLocaleString('en-US')@@ -156,6 +159,14 @@ export function gateOfferLine(way: GateWay, offerList: GateCatalog['offers']): sreturn k ? `€${count(k.eur)} once, about ${count(k.images)} images or ${count(k.clips)} clips` : null}+/** The price of the pack the buttons sell, from the catalogue's offers. Null+ * without an answer from the server: the app then names no pack price, as+ * lib/cloud-pitch keeps no pack sizes (decision of 13.09.2026). */+export function gatePackEur(offerList: GateCatalog['offers']): number | null {+ const k = offerList?.packs.find((o) => o.id === GATE_DEFAULT_PACK)+ return k ? k.eur : null+}+/*** The parameter count a chat model's id names, in billions: "Qwen3-235B-A22B"* is 235, "gemma-4-31b-it" is 31. The first count is the total, the "A22B" ofdiff --git a/src/lib/cloud-links.ts b/src/lib/cloud-links.tsnew file mode 100644index 00000000..c802a779--- /dev/null+++ b/src/lib/cloud-links.ts@@ -0,0 +1,94 @@+/**+ * Every link from the desktop app to lu-labs.ai, with where it came from+ * (funnel 13.11.2026, Nr. 3).+ *+ * Until 3.1.0 no link out of the app said where it was clicked: a purchase+ * that started on the gate's main button landed without any source, and the+ * report could not tell the app from a Google visitor. Each link now carries+ * `utm_source=desktop` and `utm_medium=<the place>`, so the web side can file+ * the visit and the account under the place in the app (account_sources). The+ * short `src` word the checkout already reads stays where it was.+ *+ * Nothing about the user goes into a link: the source, the place in the app+ * and, for the checkout, the order and the gate model. No identifier.+ *+ * Pure: no store, no network.+ */+import { CLOUD_BASE } from '../api/cloud/config'++/** The places in the app a link to lu-labs.ai can start from. */+export type CloudLinkMedium =+ | 'gate'+ | 'gate-models'+ | 'gate-plans'+ | 'create-sheet'+ | 'onboarding'+ | 'account'+ | 'settings'+ | 'credits-meter'+ | 'credits-empty'++/** Where the gate was opened from. Goes with a gate link as utm_content, so+ * "the gate brought it" can be split by the way into the gate. */+export type CloudGateOpener =+ | 'switch'+ | 'model-picker'+ | 'cloud-offer'+ | 'release-notes'+ | 'checkout-return'++export const UTM_SOURCE = 'desktop'++/** The scheme the desktop app answers (src-tauri/src/hf_link.rs). Sent with a+ * checkout so the page after the payment can offer the way back into the+ * app. A page that does not know the parameter ignores it. */+export const APP_RETURN_SCHEME = 'locallyuncensored'++/** `path` on lu-labs.ai with the source of the click. A hash stays at the end. */+export function cloudLink(path: string, medium: CloudLinkMedium, opener?: CloudGateOpener, base: string = CLOUD_BASE): string {+ const url = new URL(path.startsWith('/') ? path : `/${path}`, 'https://lu.invalid')+ url.searchParams.set('utm_source', UTM_SOURCE)+ url.searchParams.set('utm_medium', medium)+ if (opener) url.searchParams.set('utm_content', opener)+ return `${base}${url.pathname}${url.search}${url.hash}`+}++/** The two ways in, side by side everywhere the app sells (Nr. 4). */+export type CheckoutOrder = 'sub' | 'pack'++/** The first plan, monthly, and the smallest pack: what the two buttons buy. */+export const CHECKOUT_PLAN = { tier: 'hosted', interval: 'month' } as const+export const CHECKOUT_PACK = 'pack-15'++const MODEL_ID = /^[A-Za-z0-9._:/-]{1,80}$/+const SOURCE = /^[a-z0-9_-]{1,32}$/++export interface CheckoutLinkOptions {+ order: CheckoutOrder+ /** The short source word the checkout counts (`app-gate`, `gpu8`). */+ src: string+ medium: CloudLinkMedium+ opener?: CloudGateOpener+ /** The gate model the app lands on after the purchase. */+ model?: string+ category?: 'chat' | 'code' | 'create'+ base?: string+}++/**+ * The checkout start on lu-labs.ai, never the payment page itself: the page there shows+ * the order and the alternative before anybody pays, and signs in first when+ * nobody is. `return=app` asks every way back from the payment to offer the+ * app, `scheme` says which link opens it.+ */+export function checkoutStartUrl(o: CheckoutLinkOptions): string {+ const q = new URLSearchParams(o.order === 'sub'+ ? { plan: CHECKOUT_PLAN.tier, interval: CHECKOUT_PLAN.interval }+ : { pack: CHECKOUT_PACK })+ if (SOURCE.test(o.src)) q.set('src', o.src)+ if (o.model && MODEL_ID.test(o.model)) q.set('model', o.model)+ if (o.category) q.set('category', o.category)+ q.set('return', 'app')+ q.set('scheme', APP_RETURN_SCHEME)+ return cloudLink(`/checkout/start?${q.toString()}`, o.medium, o.opener, o.base)+}diff --git a/src/lib/credits-exhausted.ts b/src/lib/credits-exhausted.tsindex 7ec66cbd..2f77d86c 100644--- a/src/lib/credits-exhausted.ts+++ b/src/lib/credits-exhausted.ts@@ -6,6 +6,7 @@// new dependencies.import { CLOUD_BASE } from '../api/cloud/config'+import { cloudLink } from './cloud-links'export const CREDITS_EXHAUSTED_EVENT = 'lu:credits-exhausted'@@ -32,6 +33,11 @@ export type ExhaustedReason = 'credits' | 'video_budget' | 'trainings'*/export const PRICING_URL = `${CLOUD_BASE}/pricing`+/** The same page for the dialog's button, with where the click came from+ * (lib/cloud-links). The sentence in the transcript keeps the plain address:+ * it is read, not clicked, and a query string there is noise. */+export const PRICING_LINK = cloudLink('/pricing', 'credits-empty')+export function signalCreditsExhausted(reason: ExhaustedReason = 'credits'): void {if (typeof window !== 'undefined') {window.dispatchEvent(new CustomEvent(CREDITS_EXHAUSTED_EVENT, { detail: { reason } }))diff --git a/src/lib/hf-link.ts b/src/lib/hf-link.tsindex eaf9ef40..bf873033 100644--- a/src/lib/hf-link.ts+++ b/src/lib/hf-link.ts@@ -23,6 +23,10 @@ export interface HfModelLink {export type HfLinkInbound =| { kind: 'model'; link: HfModelLink }| { kind: 'rejected'; reason: string }+ /** The way back from a checkout on lu-labs.ai (3.1.0):+ * locallyuncensored://cloud/open?status=paid|cancelled. Says nothing about+ * the account; the gate's account check decides what is bought. */+ | { kind: 'cloudReturn'; status: 'paid' | 'cancelled' }/** Hugging Face's rule for an owner and for a repository name. */function validNamePart(s: string): boolean {@@ -59,6 +63,9 @@ export function readInbound(raw: unknown): HfLinkInbound | null {const reason = typeof r.reason === 'string' && r.reason.length <= 200 ? r.reason : REJECTED_FALLBACKreturn { kind: 'rejected', reason }}+ if (r.kind === 'cloudReturn') {+ return r.status === 'paid' || r.status === 'cancelled' ? { kind: 'cloudReturn', status: r.status } : null+ }if (r.kind !== 'model' || typeof r.repo !== 'string' || !isValidRepoId(r.repo)) return nullconst file = r.file == null ? null : r.fileif (file !== null && (typeof file !== 'string' || !isValidGgufPath(file))) return nulldiff --git a/src/stores/__tests__/releaseNotesStore.test.ts b/src/stores/__tests__/releaseNotesStore.test.tsindex f40e1dd6..c6d7076b 100644--- a/src/stores/__tests__/releaseNotesStore.test.ts+++ b/src/stores/__tests__/releaseNotesStore.test.ts@@ -687,7 +687,7 @@ describe('the notes table', () => {expect(modal.indexOf('release-cloud-block')).toBeLessThan(modal.indexOf('data-testid="release-intro"'))// Der Knopf faellt auf denselben Weg zurueck wie der Schalter im Kopf.- expect(modal).toContain('setCloudGateOpen(true)')+ expect(modal).toContain("setCloudGateOpen(true, 'release-notes')")expect(modal).toContain("updateSettings({ appMode: 'cloud' })")})diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.tsindex 89abaeff..1567226c 100644--- a/src/stores/uiStore.ts+++ b/src/stores/uiStore.ts@@ -3,6 +3,7 @@ import { persist } from 'zustand/middleware'import { safeJSONStorage } from '../lib/storage-quota'import type { SettingsTab } from '../lib/settings-reset'import { visibleView } from '../lib/features'+import type { CloudGateOpener } from '../lib/cloud-links'export type View = 'chat' | 'models' | 'settings' | 'create' | 'benchmark' | 'voice' | 'neuron'@@ -184,6 +185,13 @@ interface UIState {/** CloudGateModal (login, plan, beta gate), opened by the header's* Cloud switch when the cloud side isn't usable yet. */cloudGateOpen: boolean+ /** Where the gate was opened from (funnel 3.1.0): rides along on the+ * gate's links as utm_content. Never persisted. */+ cloudGateFrom: CloudGateOpener+ /** A checkout in the browser came back through the app's link with a+ * payment (locallyuncensored://cloud/open?status=paid). The gate then opens+ * on the sign in, not on the sales panel. Never persisted. */+ cloudGateReturn: 'paid' | 'cancelled' | null/** CloudTeaserModal, null = closed. */cloudTeaser: CloudTeaserTarget | null/** The Cloud sheet's link has just switched the Cloud features off. Create@@ -246,7 +254,8 @@ interface UIState {clearSettingsFocus: () => voidtoggleSidebar: () => voidsetSidebarOpen: (open: boolean) => void- setCloudGateOpen: (open: boolean) => void+ setCloudGateOpen: (open: boolean, from?: CloudGateOpener) => void+ setCloudGateReturn: (status: 'paid' | 'cancelled' | null) => voidsetCloudTeaser: (target: CloudTeaserTarget | null) => voidsetCloudHiddenNotice: (shown: boolean) => voidsetPendingCloudModel: (name: string | null) => void@@ -304,6 +313,8 @@ export const useUIStore = create<UIState>()(// scratch on every visit and the choice should survive a restart.sidebarOpen: false,cloudGateOpen: false,+ cloudGateFrom: 'switch',+ cloudGateReturn: null,cloudTeaser: null,cloudHiddenNotice: false,pendingCloudModel: null,@@ -342,7 +353,8 @@ export const useUIStore = create<UIState>()(clearSettingsFocus: () => set({ settingsFocus: null }),toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),setSidebarOpen: (open) => set({ sidebarOpen: open }),- setCloudGateOpen: (open) => set({ cloudGateOpen: open }),+ setCloudGateOpen: (open, from = 'switch') => set(open ? { cloudGateOpen: true, cloudGateFrom: from } : { cloudGateOpen: false }),+ setCloudGateReturn: (status) => set({ cloudGateReturn: status }),setCloudTeaser: (target) => set({ cloudTeaser: target }),setCloudHiddenNotice: (shown) => set({ cloudHiddenNotice: shown }),setPendingCloudModel: (name) => set({ pendingCloudModel: name }),