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
fix(cloud): der Zwei-Klick-Schalter bekommt sechs statt vier Sekunden
purple88277270a90d
diff --git a/src/components/cloud/CloudSwitch.tsx b/src/components/cloud/CloudSwitch.tsxindex 476072ee..a43f9dc2 100644--- a/src/components/cloud/CloudSwitch.tsx+++ b/src/components/cloud/CloudSwitch.tsx@@ -89,8 +89,16 @@ export function CloudSwitch() {className="shrink-0 select-none dark:invert-0 invert"/>{/* 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">+ finger already is. No transition on this text on purpose: the label+ has to change on the same frame as the click, or the first click+ looks like it did nothing at all (Nebenbefund 2, R10 re-measure).+ The testid is so a prober can read the state without guessing at+ class names, the way aria-checked reads the mode. */}+ <span+ data-testid="cloud-switch-label"+ data-state={armed ? 'armed' : on ? 'on' : 'off'}+ className="text-[0.65rem] font-medium leading-none"+ >{armed ? 'Switch to Cloud?' : 'Cloud'}</span><spandiff --git a/src/lib/__tests__/cloud-switch-arm-window.test.ts b/src/lib/__tests__/cloud-switch-arm-window.test.tsnew file mode 100644index 00000000..d15322d1--- /dev/null+++ b/src/lib/__tests__/cloud-switch-arm-window.test.ts@@ -0,0 +1,156 @@+/**+ * Nebenbefund 2 of the R10 re-measure on the real 2.6.7 Windows build+ * (2026-08-30): "the Cloud switch in the header switches OFF reliably, but+ * practically never ON. 8 clean single clicks at a spacing of 4 seconds, all+ * with real mouse events over CDP, all without effect, aria-checked stays+ * false. Over the whole session about 20 attempts from Local to Cloud, 2 of+ * them successful. Every single click from Cloud to Local worked at once."+ *+ * It reads like a broken control and it is not one. 4 seconds is+ * CLOUD_ARM_TIMEOUT_MS to the millisecond, the window the R5 fix put in front+ * of cloud mode so a single stray click could not move the app there and bill+ * the next question. A click at t=0 arms, the timer disarms at t=4000, the+ * next click lands at t=4000 plus the round trip and arms again. Eight clicks,+ * eight armings, no entry, and it would have gone on forever.+ *+ * The report names its own two exceptions and both land inside the window:+ * one space bar, and one second click 1.6 s after the first. The asymmetry it+ * reports is the guard's whole design: leaving cloud is one click, always.+ *+ * So the mechanism is understood and there is no defect to fix. What is worth+ * changing is the number. A human who reads four words, looks at the switch+ * and then decides is easily slower than four seconds, and anybody that slow+ * has the same experience the measurement had: nothing ever happens. Six is+ * the mild version, still nowhere near lying in wait.+ *+ * This file is the arithmetic, written down, so the next person who measures a+ * rhythm against this window can read why the rhythm mattered.+ *+ * Run: npx vitest run src/lib/__tests__/cloud-switch-arm-window.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 repo = resolve(here, '../../..')+const read = (rel: string) => readFileSync(resolve(repo, rel), 'utf8')++/**+ * The switch as the component runs it: a click arms, the arming expires+ * strictly AFTER the window (the timer fires at the window, and a click at the+ * same instant is a click that arrives later than the timer did).+ */+function clickRun(gapsMs: number[], window = CLOUD_ARM_TIMEOUT_MS) {+ let armed = false+ let on = false+ const actions: string[] = []+ let sinceArm = 0+ for (const gap of gapsMs) {+ if (armed) {+ sinceArm += gap+ if (sinceArm >= window) armed = false+ }+ const action = cloudSwitchClick({ on, available: true, armed })+ actions.push(action)+ if (action === 'arm') { armed = true; sinceArm = 0 }+ if (action === 'enter-cloud') { armed = false; on = true }+ if (action === 'leave-cloud') { armed = false; on = false }+ }+ return { actions, on }+}++describe('THE FINDING: the measured rhythm and the window were the same number', () => {+ it('the exact frame: 8 clicks at 4 s never enter cloud, on the old 4 s window', () => {+ const run = clickRun([0, 4000, 4000, 4000, 4000, 4000, 4000, 4000], 4000)+ expect(run.on).toBe(false)+ expect(new Set(run.actions)).toEqual(new Set(['arm']))+ expect(run.actions.length).toBe(8)+ })++ it('and the two that got through were the two that were faster', () => {+ // The report's own exceptions: a second click 1.6 s after the first.+ const run = clickRun([0, 1600], 4000)+ expect(run.actions).toEqual(['arm', 'enter-cloud'])+ expect(run.on).toBe(true)+ })++ it('THE CHANGE: a 4 s rhythm now has room instead of landing on the edge', () => {+ const run = clickRun([0, 4000])+ expect(run.actions).toEqual(['arm', 'enter-cloud'])+ expect(run.on).toBe(true)+ })++ it('the window is six seconds, mild and deliberate', () => {+ expect(CLOUD_ARM_TIMEOUT_MS).toBe(6000)+ })+})++describe('NEGATIVE CONTROL: the R5 guard is untouched, only the number moved', () => {+ it('one stray click still cannot move the app into cloud', () => {+ // The whole point of the guard: a single click on a fresh switch arms and+ // changes nothing. This is the money frame of Nebenbefund 4 of R5.+ expect(cloudSwitchClick({ on: false, available: true, armed: false })).toBe('arm')+ expect(clickRun([0]).on).toBe(false)+ })++ it('the arming still expires on its own, it does not lie in wait', () => {+ const run = clickRun([0, 60_000])+ expect(run.actions).toEqual(['arm', 'arm'])+ expect(run.on).toBe(false)+ // Bracketed, so the next mild adjustment cannot quietly become a minute.+ expect(CLOUD_ARM_TIMEOUT_MS).toBeGreaterThan(1500)+ expect(CLOUD_ARM_TIMEOUT_MS).toBeLessThanOrEqual(10_000)+ })++ it('leaving cloud is still one click, at any spacing', () => {+ // The asymmetry the re-measure reported is the design: a guard on the way+ // out would only make it harder to stop spending money.+ let on = true+ for (const armed of [false, true]) {+ expect(cloudSwitchClick({ on, available: true, armed })).toBe('leave-cloud')+ }+ on = false+ expect(on).toBe(false)+ })++ it('an account without cloud still meets the gate on the first click', () => {+ expect(cloudSwitchClick({ on: false, available: false, armed: false })).toBe('open-gate')+ })+})++describe('the arming has to be visible the moment it happens', () => {+ const sw = read('src/components/cloud/CloudSwitch.tsx')++ it('the label changes with the state, on the same render as the click', () => {+ expect(sw).toMatch(/armed \? 'Switch to Cloud\?' : 'Cloud'/)+ // No transition on the text: a faded-in label is a label that was not+ // there when the user looked.+ const label = sw.slice(sw.indexOf('data-testid="cloud-switch-label"'), sw.indexOf("{armed ? 'Switch to Cloud?'"))+ expect(label).not.toMatch(/transition/)+ })++ it('the state is readable without guessing at class names', () => {+ // aria-checked answers the MODE, and correctly stays false while armed,+ // which is exactly what made the re-measure read "nothing happened".+ expect(sw).toMatch(/data-testid="cloud-switch-label"/)+ expect(sw).toMatch(/data-state=\{armed \? 'armed' : on \? 'on' : 'off'\}/)+ expect(sw).toMatch(/data-armed=\{armed \? 'true' : undefined\}/)+ })++ it('NEGATIVE CONTROL: the selector the re-measure used still works', () => {+ // aria-label stays "Cloud" and aria-checked stays the mode. Moving either+ // would break every probe written against this control so far.+ expect(sw).toMatch(/aria-label="Cloud"/)+ expect(sw).toMatch(/aria-checked=\{on\}/)+ })++ it('NEGATIVE CONTROL: the first click still writes nothing but the arming', () => {+ const arm = sw.slice(sw.indexOf("case 'arm':"), sw.indexOf("case 'enter-cloud':"))+ expect(arm).toMatch(/setArmed\(true\)/)+ expect(arm).not.toMatch(/updateSettings|setCloudGateOpen/)+ })+})diff --git a/src/lib/cloud-switch-guard.ts b/src/lib/cloud-switch-guard.tsindex 1bf165b7..994c88ed 100644--- a/src/lib/cloud-switch-guard.ts+++ b/src/lib/cloud-switch-guard.ts@@ -48,8 +48,27 @@ export interface CloudSwitchState {* 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.+ *+ * Was 4000. Nebenbefund 2 of the R10 re-measure (2026-08-30) read as a defect+ * and is not one: "the Cloud switch only ever switches OFF, about 2 of 20+ * attempts got INTO cloud". The measurement was 8 clean single clicks at a+ * spacing of 4 seconds, which is this constant exactly. A click at t=0 arms,+ * the timer disarms at t=4000, and the next click lands at t=4000 plus the+ * round trip, so it arms again instead of entering. Eight clicks, eight+ * armings, no entry, systematically. The report names its own two exceptions+ * and both fit: one space bar, and one second click 1.6 s after the first.+ * Leaving cloud is one click and worked every single time, which is the other+ * half of the picture.+ *+ * So the guard did what it was built to do and the reading was wrong. It is+ * still a poor number to have picked, because a human who reads four words,+ * looks at the switch and then decides is easily slower than four seconds, and+ * anybody who is that slow experiences the same thing the measurement did:+ * nothing happens, ever. Six seconds is the mild version. It stays far inside+ * the window the test brackets, it is still nowhere near lying in wait, and it+ * gives a rhythm of four seconds room instead of landing on it.*/-export const CLOUD_ARM_TIMEOUT_MS = 4000+export const CLOUD_ARM_TIMEOUT_MS = 6000export function cloudSwitchClick(state: CloudSwitchState): CloudSwitchAction {// Leaving cloud is free and always was. A guard on the way out would only