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): one stray click can no longer move the app into cloud and bill it

purplefb75252a5ba4
diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx
index cbf44a2c..085755c3 100644
--- a/src/components/chat/ChatInput.tsx
+++ b/src/components/chat/ChatInput.tsx
@@ -80,6 +80,9 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
const isTranscribing = useVoiceStore((s) => s.isTranscribing)
const thinkingEnabled = useSettingsStore((s) => s.settings.thinkingEnabled)
const updateSettings = useSettingsStore((s) => s.updateSettings)
+ // Cloud mode is a money state: the next Send is billed. It gets drawn here,
+ // where the user is typing, not only on the switch in the header corner.
+ const cloudMode = useSettingsStore((s) => s.settings.appMode) === 'cloud'
const activeModel = useModelStore((s) => s.activeModel)
const activeModelMeta = useModelStore((s) => s.models.find((m) => m.name === s.activeModel))
// Server-declared capability (LU Cloud carries thinkMode from /models) wins
@@ -252,10 +255,18 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
they belong to. ChatView owns the Enter/Esc keyboard layer. */}
<div
+ // Cloud mode is drawn on the box the user is about to type into, not
+ // only on a switch in the far corner of the header (Nebenbefund 4, R5
+ // re-measure 2026-08-30: a single stray click moved the app to Cloud
+ // and the next question was billed, with nothing in the writing area
+ // saying anything had changed).
+ data-cloud={cloudMode ? 'on' : undefined}
className={`relative flex flex-col rounded-lg border transition-colors ${
isDragOver
? 'bg-blue-500/5 border-blue-500/30'
- : 'bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.06] focus-within:border-gray-400 dark:focus-within:border-white/15'
+ : cloudMode
+ ? 'bg-[#7c3aed]/[0.04] border-[#7c3aed]/40 focus-within:border-[#7c3aed]/70'
+ : 'bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.06] focus-within:border-gray-400 dark:focus-within:border-white/15'
}`}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
@@ -445,6 +456,28 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
{/* View-specific actions (Docs · Plugins · Tools) */}
<div className="flex flex-nowrap items-center gap-1 shrink-0">{composerActions}</div>
+ {/* Cloud is a money state and it is said here, in words, on the row
+ the user looks at while typing. The tinted box around this row
+ carries the same message; a colour alone is not a statement
+ (Nebenbefund 4, R5 re-measure 2026-08-30). */}
+ {cloudMode && (
+ <span
+ data-testid="composer-cloud-state"
+ title="Cloud mode: this message runs on LU's hosted GPUs and is billed to your lu-labs.ai credits. The Cloud switch up in the header turns it off."
+ className="flex items-center gap-1 px-1.5 py-1.5 rounded-md shrink-0 text-[0.6rem] font-medium bg-[#7c3aed]/15 text-[#7c3aed] dark:text-[#a78bfa] border border-[#7c3aed]/30"
+ >
+ <img
+ src="/LU-monogram-bw.png"
+ alt=""
+ width={10}
+ height={10}
+ draggable={false}
+ className="shrink-0 select-none dark:invert-0 invert"
+ />
+ <span>Cloud</span>
+ </span>
+ )}
+
<div className="flex-1 min-w-0" />
{/* Model picker, opens upward from the composer */}
diff --git a/src/components/cloud/CloudSwitch.tsx b/src/components/cloud/CloudSwitch.tsx
index 67d4e7e3..476072ee 100644
--- a/src/components/cloud/CloudSwitch.tsx
+++ b/src/components/cloud/CloudSwitch.tsx
@@ -7,9 +7,11 @@
// shows the one-time cloud onboarding instead of switching silently. Flipping
// OFF always works.
+import { useEffect, useState } from 'react'
import { useSettingsStore } from '../../stores/settingsStore'
import { useUIStore } from '../../stores/uiStore'
import { useCloudAuthStore, deriveCloudAvailable } from '../../stores/cloudAuthStore'
+import { cloudSwitchClick, CLOUD_ARM_TIMEOUT_MS } from '../../lib/cloud-switch-guard'
import { cn } from '../create/ui/cn'
export function CloudSwitch() {
@@ -18,18 +20,42 @@ export function CloudSwitch() {
const setCloudGateOpen = useUIStore((s) => s.setCloudGateOpen)
const available = useCloudAuthStore(deriveCloudAvailable)
const on = appMode === 'cloud'
+ // First of the two clicks it takes to go INTO cloud. A stray click in this
+ // corner of the header used to move the whole app to Cloud, pick a hosted
+ // model silently, and bill the next question (Nebenbefund 4, R5 re-measure
+ // 2026-08-30). See lib/cloud-switch-guard for why it is two clicks on this
+ // one control and not a dialog.
+ const [armed, setArmed] = useState(false)
+
+ // An armed switch goes back to sleep on its own, so it is never lying in
+ // wait minutes later for a click that means something else entirely.
+ useEffect(() => {
+ if (!armed) return
+ const t = setTimeout(() => setArmed(false), CLOUD_ARM_TIMEOUT_MS)
+ return () => clearTimeout(t)
+ }, [armed])
+
+ // A mode change made anywhere else settles the switch too.
+ useEffect(() => { if (on) setArmed(false) }, [on])
const toggle = () => {
- if (on) {
- updateSettings({ appMode: 'local' })
- return
+ switch (cloudSwitchClick({ on, available, armed })) {
+ case 'leave-cloud':
+ setArmed(false)
+ updateSettings({ appMode: 'local' })
+ return
+ case 'open-gate':
+ setCloudGateOpen(true)
+ return
+ case 'arm':
+ setArmed(true)
+ return
+ case 'enter-cloud':
+ setArmed(false)
+ // The cloud onboarding modal was dropped in 2.5.9, the switch flips.
+ updateSettings({ appMode: 'cloud' })
+ return
}
- if (!available) {
- setCloudGateOpen(true)
- return
- }
- // The cloud onboarding modal was dropped in 2.5.9 — the switch just flips.
- updateSettings({ appMode: 'cloud' })
}
return (
@@ -37,15 +63,21 @@ export function CloudSwitch() {
role="switch"
aria-checked={on}
aria-label="Cloud"
+ data-armed={armed ? 'true' : undefined}
title={on
? "Cloud mode is on. Chat, image and video run on LU's hosted GPUs. Click to go back to Local."
- : "Run LU on hosted GPUs with your lu-labs.ai account"}
+ : armed
+ ? 'Click again to move the whole app to Cloud. Answers are then billed to your lu-labs.ai credits.'
+ : "Run LU on hosted GPUs with your lu-labs.ai account"}
onClick={toggle}
+ onBlur={() => setArmed(false)}
className={cn(
'flex items-center gap-1.5 pl-2 pr-1.5 py-[3px] rounded-full border transition-colors',
on
? 'border-[#7c3aed] bg-[#7c3aed]/10 text-[#7c3aed] dark:text-[#a78bfa]'
- : 'border-gray-200 dark:border-white/10 text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 hover:border-gray-300 dark:hover:border-white/20',
+ : armed
+ ? 'border-[#7c3aed] bg-[#7c3aed]/10 text-[#7c3aed] dark:text-[#a78bfa] ring-1 ring-[#7c3aed]/40'
+ : 'border-gray-200 dark:border-white/10 text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 hover:border-gray-300 dark:hover:border-white/20',
)}
>
<img
@@ -56,12 +88,16 @@ export function CloudSwitch() {
draggable={false}
className="shrink-0 select-none dark:invert-0 invert"
/>
- <span className="text-[0.65rem] font-medium leading-none">Cloud</span>
+ {/* The armed switch says what the next click will do, in the place the
+ finger already is. */}
+ <span className="text-[0.65rem] font-medium leading-none">
+ {armed ? 'Switch to Cloud?' : 'Cloud'}
+ </span>
<span
aria-hidden
className={cn(
'relative w-[22px] h-[12px] rounded-full transition-colors shrink-0',
- on ? 'bg-[#7c3aed]' : 'bg-gray-300 dark:bg-white/15',
+ on ? 'bg-[#7c3aed]' : armed ? 'bg-[#7c3aed]/50' : 'bg-gray-300 dark:bg-white/15',
)}
>
<span
diff --git a/src/lib/__tests__/cloud-switch-guard.test.ts b/src/lib/__tests__/cloud-switch-guard.test.ts
new file mode 100644
index 00000000..65b4a0b0
--- /dev/null
+++ b/src/lib/__tests__/cloud-switch-guard.test.ts
@@ -0,0 +1,115 @@
+/**
+ * Nebenbefund 4 of the R5 re-measure on the 2.6.7 Windows build
+ * (2026-08-30, ergebnis-r5-nachmessung.md), the one that costs money:
+ *
+ * "Der Cloud-Schalter liegt als Stolperstein neben dem Modellwaehler. Ein
+ * einzelner Fehlklick in der Kopfzeile schaltete die App von Local auf
+ * Cloud, waehlte still ein Cloud-Modell und schickte die naechste Frage an
+ * die Cloud. Rueckweg ohne Rueckfrage, die vorherige lokale Modellwahl kam
+ * von selbst zurueck. Kostenrelevant, weil eine versehentlich gesendete
+ * Frage abgerechnet wird."
+ *
+ * It was found by making the mistake, not by looking for it. The whole chain
+ * ran on one click: mode flipped, pickForMode silently put a hosted model in
+ * the place of the local one, and the next Send went to lu-labs.ai and was
+ * billed. Nothing in the writing area said any of it had happened.
+ *
+ * Two answers, both small. Going INTO cloud takes two clicks on the same spot;
+ * going out stays one. And cloud mode is drawn on the composer, in words, on
+ * the row the user looks at while typing.
+ *
+ * Run: npx vitest run src/lib/__tests__/cloud-switch-guard.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+import { cloudSwitchClick, CLOUD_ARM_TIMEOUT_MS } from '../cloud-switch-guard'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const src = (p: string) => readFileSync(resolve(here, '../..', p), 'utf8')
+
+describe('one stray click cannot move the app into cloud', () => {
+ it('THE FIX: the exact frame of the re-measure, a single click arms and changes nothing', () => {
+ // Local, a usable cloud account, one click. Before this it was already in
+ // cloud and the next question was billed.
+ expect(cloudSwitchClick({ on: false, available: true, armed: false })).toBe('arm')
+ })
+
+ it('THE FIX: the second click on the same spot is the deliberate one', () => {
+ expect(cloudSwitchClick({ on: false, available: true, armed: true })).toBe('enter-cloud')
+ })
+
+ it('THE FIX: an armed switch disarms itself, it does not lie in wait', () => {
+ // Long enough to read four words and move a finger, short enough that a
+ // click a minute later never means something it was not meant to mean.
+ expect(CLOUD_ARM_TIMEOUT_MS).toBeGreaterThan(1500)
+ expect(CLOUD_ARM_TIMEOUT_MS).toBeLessThanOrEqual(10_000)
+ })
+
+ it('NEGATIVE CONTROL: leaving cloud stays one click, always', () => {
+ // A guard on the way out would only make it harder to stop spending
+ // money, which is backwards. Armed or not, on means out.
+ expect(cloudSwitchClick({ on: true, available: true, armed: false })).toBe('leave-cloud')
+ expect(cloudSwitchClick({ on: true, available: true, armed: true })).toBe('leave-cloud')
+ expect(cloudSwitchClick({ on: true, available: false, armed: false })).toBe('leave-cloud')
+ })
+
+ it('NEGATIVE CONTROL: an account without cloud keeps the gate it always had', () => {
+ // A slip there has never cost anything, and the gate modal is itself a
+ // confirmation. The deliberate path for that user is unchanged.
+ expect(cloudSwitchClick({ on: false, available: false, armed: false })).toBe('open-gate')
+ expect(cloudSwitchClick({ on: false, available: false, armed: true })).toBe('open-gate')
+ })
+
+ it('NEGATIVE CONTROL: the deliberate switch is two clicks on one control, no dialog', () => {
+ const sw = src('components/cloud/CloudSwitch.tsx')
+ expect(sw).toMatch(/cloudSwitchClick\(\{ on, available, armed \}\)/)
+ // No browser dialog, and no modal of ours either: the only modal this file
+ // may reach for is the pre-existing gate for an account that cannot use
+ // cloud at all, which is a different branch and was never the problem.
+ expect(sw).not.toMatch(/window\.confirm|[^a-zA-Z]confirm\(/)
+ const arm = sw.slice(sw.indexOf("case 'arm':"), sw.indexOf("case 'enter-cloud':"))
+ // The first click changes nothing but the switch's own label. No settings
+ // write, no modal, no model swap.
+ expect(arm).toMatch(/setArmed\(true\)/)
+ expect(arm).not.toMatch(/updateSettings|setCloudGateOpen/)
+ })
+})
+
+describe('the switch says what the next click will do', () => {
+ it('THE FIX: an armed switch is labelled, not just tinted', () => {
+ const sw = src('components/cloud/CloudSwitch.tsx')
+ expect(sw).toMatch(/armed \? 'Switch to Cloud\?' : 'Cloud'/)
+ })
+
+ it('THE FIX: the arming is dropped when the switch loses focus', () => {
+ expect(src('components/cloud/CloudSwitch.tsx')).toMatch(/onBlur=\{\(\) => setArmed\(false\)\}/)
+ })
+
+ it('THE FIX: the arming times out on its own', () => {
+ const sw = src('components/cloud/CloudSwitch.tsx')
+ expect(sw).toMatch(/setTimeout\(\(\) => setArmed\(false\), CLOUD_ARM_TIMEOUT_MS\)/)
+ })
+})
+
+describe('cloud mode is visible where the money is spent', () => {
+ it('THE FIX: the composer box itself changes state, not only a switch in the corner', () => {
+ const input = src('components/chat/ChatInput.tsx')
+ expect(input).toMatch(/const cloudMode = useSettingsStore\(\(s\) => s\.settings\.appMode\) === 'cloud'/)
+ expect(input).toMatch(/data-cloud=\{cloudMode \? 'on' : undefined\}/)
+ })
+
+ it('THE FIX: it says so in words, because a colour alone is not a statement', () => {
+ const input = src('components/chat/ChatInput.tsx')
+ expect(input).toMatch(/data-testid="composer-cloud-state"/)
+ // And the label names the cost, not just the mode.
+ expect(input).toMatch(/billed to your lu-labs\.ai credits/)
+ })
+
+ it('NEGATIVE CONTROL: local mode draws none of it', () => {
+ const input = src('components/chat/ChatInput.tsx')
+ // The marker is behind the mode check, so a local session is untouched.
+ expect(input).toMatch(/\{cloudMode && \(/)
+ })
+})
diff --git a/src/lib/cloud-switch-guard.ts b/src/lib/cloud-switch-guard.ts
new file mode 100644
index 00000000..1bf165b7
--- /dev/null
+++ b/src/lib/cloud-switch-guard.ts
@@ -0,0 +1,60 @@
+/**
+ * What one click on the Cloud switch is allowed to do.
+ *
+ * Nebenbefund 4 of the R5 re-measure on the 2.6.7 Windows build (2026-08-30).
+ * A single stray click in the header moved the app from Local to Cloud, a
+ * cloud model was picked silently in its place, and the next question went to
+ * lu-labs.ai and was billed. The way back was one click and the previous local
+ * pick came back by itself, so the slip cost nothing but the question, and a
+ * question is exactly the thing that costs money here. It was found by making
+ * the mistake, not by looking for it.
+ *
+ * The guard is the smallest one that can work: going INTO cloud takes two
+ * clicks on the same spot, going OUT stays one.
+ *
+ * Two clicks on the same control, with no dialog, no mouse travel and no
+ * modal, is the cheapest confirmation there is. It costs the deliberate
+ * switcher one extra click in the place his finger already is. It costs a slip
+ * nothing at all: the armed state says what it is about to do and disarms
+ * itself after a few seconds.
+ *
+ * The account that cannot use cloud is untouched. Its first click already
+ * opens the gate modal, which is a confirmation of its own, and a slip there
+ * has never cost anything.
+ */
+
+export type CloudSwitchAction =
+ /** Cloud is on. One click goes back to Local, always, no confirmation. */
+ | 'leave-cloud'
+ /** No usable cloud account. Opens the gate, exactly as before. */
+ | 'open-gate'
+ /** First click of two. Nothing changes yet, the switch says what it will do. */
+ | 'arm'
+ /** Second click, deliberate. Now the app moves to Cloud. */
+ | 'enter-cloud'
+
+export interface CloudSwitchState {
+ /** Is the app in cloud mode right now. */
+ on: boolean
+ /** Is the cloud axis usable (signed in, licensed, budget). */
+ available: boolean
+ /** Did a first click already arm this switch. */
+ armed: boolean
+}
+
+/**
+ * How long an armed switch waits for the second click.
+ *
+ * Long enough to move a finger and read four words, short enough that an armed
+ * switch is never lying in wait minutes later for a click that means something
+ * else entirely.
+ */
+export const CLOUD_ARM_TIMEOUT_MS = 4000
+
+export function cloudSwitchClick(state: CloudSwitchState): CloudSwitchAction {
+ // Leaving cloud is free and always was. A guard on the way out would only
+ // make it harder to stop spending money, which is backwards.
+ if (state.on) return 'leave-cloud'
+ if (!state.available) return 'open-gate'
+ return state.armed ? 'enter-cloud' : 'arm'
+}