Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(cloud): the Cloud gate names a failed payment and leads to the invoice

purple387e1b52f5d4
diff --git a/src/components/cloud/CloudGateModal.tsx b/src/components/cloud/CloudGateModal.tsx
index dc8df472..ffe95082 100644
--- a/src/components/cloud/CloudGateModal.tsx
+++ b/src/components/cloud/CloudGateModal.tsx
@@ -11,7 +11,9 @@
//
// Der Zwischenschritt mit den drei Planknoepfen ist geloescht; sein Klick ging
// ohnehin auf dieselbe Preisseite. `PlanGrid` lebt weiter, denn ein
-// ANGEMELDETES Konto ohne Plan sieht die Plaene unveraendert.
+// ANGEMELDETES Konto ohne Plan sieht die Plaene unveraendert. Ausnahme seit
+// 3.0.5: ist die Verlaengerung geplatzt (`pastDue`), steht dort der Satz aus
+// `lib/past-due.ts` mit dem Weg zur offenen Rechnung, keine Planknoepfe.
//
// Jeder Zustand ohne Abo bietet weiter den Weg zurueck auf Local. Sobald
// deriveCloudAvailable durchgeht, kippt der Modus. Bezahlt wird auf
@@ -29,6 +31,8 @@ import { CLOUD_BASE } from '../../api/cloud/config'
import { openExternal } from '../../api/backend'
import { MONOGRAM, MONOGRAM_INVERT } from '../layout/brand'
import { CLOUD_PITCH, CLOUD_SUBSCRIBER_LINE, cloudSalesLines } from '../../lib/cloud-pitch'
+import { PAST_DUE_ACTION, pastDueLine } from '../../lib/past-due'
+import { Hinweis } from '../ui/Hinweis'
const PLANS = [
{ anchor: 'hosted', name: 'Hosted', price: '€19' },
@@ -71,6 +75,24 @@ function StayLocalButton({ onLocal }: { onLocal: () => void }) {
)
}
+/**
+ * A renewal payment failed and nothing else keeps the account running. The
+ * gate says that, in the account panel's own sentence, and leads to the open
+ * invoice. No plan buttons here: the server refuses a new plan (409) until the
+ * invoice is settled. Paying happens on lu-labs.ai, the app does not touch
+ * Stripe.
+ */
+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`)}>
+ <ExternalLink size={12} /> {PAST_DUE_ACTION}
+ </button>
+ </div>
+ )
+}
+
// Die drei Knopfformen des Tors. Standen bis 3.0.0 im Rumpf der Komponente und
// mussten hoch, als das Verkaufs-Panel eine eigene Komponente wurde: zwei
// Knopfstile nebeneinander waeren genau der Stilbruch, den der Auftrag
@@ -194,6 +216,8 @@ export function CloudGateModal() {
const licenseActive = useCloudAuthStore((s) => s.licenseActive)
const access = useCloudAuthStore((s) => s.access)
const quota = useCloudAuthStore((s) => s.quota)
+ const pastDue = useCloudAuthStore((s) => s.pastDue)
+ const pastDueTier = useCloudAuthStore((s) => s.pastDueTier)
const available = deriveCloudAvailable({ user, licenseActive, access, quota })
// Signed-out walkthrough position. Reset to the hero every time the gate
@@ -274,17 +298,30 @@ export function CloudGateModal() {
) : !licenseActive ? (
<div className="space-y-5 pt-2">
<CloudHero />
- <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.
- </p>
- <PlanGrid />
- <StayLocalButton onLocal={stayLocal} />
- <button className={ghostBtn} onClick={() => void refresh()}>
- <RefreshCw size={12} /> I subscribed, check again
- </button>
- </div>
+ {pastDue ? (
+ <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>.
+ </p>
+ <PastDueNotice tier={pastDueTier} />
+ <StayLocalButton onLocal={stayLocal} />
+ <button className={ghostBtn} onClick={() => void refresh()}>
+ <RefreshCw size={12} /> I paid, check again
+ </button>
+ </div>
+ ) : (
+ <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.
+ </p>
+ <PlanGrid />
+ <StayLocalButton onLocal={stayLocal} />
+ <button className={ghostBtn} onClick={() => void refresh()}>
+ <RefreshCw size={12} /> I subscribed, check again
+ </button>
+ </div>
+ )}
</div>
) : !access ? (
<div className="space-y-5 pt-2">
@@ -319,14 +356,23 @@ export function CloudGateModal() {
<div className="space-y-5 pt-2">
<CloudHero />
<div className="space-y-3 max-w-xs mx-auto">
- <p className="text-[0.72rem] text-center text-gray-600 dark:text-gray-400">
- Your plan is active, but it doesn't include a hosted compute credit
- budget, so there's nothing for Cloud mode to run on. Plans with
- cloud credits are on lu-labs.ai.
- </p>
- <button className={primaryBtn} onClick={() => void openExternal(`${CLOUD_BASE}/account`)}>
- <ExternalLink size={12} /> Open your account
- </button>
+ {/* An unpaid account whose pack credits are gone lands here too
+ (status active, tier starter, no budget). "Your plan is
+ active" would be as untrue as "no active plan". */}
+ {pastDue ? (
+ <PastDueNotice tier={pastDueTier} />
+ ) : (
+ <>
+ <p className="text-[0.72rem] text-center text-gray-600 dark:text-gray-400">
+ Your plan is active, but it doesn't include a hosted compute credit
+ budget, so there's nothing for Cloud mode to run on. Plans with
+ cloud credits are on lu-labs.ai.
+ </p>
+ <button className={primaryBtn} onClick={() => void openExternal(`${CLOUD_BASE}/account`)}>
+ <ExternalLink size={12} /> Open your account
+ </button>
+ </>
+ )}
<StayLocalButton onLocal={stayLocal} />
<button className={ghostBtn} onClick={() => void refresh()}>
<RefreshCw size={12} /> Check again
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.tsx
new file mode 100644
index 00000000..c66432cd
--- /dev/null
+++ b/src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsx
@@ -0,0 +1,127 @@
+// @vitest-environment jsdom
+/**
+ * The Cloud gate for an account whose renewal payment failed (license.pastDue
+ * in /api/me).
+ *
+ * The account panel has said "Payment failed" since d43134b5. The gate in front
+ * of the Cloud switch still told the same account "this account has no active
+ * plan yet" and showed the three plan buttons, although the server answers a
+ * new plan with 409 until the open invoice is paid. Both places now carry the
+ * same sentence and the same button.
+ *
+ * Run: npx vitest run src/components/cloud/__tests__/the-gate-names-a-failed-payment.test.tsx
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
+import type { CloudQuota } from '../../../lib/render/cloud-jobs'
+
+const refresh = vi.fn(async () => {})
+vi.mock('../../../hooks/useCloudAuth', () => ({
+ useCloudAuth: () => ({ status: 'signed-in', login: vi.fn(), signup: vi.fn(), logout: vi.fn(), refresh }),
+}))
+vi.mock('../../../api/cloud/supabase', () => ({ loginWithProvider: vi.fn() }))
+const openExternal = vi.fn(async () => {})
+vi.mock('../../../api/backend', () => ({ openExternal }))
+
+const { CloudGateModal } = await import('../CloudGateModal')
+const { useCloudAuthStore } = await import('../../../stores/cloudAuthStore')
+const { useUIStore } = await import('../../../stores/uiStore')
+const { useSettingsStore } = await import('../../../stores/settingsStore')
+const { PAST_DUE_ACTION, pastDueLine } = await import('../../../lib/past-due')
+
+const emptyWallet: CloudQuota = {
+ tier: 'starter',
+ period: '2026-10',
+ limits: { credits: 0 },
+ costs: { image: 10, video: 100 },
+ used: { credits_used: 0 },
+ remaining: { credits: 0 },
+}
+
+type Account = Parameters<ReturnType<typeof useCloudAuthStore.getState>['setSignedIn']>[1]
+
+async function openGate(account: Partial<Account>) {
+ useSettingsStore.getState().updateSettings({ appMode: 'local' })
+ useCloudAuthStore.getState().setSignedIn(
+ { id: 'u1', email: '[email protected]' },
+ { licenseActive: false, tier: null, access: true, quota: null, paidPlan: false, ...account },
+ )
+ useUIStore.getState().setCloudGateOpen(true)
+ await act(async () => {
+ render(<CloudGateModal />)
+ })
+}
+
+const planButtons = () => screen.queryAllByRole('button', { name: /€\d+/ })
+
+afterEach(() => {
+ cleanup()
+ openExternal.mockClear()
+ refresh.mockClear()
+ useUIStore.getState().setCloudGateOpen(false)
+ useCloudAuthStore.getState().setSignedOut()
+})
+
+describe('a failed renewal without credits', () => {
+ it('reads the account panel sentence and leads to the invoice, with no plan on offer', async () => {
+ await openGate({ pastDue: true, pastDueTier: 'hosted-pro' })
+
+ const notice = screen.getByTestId('cloud-gate-past-due')
+ expect(notice.textContent).toContain(pastDueLine('hosted-pro'))
+ expect(notice.textContent).toContain('your Hosted Pro plan')
+ expect(screen.queryByText(/no active plan/i)).toBeNull()
+ expect(screen.queryByText(/paid plans/i)).toBeNull()
+ expect(planButtons()).toHaveLength(0)
+ expect(screen.queryByText(/I subscribed/)).toBeNull()
+
+ fireEvent.click(screen.getByRole('button', { name: PAST_DUE_ACTION }))
+ expect(openExternal).toHaveBeenCalledTimes(1)
+ expect(openExternal).toHaveBeenCalledWith('https://lu-labs.ai/account')
+ // Nothing on this state opens the pricing page.
+ expect(openExternal.mock.calls.flat().some((u) => String(u).includes('/pricing'))).toBe(false)
+ })
+
+ it('keeps the way back to Local and the re-check, and stays in local mode', async () => {
+ await openGate({ pastDue: true, pastDueTier: null })
+
+ expect(screen.getByTestId('cloud-gate-past-due').textContent).toContain(pastDueLine(null))
+ refresh.mockClear()
+ fireEvent.click(screen.getByRole('button', { name: /I paid, check again/ }))
+ expect(refresh).toHaveBeenCalledTimes(1)
+ expect(useSettingsStore.getState().settings.appMode).toBe('local')
+
+ fireEvent.click(screen.getByRole('button', { name: /Stay on Local/ }))
+ expect(useUIStore.getState().cloudGateOpen).toBe(false)
+ expect(useSettingsStore.getState().settings.appMode).toBe('local')
+ })
+})
+
+describe('a failed renewal whose pack credits are used up', () => {
+ it('does not call the plan active', async () => {
+ await openGate({ licenseActive: true, tier: 'starter', quota: emptyWallet, pastDue: true, pastDueTier: 'hosted' })
+
+ expect(screen.getByTestId('cloud-gate-past-due').textContent).toContain(pastDueLine('hosted'))
+ expect(screen.queryByText(/Your plan is active/)).toBeNull()
+ expect(screen.getByRole('button', { name: PAST_DUE_ACTION })).toBeTruthy()
+ expect(screen.getByRole('button', { name: /Stay on Local/ })).toBeTruthy()
+ })
+})
+
+describe('no failed payment', () => {
+ it('an account without a plan sees the three plans as before', 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()
+ expect(screen.queryByTestId('cloud-gate-past-due')).toBeNull()
+ })
+
+ it('a plan without a credit budget reads as before', async () => {
+ await openGate({ licenseActive: true, tier: 'hosted', quota: { ...emptyWallet, tier: 'hosted' }, paidPlan: true })
+
+ expect(screen.getByText(/Your plan is active/)).toBeTruthy()
+ expect(screen.getByRole('button', { name: /Open your account/ })).toBeTruthy()
+ expect(screen.queryByTestId('cloud-gate-past-due')).toBeNull()
+ })
+})