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(picker): die geklickte Cloud-Zeile ist das Modell, das danach dasteht
purpleeec00600d9f7
diff --git a/src/components/cloud/CloudGateModal.tsx b/src/components/cloud/CloudGateModal.tsxindex 832d94cb..9cb26e7d 100644--- a/src/components/cloud/CloudGateModal.tsx+++ b/src/components/cloud/CloudGateModal.tsx@@ -122,9 +122,19 @@ export function CloudGateModal() {}}, [open, available, setOpen, updateSettings])+ // Backing out of the gate drops the model the user named on the way in+ // (clicking an LU Cloud row in the local picker). It described that one+ // click, so it must not be lying in wait for the next flip, which could+ // happen minutes later and mean something else.+ const setPendingCloudModel = useUIStore((s) => s.setPendingCloudModel)+ const close = () => {+ setPendingCloudModel(null)+ setOpen(false)+ }+const stayLocal = () => {updateSettings({ appMode: 'local' })- setOpen(false)+ close()}// Re-probe on open — someone staring at this gate shouldn't wait for the@@ -143,7 +153,7 @@ export function CloudGateModal() {const signedOut = status === 'signed-out' || !userreturn (- <Modal open={open} onClose={() => setOpen(false)} title="LU Cloud" hideHeader>+ <Modal open={open} onClose={close} title="LU Cloud" hideHeader>{signedOut ? (step === 'intro' ? (<div className="space-y-5 pt-2">diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsxindex 43526be6..683b9abc 100644--- a/src/components/layout/AppShell.tsx+++ b/src/components/layout/AppShell.tsx@@ -124,8 +124,17 @@ export function AppShell() {// out-of-mode model active when the new mode has nothing to offer: a// lu-cloud model left active in Local mode kept billing credits after the// switch said Local (Discord 2026-08-09, helpslowlydying).- const pick = pickForMode(activeModel, allModels, appMode)+ //+ // The fourth argument is the model the user NAMED on the way in, by+ // clicking its row in the local-mode LU Cloud strip. Without it every one+ // of those rows merely opened the gate and the fallback below decided+ // which hosted model came out, which is why clicking DeepSeek V3.2 landed+ // on Kimi K3 (Nebenbefund 1, R10 re-measure 2026-08-30). The request is+ // dropped the moment it is answered, so it never steers a later flip.+ const { pendingCloudModel, setPendingCloudModel } = useUIStore.getState()+ const pick = pickForMode(activeModel, allModels, appMode, pendingCloudModel)if (pick.change) setActiveModel(pick.next)+ if (pick.usedRequest) setPendingCloudModel(null)}, [appMode, allModels])// Local-hardware views (Models/Benchmark) don't exist in cloud mode — thediff --git a/src/components/models/ModelBenchmark.tsx b/src/components/models/ModelBenchmark.tsxindex accf70b5..14f4b6dc 100644--- a/src/components/models/ModelBenchmark.tsx+++ b/src/components/models/ModelBenchmark.tsx@@ -63,7 +63,13 @@ export function BenchmarkLeaderboard() {</h3><div className="space-y-1.5">{leaderboard.map((entry, i) => {- const maxTps = leaderboard[0].avgTps+ // Same class as the picker bug of R10: a position in a list that is+ // ordered by something else. getLeaderboard sorts by score+ // (avgTps × accuracy), so row 1 is not the fastest row, and+ // `leaderboard[0].avgTps` as the scale drew bars past 100% for every+ // model that was faster but less accurate than the leader. The+ // longest bar is asked for by value now, not by position.+ const maxTps = Math.max(...leaderboard.map((e) => e.avgTps))const barWidth = maxTps > 0 ? (entry.avgTps / maxTps) * 100 : 0return (diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 687b429b..01da369f 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -30,6 +30,7 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {const appMode = useSettingsStore((s) => s.settings.appMode)const teasersEnabled = useSettingsStore((s) => s.settings.cloudTeasersEnabled)const setCloudGateOpen = useUIStore((s) => s.setCloudGateOpen)+ const setPendingCloudModel = useUIStore((s) => s.setPendingCloudModel)const allModels = useModelStore((s) => s.models)if (appMode === 'cloud' || !teasersEnabled) return null// The five used to be the head of the list as `/v1/models` happened to send@@ -40,7 +41,20 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {allModels.filter((m) => m.provider === 'lu-cloud' && m.type === 'text'),(m) => (('displayName' in m && m.displayName) || displayModelName(m.name)) as string,)- const open = () => { onOpen(); setCloudGateOpen(true) }+ // Every row used to call this with nothing, so the row you pressed and the+ // model you got afterwards were unrelated: the gate flipped the mode and the+ // mode rule then handed out the head of the catalogue, in whatever order the+ // last `/v1/models` answer had arrived in (Nebenbefund 1, R10 re-measure+ // 2026-08-30, DeepSeek V3.2 landed on Kimi K3). A model row now names its+ // model, by name and never by its position in any list, and the mode rule+ // honours that name when the flip lands. The rows that stand for the+ // catalogue as a whole, the rest-counter and the logged-out line, still ask+ // for nothing in particular.+ const open = (model?: string) => {+ setPendingCloudModel(model ?? null)+ onOpen()+ setCloudGateOpen(true)+ }return (<div className="mt-1 border-t border-white/[0.05]"><div className="px-2.5 pt-2 pb-0.5 flex items-center gap-1">@@ -52,7 +66,7 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {{cloudChat.map((m) => (<buttonkey={m.name}- onClick={open}+ onClick={() => open(m.name)}className="w-full flex items-center gap-2 px-2.5 py-1.5 text-left hover:bg-white/[0.04] transition-colors"title="Runs on LU Cloud, tap to see plans">@@ -65,7 +79,7 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {))}{cloudChat.length > 0 && cloudMore > 0 && (<button- onClick={open}+ onClick={() => open()}className="w-full flex items-center gap-2 px-2.5 py-1.5 text-left hover:bg-white/[0.04] transition-colors"title="See the whole hosted catalogue">@@ -76,7 +90,7 @@ function CloudTeaserSection({ onOpen }: { onOpen: () => void }) {)}{cloudChat.length === 0 && (<button- onClick={open}+ onClick={() => open()}className="w-full flex items-center gap-2 px-2.5 py-1.5 text-left hover:bg-white/[0.04] transition-colors"title="Runs on LU Cloud, tap to see plans">diff --git a/src/components/onboarding/BackendSelector.tsx b/src/components/onboarding/BackendSelector.tsxindex 95f8e0c8..39b2ad8a 100644--- a/src/components/onboarding/BackendSelector.tsx+++ b/src/components/onboarding/BackendSelector.tsx@@ -8,7 +8,7 @@* from Settings → Providers going forward.*/-import { useState } from 'react'+import { useEffect, useState } from 'react'import { Modal } from '../ui/Modal'import { useProviderStore } from '../../stores/providerStore'import { useUIStore } from '../../stores/uiStore'@@ -23,6 +23,17 @@ interface Props {export function BackendSelector({ open, backends, onClose }: Props) {const [selected, setSelected] = useState<string>(backends[0]?.id || '')+ // AppShell mounts this with an EMPTY `backends` array and fills it seconds+ // later, once the idle-time detection has run. A useState initialiser runs+ // once, so the default above read `[]` and `selected` stayed the empty+ // string for good: the dialog opened with no row marked, and "Use selected"+ // found nothing under that name, dismissed itself and configured nothing.+ // Same class as the picker bug of R10, a position taken from a list before+ // the list exists. Re-seed it the moment a list arrives, and never overwrite+ // a choice the user has already made.+ useEffect(() => {+ setSelected((cur) => (backends.some((b) => b.id === cur) ? cur : backends[0]?.id || ''))+ }, [backends])// Pre-checked: the common case is "saw it once, don't bug me again". User can// uncheck if they want it to re-appear on next launch.const [dontShowAgain, setDontShowAgain] = useState(true)diff --git a/src/lib/__tests__/cloud-teaser-click-identity.test.ts b/src/lib/__tests__/cloud-teaser-click-identity.test.tsnew file mode 100644index 00000000..1de97493--- /dev/null+++ b/src/lib/__tests__/cloud-teaser-click-identity.test.ts@@ -0,0 +1,227 @@+/**+ * Nebenbefund 1 of the R10 re-measure on the real 2.6.7 Windows build+ * (2026-08-30, ergebnis-r10-nachmessung.md).+ *+ * The measured frame, twice, with the chip read before and after each click:+ *+ * | clicked | active afterwards |+ * | DeepSeek V3.2 | Kimi K3 |+ * | DeepSeek R1 | DeepSeek V4 Flash 0731 |+ *+ * Neither the clicked model nor the same wrong model twice, so a fixed default+ * was ruled out on the spot. The cause was smaller than a wrong default and+ * worse: the rows carried no identity at all. Every row in the LU Cloud strip+ * called the same argument-less `open()`, which opened the cloud gate and+ * nothing else. The gate flipped appMode, and `pickForMode` then did what it+ * does when the active model is out of mode: it handed out `models.find(...)`,+ * the FIRST hosted model in the store, in whatever order the last `/v1/models`+ * answer happened to arrive in. That order is the same unstable order e7b2b440+ * had just sorted out of the DISPLAY, which is why the strip looked stable+ * while the click behind it landed somewhere else.+ *+ * The fix is identity, not a position: the row names its model, the name+ * travels as `pendingCloudModel`, and the mode rule honours that name when the+ * flip lands. The rows that stand for the catalogue as a whole (the rest+ * counter, the logged-out line) name nothing and keep the old fallback.+ *+ * Run: npx vitest run src/lib/__tests__/cloud-teaser-click-identity.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 { pickForMode } from '../active-model-mode'+import { cloudTeaserModels } from '../cloud-teaser-models'++const here = dirname(fileURLToPath(import.meta.url))+const repo = resolve(here, '../../..')+const read = (rel: string) => readFileSync(resolve(repo, rel), 'utf8')++/**+ * The hosted catalogue as `/v1/models` handed it over in the re-measure: not+ * alphabetical, not ranked, just arrival order. Kimi K3 and DeepSeek V4 Flash+ * 0731 are near the head, which is exactly why they are what the two clicks+ * came back with.+ */+const HOSTED = [+ { name: 'kimi-k3', displayName: 'Kimi K3', provider: 'lu-cloud', type: 'text' },+ { name: 'deepseek-v4-flash-0731', displayName: 'DeepSeek V4 Flash 0731', provider: 'lu-cloud', type: 'text' },+ { name: 'deepseek-r1', displayName: 'DeepSeek R1', provider: 'lu-cloud', type: 'text' },+ { name: 'deepseek-v3.2', displayName: 'DeepSeek V3.2', provider: 'lu-cloud', type: 'text' },+ { name: 'deepseek-v3.1', displayName: 'DeepSeek V3.1', provider: 'lu-cloud', type: 'text' },+ { name: 'deepseek-v4-pro-0813', displayName: 'DeepSeek V4 Pro 0813', provider: 'lu-cloud', type: 'text' },+ { name: 'glm-5', displayName: 'GLM 5', provider: 'lu-cloud', type: 'text' },+]++/** The same catalogue, arriving in a different order, which is the whole+ * reason the wrong model was a different wrong model on the second click. */+const HOSTED_REORDERED = [...HOSTED].reverse()++/** What the local machine has on it in the measured session. */+const LOCAL = { name: 'Hermes-3-Llama-3.2-3B.Q4_K_M', provider: 'openai', type: 'text' }++describe('THE FIX: the clicked LU Cloud row is the model that comes out', () => {+ it('the exact frame of the re-measure: DeepSeek V3.2 lands on DeepSeek V3.2', () => {+ const pick = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud', 'deepseek-v3.2')+ expect(pick.next).toBe('deepseek-v3.2')+ expect(pick.change).toBe(true)+ expect(pick.usedRequest).toBe(true)+ })++ it('the second frame: DeepSeek R1 lands on DeepSeek R1', () => {+ const pick = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud', 'deepseek-r1')+ expect(pick.next).toBe('deepseek-r1')+ expect(pick.usedRequest).toBe(true)+ })++ it('and it does not depend on the order the catalogue arrived in', () => {+ // This is the half that makes the bug what it was: the same click on the+ // same label used to give two different answers on two different loads.+ for (const catalogue of [HOSTED, HOSTED_REORDERED]) {+ expect(pickForMode(LOCAL.name, [LOCAL, ...catalogue], 'cloud', 'deepseek-v3.2').next)+ .toBe('deepseek-v3.2')+ }+ })++ it('every row the strip shows can be clicked and gets itself back', () => {+ // Walks the actual five rows the strip draws, through the same rule the+ // component uses, so a row is never a label without a working click.+ const { shown } = cloudTeaserModels(+ HOSTED.filter((m) => m.provider === 'lu-cloud' && m.type === 'text'),+ (m) => m.displayName,+ )+ expect(shown.length).toBe(5)+ for (const row of shown) {+ expect(pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud', row.name).next).toBe(row.name)+ }+ })++ it('the request is answered once, so it cannot steer a later flip', () => {+ const first = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud', 'deepseek-v3.2')+ expect(first.usedRequest).toBe(true)+ // The caller drops it here. A second flip with no request behaves exactly+ // as it did before the fix.+ const second = pickForMode('deepseek-v3.2', [LOCAL, ...HOSTED], 'cloud', null)+ expect(second.change).toBe(false)+ expect(second.usedRequest).toBe(false)+ })+})++describe('NEGATIVE CONTROL: the rule without a request is untouched', () => {+ it('no request, an out-of-mode pick: the old fallback, unchanged', () => {+ const pick = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud')+ expect(pick.next).toBe('kimi-k3')+ expect(pick.change).toBe(true)+ expect(pick.usedRequest).toBe(false)+ })++ it('an empty list is still not evidence that a model is gone', () => {+ // Befund 3 of the abnahme counter-check, the guard that keeps a persisted+ // pick alive across a restart. A request must not punch through it.+ const pick = pickForMode(LOCAL.name, [], 'cloud', 'deepseek-v3.2')+ expect(pick.change).toBe(false)+ expect(pick.next).toBe(LOCAL.name)+ expect(pick.usedRequest).toBe(false)+ })++ it('a request for a model that is not in the list falls back as before', () => {+ const pick = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'cloud', 'a-model-that-left')+ expect(pick.next).toBe('kimi-k3')+ expect(pick.usedRequest).toBe(false)+ })++ it('a hosted request cannot pull a hosted model into LOCAL mode', () => {+ // The rule that stopped a lu-cloud model from billing credits under a+ // switch that said Local (Discord 2026-08-09) still wins.+ const pick = pickForMode(LOCAL.name, [LOCAL, ...HOSTED], 'local', 'deepseek-v3.2')+ expect(pick.next).toBe(LOCAL.name)+ expect(pick.usedRequest).toBe(false)+ })++ it('a request never overrides an in-mode pick the user is already on', () => {+ const pick = pickForMode('deepseek-r1', [LOCAL, ...HOSTED], 'cloud', 'deepseek-r1')+ expect(pick.change).toBe(false)+ expect(pick.next).toBe('deepseek-r1')+ })++ it('an image checkpoint stays out, request or no request', () => {+ const checkpoint = { name: 'flux.safetensors', provider: 'lu-cloud', type: 'image' }+ const pick = pickForMode(null, [checkpoint], 'cloud', 'flux.safetensors')+ expect(pick.next).toBe(null)+ expect(pick.usedRequest).toBe(false)+ })+})++describe('the wiring, so the rule reaches the screen', () => {+ const picker = read('src/components/models/ModelSelector.tsx')+ const shell = read('src/components/layout/AppShell.tsx')+ const gate = read('src/components/cloud/CloudGateModal.tsx')++ it('a model row names its model, and it names it by name', () => {+ expect(picker).toMatch(/onClick=\{\(\) => open\(m\.name\)\}/)+ // The bug in one line: this is what the row used to be.+ expect(picker).not.toMatch(/key=\{m\.name\}\s*\n\s*onClick=\{open\}/)+ })++ it('the row hands the name to the store, it does not select behind the gate', () => {+ expect(picker).toMatch(/setPendingCloudModel\(model \?\? null\)/)+ })++ it('the rows that stand for the whole catalogue name nothing', () => {+ // Two of them: the rest counter and the logged-out line. Passing `open`+ // straight to onClick would hand them a MouseEvent as the model name.+ expect((picker.match(/onClick=\{\(\) => open\(\)\}/g) ?? []).length).toBe(2)+ expect(picker).not.toMatch(/onClick=\{open\}/)+ })++ it('the mode rule is asked with the request, and drops it once answered', () => {+ expect(shell).toMatch(/pickForMode\(activeModel, allModels, appMode, pendingCloudModel\)/)+ expect(shell).toMatch(/if \(pick\.usedRequest\) setPendingCloudModel\(null\)/)+ })++ it('backing out of the gate drops the request', () => {+ expect(gate).toMatch(/setPendingCloudModel\(null\)/)+ expect(gate).toMatch(/<Modal open=\{open\} onClose=\{close\}/)+ })++ it('NEGATIVE CONTROL: the request is never persisted', () => {+ // It describes one click. A persisted one would flip a model on the next+ // start of the app, which is a different bug in the same family.+ const ui = read('src/stores/uiStore.ts')+ const partialize = ui.slice(ui.indexOf('partialize:'), ui.indexOf('partialize:') + 300)+ expect(partialize).not.toMatch(/pendingCloudModel/)+ })+})++describe('the same mistake, swept for elsewhere', () => {+ it('the benchmark bar scales by the longest bar, not by row one', () => {+ // getLeaderboard sorts by score (avgTps × accuracy), so row one is not the+ // fastest row and `leaderboard[0].avgTps` drew bars past 100%.+ const bench = read('src/components/models/ModelBenchmark.tsx')+ expect(bench).toMatch(/Math\.max\(\.\.\.leaderboard\.map\(\(e\) => e\.avgTps\)\)/)+ expect(bench).not.toMatch(/const maxTps = leaderboard\[0\]\.avgTps/)+ })++ it('NEGATIVE CONTROL: the other leaderboard, which was always right, is untouched', () => {+ // BenchmarkView draws the bar from the key it sorted by, and says so.+ const view = read('src/components/models/BenchmarkView.tsx')+ expect(view).toMatch(/const topScore = leaderboard\[0\]\.score/)+ })++ it('the backend dialog re-seeds its choice when the detected list arrives', () => {+ // AppShell mounts it with an empty array and fills it seconds later, so+ // the useState default read `[]` and "Use selected" found nothing.+ const sel = read('src/components/onboarding/BackendSelector.tsx')+ expect(sel).toMatch(/backends\.some\(\(b\) => b\.id === cur\) \? cur : backends\[0\]\?\.id/)+ expect(sel).toMatch(/\}, \[backends\]\)/)+ })++ it('NEGATIVE CONTROL: it still confirms by id, and a made choice survives', () => {+ const sel = read('src/components/onboarding/BackendSelector.tsx')+ expect(sel).toMatch(/backends\.find\(b => b\.id === selected\)/)+ // The re-seed keeps `cur` whenever the list still holds it, so a user who+ // picked before the list settled is not overruled.+ expect(sel).toMatch(/setSelected\(\(cur\) =>/)+ })+})diff --git a/src/lib/__tests__/model-pick-survives-restart.test.ts b/src/lib/__tests__/model-pick-survives-restart.test.tsindex 83677177..e79f7373 100644--- a/src/lib/__tests__/model-pick-survives-restart.test.ts+++ b/src/lib/__tests__/model-pick-survives-restart.test.ts@@ -42,45 +42,45 @@ const LOCAL_LIST = [describe('the picked model survives a restart', () => {it('THE FIX: the mount-time run against an empty list changes nothing', () => {// This is the exact moment the pick used to die.- expect(pickForMode(QWEN, [], 'local')).toEqual({ change: false, next: QWEN })+ expect(pickForMode(QWEN, [], 'local')).toMatchObject({ change: false, next: QWEN })})it('the list lands a moment later and the pick is still the pick', () => {- expect(pickForMode(QWEN, LOCAL_LIST, 'local')).toEqual({ change: false, next: QWEN })+ expect(pickForMode(QWEN, LOCAL_LIST, 'local')).toMatchObject({ change: false, next: QWEN })})it('NEGATIVE CONTROL: a model that really is gone still hands over to the first one', () => {// The dead-name guard is the reason this rule exists. A picker showing a// model the provider no longer has opens an empty list on click.expect(pickForMode('openai::deleted-model', LOCAL_LIST, 'local'))- .toEqual({ change: true, next: HERMES })+ .toMatchObject({ change: true, next: HERMES })})it('NEGATIVE CONTROL: flipping to Cloud still moves off a local model', () => {const withCloud = [...LOCAL_LIST, { name: 'lu-cloud::glm-5.3', type: 'text', provider: 'lu-cloud' }]- expect(pickForMode(QWEN, withCloud, 'cloud')).toEqual({ change: true, next: 'lu-cloud::glm-5.3' })+ expect(pickForMode(QWEN, withCloud, 'cloud')).toMatchObject({ change: true, next: 'lu-cloud::glm-5.3' })})it('NEGATIVE CONTROL: Local mode with nothing but cloud models clears the pick', () => {// A lu-cloud model left active in Local mode kept spending credits after// the switch said Local. That must still clear, not linger.const cloudOnly = [{ name: 'lu-cloud::glm-5.3', type: 'text', provider: 'lu-cloud' }]- expect(pickForMode('lu-cloud::glm-5.3', cloudOnly, 'local')).toEqual({ change: true, next: null })+ expect(pickForMode('lu-cloud::glm-5.3', cloudOnly, 'local')).toMatchObject({ change: true, next: null })})it('NEGATIVE CONTROL: a ComfyUI checkpoint never becomes the active chat model', () => {// It shares this list and carries no provider, so a bare provider check// would pin it. It routes to Ollama and every send fails.const mediaOnly = [{ name: 'sd_turbo.safetensors', type: 'image' }]- expect(pickForMode(null, mediaOnly, 'local')).toEqual({ change: false, next: null })- expect(pickForMode(QWEN, mediaOnly, 'local')).toEqual({ change: true, next: null })+ expect(pickForMode(null, mediaOnly, 'local')).toMatchObject({ change: false, next: null })+ expect(pickForMode(QWEN, mediaOnly, 'local')).toMatchObject({ change: true, next: null })})it('an empty list does not clear an already empty selection either', () => {- expect(pickForMode(null, [], 'local')).toEqual({ change: false, next: null })+ expect(pickForMode(null, [], 'local')).toMatchObject({ change: false, next: null })})it('a first launch with models and no pick takes the first in-mode one', () => {- expect(pickForMode(null, LOCAL_LIST, 'local')).toEqual({ change: true, next: HERMES })+ expect(pickForMode(null, LOCAL_LIST, 'local')).toMatchObject({ change: true, next: HERMES })})})diff --git a/src/lib/active-model-mode.ts b/src/lib/active-model-mode.tsindex b47ab3ce..bd64f03f 100644--- a/src/lib/active-model-mode.ts+++ b/src/lib/active-model-mode.ts@@ -27,6 +27,10 @@ export interface ModePick {* lu-cloud model left active in Local mode kept spending credits after the* switch said Local (Discord 2026-08-09, helpslowlydying). */next: string | null+ /** True when `requested` is what landed, so the caller knows the request was+ * answered and can drop it. False whenever the request was absent, not in+ * the list yet, or not usable in this mode. */+ usedRequest: boolean}/** ComfyUI image/video checkpoints share the model list but are never a chat@@ -40,18 +44,39 @@ export function pickForMode(activeModel: string | null,models: ModeCandidate[],appMode: AppMode,+ /**+ * The model the user asked for by name on the way into this mode, e.g. the+ * LU Cloud row they clicked in the local-mode picker. Nebenbefund 1 of the+ * R10 re-measure (2026-08-30): clicking "DeepSeek V3.2" landed on Kimi K3,+ * clicking "DeepSeek R1" landed on DeepSeek V4 Flash 0731. The rows carried+ * no identity at all, so every one of them merely opened the cloud gate and+ * the line below then handed out `models.find(wanted)`, the head of the+ * catalogue in whatever order `/v1/models` had answered in. Two clicks, two+ * different wrong models, and neither of them a fixed default.+ *+ * A named request wins over that fallback, and over nothing else: it still+ * has to be in the list and still has to be usable in this mode.+ */+ requested: string | null = null,): ModePick {// Nothing to judge against. THE guard: without it, the mount-time run of// this rule wipes a perfectly good persisted pick.- if (models.length === 0) return { change: false, next: activeModel }+ if (models.length === 0) return { change: false, next: activeModel, usedRequest: false }const wanted = (m: ModeCandidate) =>chatCapable(m) && (appMode === 'cloud' ? m.provider === 'lu-cloud' : m.provider !== 'lu-cloud')+ // Identity, never a position: the row the user pressed is named, and the+ // name is what is looked up here.+ const asked = requested ? models.find((m) => m.name === requested) : undefined+ if (asked && wanted(asked)) {+ return { change: activeModel !== asked.name, next: asked.name, usedRequest: true }+ }+const current = activeModel ? models.find((m) => m.name === activeModel) : undefined- if (current && wanted(current)) return { change: false, next: activeModel }+ if (current && wanted(current)) return { change: false, next: activeModel, usedRequest: false }const fallback = models.find(wanted)- if (activeModel === null && !fallback) return { change: false, next: null }- return { change: true, next: fallback ? fallback.name : null }+ if (activeModel === null && !fallback) return { change: false, next: null, usedRequest: false }+ return { change: true, next: fallback ? fallback.name : null, usedRequest: false }}diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.tsindex 79db71ed..a598c8cb 100644--- a/src/stores/uiStore.ts+++ b/src/stores/uiStore.ts@@ -53,6 +53,11 @@ interface UIState {cloudGateOpen: boolean/** CloudTeaserModal, null = closed. */cloudTeaser: CloudTeaserTarget | null+ /** The hosted model the user named on the way into cloud mode, by clicking+ * its row in the local-mode picker. Read once by the mode rule when the+ * flip lands, then cleared. Never persisted: it describes one click, not a+ * preference. */+ pendingCloudModel: string | null/** Explorer panel width in px, persisted. */explorerWidth: number/** Explorer panel collapsed to its rail, persisted. */@@ -68,6 +73,7 @@ interface UIState {setSidebarOpen: (open: boolean) => voidsetCloudGateOpen: (open: boolean) => voidsetCloudTeaser: (target: CloudTeaserTarget | null) => void+ setPendingCloudModel: (name: string | null) => voidsetExplorerWidth: (width: number, viewportWidth: number) => voidsetExplorerCollapsed: (collapsed: boolean) => void}@@ -79,6 +85,7 @@ export const useUIStore = create<UIState>()(sidebarOpen: true,cloudGateOpen: false,cloudTeaser: null,+ pendingCloudModel: null,explorerWidth: EXPLORER_DEFAULT_WIDTH,explorerCollapsed: false,settingsFocus: null,@@ -97,6 +104,7 @@ export const useUIStore = create<UIState>()(setSidebarOpen: (open) => set({ sidebarOpen: open }),setCloudGateOpen: (open) => set({ cloudGateOpen: open }),setCloudTeaser: (target) => set({ cloudTeaser: target }),+ setPendingCloudModel: (name) => set({ pendingCloudModel: name }),setExplorerWidth: (width, viewportWidth) =>set({ explorerWidth: clampExplorerWidth(width, viewportWidth) }),setExplorerCollapsed: (collapsed) => set({ explorerCollapsed: collapsed }),