Skip to content

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

feat(cloud): der Cloud-Umschalter zaehlt seine Klicks anonym

David3283404f9cb7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe1190b5..5d21ae73 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,12 @@ and the built-in engine has a name of its own, the LU Engine.
### Added
+- **The Cloud switch counts its presses anonymously.** Which way it was
+ pressed (gate, armed, into Cloud, back to Local), platform and app version
+ go into a daily count on lu-labs.ai, nothing else. It tells us whether
+ anyone finds the switch; local mode stays silent otherwise, and the privacy
+ text in Settings names the one call.
+
- **Compact mode.** Type /compact and the older turns of the conversation are
folded into a summary while the recent ones stay as they are; a few words
after the command say what the summary should focus on. The chat model
diff --git a/src-tauri/src/commands/funnel.rs b/src-tauri/src/commands/funnel.rs
new file mode 100644
index 00000000..c70433f5
--- /dev/null
+++ b/src-tauri/src/commands/funnel.rs
@@ -0,0 +1,131 @@
+//! One anonymous counter for the Cloud switch (David, 06.09.2026): how many
+//! presses open the gate, arm the switch, enter Cloud or go back to Local,
+//! per day, platform and app version. Nothing else leaves the machine: no
+//! identifier, no prompt, no IP kept (the table holds daily counts). The
+//! frontend can only pass an event name from the allowlist below; platform
+//! and version are read here, not trusted from the caller. The press that
+//! reaches for the cloud is the one thing local mode reports, and that is
+//! written into Settings and the privacy page.
+use tauri::AppHandle;
+
+use crate::os_error;
+
+/// The LU Labs project (lu-labs.ai). The anon key is the browser key of the
+/// web app, public by design; the counter table itself is service-role only,
+/// the app can only call the counting function.
+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). The SQL function carries the same list.
+pub(crate) const FUNNEL_EVENTS: &[&str] = &[
+ "cloud_switch_gate",
+ "cloud_switch_arm",
+ "cloud_switch_enter",
+ "cloud_switch_leave",
+];
+
+pub(crate) fn funnel_event_allowed(event: &str) -> bool {
+ FUNNEL_EVENTS.contains(&event)
+}
+
+pub(crate) fn platform_label(os: &str) -> &'static str {
+ match os {
+ "windows" => "windows",
+ "linux" => "linux",
+ "macos" => "macos",
+ _ => "unknown",
+ }
+}
+
+/// The RPC arguments of `funnel_count`, exactly three, nothing user-shaped.
+pub(crate) fn funnel_payload(event: &str, platform: &str, version: &str) -> serde_json::Value {
+ serde_json::json!({
+ "p_event": event,
+ "p_platform": platform,
+ "p_app_version": version,
+ })
+}
+
+/// Fire and forget. Never an error to the caller and never awaited by the
+/// switch: a counter that cannot be reached is a counter, not a feature.
+#[tauri::command]
+pub async fn funnel_ping(app: AppHandle, event: String) -> Result<(), String> {
+ if !funnel_event_allowed(&event) {
+ return Ok(());
+ }
+ let version = app.package_info().version.to_string();
+ let payload = funnel_payload(&event, platform_label(std::env::consts::OS), &version);
+ tauri::async_runtime::spawn(async move {
+ let client = match reqwest::Client::builder()
+ .user_agent(format!("LocallyUncensored/{version}"))
+ .timeout(std::time::Duration::from_secs(5))
+ .build()
+ {
+ Ok(c) => c,
+ Err(_) => return,
+ };
+ let url = format!("{LUC_SUPABASE_URL}/rest/v1/rpc/funnel_count");
+ match client
+ .post(&url)
+ .header("apikey", LUC_SUPABASE_ANON_KEY)
+ .header("Authorization", format!("Bearer {LUC_SUPABASE_ANON_KEY}"))
+ .header("Content-Type", "application/json")
+ .body(payload.to_string())
+ .send()
+ .await
+ {
+ Ok(r) if r.status().is_success() => {}
+ Ok(r) => println!("[Funnel] {event} answered HTTP {}", r.status().as_u16()),
+ Err(e) => println!("[Funnel] {event} not sent: {}", os_error::english(&e)),
+ }
+ });
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn only_the_four_presses_of_the_switch_count() {
+ for e in FUNNEL_EVENTS {
+ assert!(funnel_event_allowed(e), "{e}");
+ }
+ for e in ["", "cloud_switch_seen", "app_start", "cloud_switch_gate'; drop table x; --", "CLOUD_SWITCH_GATE"] {
+ assert!(!funnel_event_allowed(e), "{e:?} must not count");
+ }
+ }
+
+ #[test]
+ fn the_platform_is_one_of_four_words() {
+ assert_eq!(platform_label("windows"), "windows");
+ assert_eq!(platform_label("linux"), "linux");
+ assert_eq!(platform_label("macos"), "macos");
+ assert_eq!(platform_label("freebsd"), "unknown");
+ assert_eq!(platform_label(""), "unknown");
+ }
+
+ #[test]
+ fn the_payload_is_exactly_the_three_rpc_arguments() {
+ let p = funnel_payload("cloud_switch_enter", "windows", "2.6.8");
+ let obj = p.as_object().expect("object");
+ let mut keys: Vec<&String> = obj.keys().collect();
+ keys.sort();
+ assert_eq!(keys, ["p_app_version", "p_event", "p_platform"]);
+ assert_eq!(p["p_event"], "cloud_switch_enter");
+ assert_eq!(p["p_platform"], "windows");
+ assert_eq!(p["p_app_version"], "2.6.8");
+ }
+
+ #[test]
+ fn the_command_never_fails_the_switch_and_never_waits_on_the_network() {
+ let src = include_str!("funnel.rs");
+ let body = &src[src.find("pub async fn funnel_ping").expect("command")..];
+ let body = &body[..body.find("#[cfg(test)]").expect("end")];
+ assert!(!body.contains("return Err") && !body.contains("map_err") && !body.contains("?;"), "the switch must never hear an error from the counter");
+ assert_eq!(body.matches("Ok(())").count(), 2, "both ways out of the command are Ok");
+ assert!(body.contains("tauri::async_runtime::spawn"), "the request runs detached");
+ assert!(!body.contains("email") && !body.contains("user_id") && !body.contains("token"), "nothing user-shaped goes out");
+ }
+}
diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs
index a35dc3c4..ce1631fb 100644
--- a/src-tauri/src/commands/mod.rs
+++ b/src-tauri/src/commands/mod.rs
@@ -27,6 +27,7 @@ pub mod trainer;
pub mod tts;
pub mod video;
pub mod waitlist;
+pub mod funnel;
pub mod whisper;
// ── uselu-compat error helpers ────────────────────────────────────────
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 48f04b25..2dda8055 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -456,6 +456,8 @@ fn main() {
commands::proxy::cancel_model_pull,
// Cloud "Hosted LU Workflows" waitlist — opt-in email capture
commands::waitlist::waitlist_submit,
+ // The Cloud switch counts its presses anonymously (funnel.rs)
+ commands::funnel::funnel_ping,
// B7 (uselu Phase 4 inspiration) — one-shot diagnostic probe
commands::health::system_health,
// Audit #01 — the app log file: the frontend mirrors its warn /
diff --git a/src/api/__tests__/funnel.test.ts b/src/api/__tests__/funnel.test.ts
new file mode 100644
index 00000000..6a10b239
--- /dev/null
+++ b/src/api/__tests__/funnel.test.ts
@@ -0,0 +1,43 @@
+/**
+ * The Cloud switch counter (David, 2026-09-06). Pins the four-name mapping,
+ * that exactly one bridge call goes out per press with nothing but the
+ * event, and that a dead bridge never reaches the switch.
+ *
+ * Run: npx vitest run src/api/__tests__/funnel.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+const backendCall = vi.fn()
+vi.mock('../backend', () => ({
+ backendCall: (...a: unknown[]) => backendCall(...a),
+}))
+
+import { funnelEventFor, reportCloudSwitch } from '../funnel'
+
+beforeEach(() => {
+ backendCall.mockReset()
+ backendCall.mockResolvedValue(undefined)
+})
+
+describe('the Cloud switch counter', () => {
+ it('maps the four presses to the four event names and nothing else', () => {
+ expect(funnelEventFor('open-gate')).toBe('cloud_switch_gate')
+ expect(funnelEventFor('arm')).toBe('cloud_switch_arm')
+ expect(funnelEventFor('enter-cloud')).toBe('cloud_switch_enter')
+ expect(funnelEventFor('leave-cloud')).toBe('cloud_switch_leave')
+ })
+
+ it('sends one bridge call per press carrying only the event name', () => {
+ reportCloudSwitch('enter-cloud')
+ expect(backendCall).toHaveBeenCalledTimes(1)
+ expect(backendCall).toHaveBeenCalledWith('funnel_ping', { event: 'cloud_switch_enter' })
+ })
+
+ it('never lets a failing bridge reach the switch', async () => {
+ backendCall.mockRejectedValue(new Error('offline'))
+ expect(() => reportCloudSwitch('arm')).not.toThrow()
+ await new Promise((r) => setTimeout(r, 0))
+ backendCall.mockImplementation(() => { throw new Error('no tauri') })
+ expect(() => reportCloudSwitch('leave-cloud')).not.toThrow()
+ })
+})
diff --git a/src/api/funnel.ts b/src/api/funnel.ts
new file mode 100644
index 00000000..388d7c44
--- /dev/null
+++ b/src/api/funnel.ts
@@ -0,0 +1,36 @@
+/**
+ * One anonymous counter for the Cloud switch (David, 2026-09-06): how many
+ * presses open the gate, arm the switch, enter Cloud or go back to Local.
+ *
+ * The frontend hands the Rust side nothing but the event name; platform and
+ * app version are read there, and the four names are the whole allowlist on
+ * both sides (commands/funnel.rs, migration 0033_cloud_funnel). Fire and
+ * forget: the switch never waits on the counter and never hears from it, so a
+ * machine without a connection, a web build without Tauri, or a server that
+ * is down all cost the press nothing.
+ */
+import { backendCall } from './backend'
+import type { CloudSwitchAction } from '../lib/cloud-switch-guard'
+
+export type FunnelEvent =
+ | 'cloud_switch_gate'
+ | 'cloud_switch_arm'
+ | 'cloud_switch_enter'
+ | 'cloud_switch_leave'
+
+export function funnelEventFor(action: CloudSwitchAction): FunnelEvent {
+ switch (action) {
+ case 'open-gate': return 'cloud_switch_gate'
+ case 'arm': return 'cloud_switch_arm'
+ case 'enter-cloud': return 'cloud_switch_enter'
+ case 'leave-cloud': return 'cloud_switch_leave'
+ }
+}
+
+export function reportCloudSwitch(action: CloudSwitchAction): void {
+ try {
+ void backendCall('funnel_ping', { event: funnelEventFor(action) }).catch(() => {})
+ } catch {
+ /* no bridge (web build): the press is simply not counted */
+ }
+}
diff --git a/src/components/cloud/CloudSwitch.tsx b/src/components/cloud/CloudSwitch.tsx
index 981a45dd..4e64b855 100644
--- a/src/components/cloud/CloudSwitch.tsx
+++ b/src/components/cloud/CloudSwitch.tsx
@@ -12,6 +12,7 @@ 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 { reportCloudSwitch } from '../../api/funnel'
import { cn } from '../create/ui/cn'
import { MONOGRAM, MONOGRAM_INVERT } from '../layout/brand'
@@ -46,7 +47,11 @@ export function CloudSwitch() {
}, [armedRaw])
const toggle = () => {
- switch (cloudSwitchClick({ on, available, armed })) {
+ const action = cloudSwitchClick({ on, available, armed })
+ // Counted before it happens, anonymously (api/funnel): which way the
+ // press went is the whole message.
+ reportCloudSwitch(action)
+ switch (action) {
case 'leave-cloud':
setArmed(false)
updateSettings({ appMode: 'local' })
diff --git a/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts b/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts
new file mode 100644
index 00000000..f7e9d16a
--- /dev/null
+++ b/src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts
@@ -0,0 +1,48 @@
+/**
+ * The Cloud switch reports every press to the anonymous counter, and the
+ * allowlist is the same on both sides of the bridge. Source contract, the way
+ * the header and the trainer pin theirs.
+ *
+ * Run: npx vitest run src/components/cloud/__tests__/der-umschalter-zaehlt-anonym.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import fs from 'node:fs'
+import path from 'node:path'
+
+const root = path.join(__dirname, '..', '..', '..', '..')
+const read = (p: string) => fs.readFileSync(path.join(root, p), 'utf8')
+
+describe('the Cloud switch counts its presses', () => {
+ it('reports the outcome of a press before acting on it', () => {
+ const src = read('src/components/cloud/CloudSwitch.tsx')
+ expect(src).toContain("import { reportCloudSwitch } from '../../api/funnel'")
+ const report = src.indexOf('reportCloudSwitch(action)')
+ const act = src.indexOf('switch (action)')
+ expect(report).toBeGreaterThan(0)
+ expect(act).toBeGreaterThan(report)
+ })
+
+ it('names the same four 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_[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_[a-z]+)"/g)].map((m) => m[1])
+ const uniq = (a: string[]) => [...new Set(a)].sort()
+ expect(uniq(tsEvents)).toEqual(['cloud_switch_arm', 'cloud_switch_enter', 'cloud_switch_gate', 'cloud_switch_leave'])
+ expect(uniq(rsEvents)).toEqual(uniq(tsEvents))
+ })
+
+ it('sends nothing user-shaped', () => {
+ const ts = read('src/api/funnel.ts')
+ for (const word of ['email', 'userId', 'token', 'prompt', 'navigator']) {
+ expect(ts).not.toContain(word)
+ }
+ })
+
+ it('is written into Settings so the privacy text stays true', () => {
+ const settings = read('src/components/settings/SettingsPage.tsx')
+ expect(settings).toContain('Cloud switch')
+ expect(settings).toContain('anonymous')
+ })
+})
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index a1bd9504..720af9a6 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -1957,7 +1957,7 @@ export function SettingsPage() {
<Lock size={12} className="mt-0.5 shrink-0 text-emerald-500" />
<div>
<p className="text-gray-700 dark:text-gray-300 font-medium mb-0.5">100% local by default.</p>
- <p>Chat, agent runs, image &amp; video generation all execute on your machine. No telemetry, no analytics, no model pings home. The only network calls LU makes unless you explicitly opt in are: update checks against GitHub Releases, and cloud provider APIs (OpenAI, Anthropic, etc.) that you configure yourself with your own API keys.</p>
+ <p>Chat, agent runs, image &amp; video generation all execute on your machine. No telemetry, no analytics, no model pings home. The only network calls LU makes unless you explicitly opt in are: update checks against GitHub Releases, cloud provider APIs (OpenAI, Anthropic, etc.) that you configure yourself with your own API keys, and one anonymous daily count to lu-labs.ai when you press the Cloud switch (which way it was pressed, platform, app version, nothing else).</p>
</div>
</div>
<div className="flex items-start gap-2 pt-1.5">
diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.ts
index 4665c549..3205bfae 100644
--- a/src/lib/release-notes.ts
+++ b/src/lib/release-notes.ts
@@ -109,6 +109,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [
items: [
'A reasoning model gets an effort control beside its Think button. Low, Medium and High, with Max on GLM 5.3, set how many tokens a reply may spend on thinking. The steps come from the server for each model, so a model that offers only two shows two, and a model with none keeps the plain Think button it always had.',
'GLM 5.3 (Pro) and GLM 5.3 Flash (Hosted) are in the cloud catalogue.',
+ 'The Cloud switch counts its presses anonymously: which way it was pressed, platform and app version go into a daily count on lu-labs.ai, nothing else, so we learn whether anyone finds the switch. Local mode stays silent otherwise, and Settings says so.',
'The cloud model list keeps one fixed order. The upstream provider shuffles its own list on every call, measured three times and returned in three different orders, so a new chat opened on whatever happened to be first. The catalogue order decides now, and a new chat starts on the same model every time.',
'Document Chat works in Cloud mode. Your files are indexed on your own machine and only the passages that match your question travel with the prompt. If indexing runs on an Ollama you pointed at another machine, the panel says so.',
],