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(chat): sending without a model keeps the message and opens the model picker
purple505e73d202f9
diff --git a/e2e/send-without-a-model-keeps-the-message.spec.ts b/e2e/send-without-a-model-keeps-the-message.spec.tsnew file mode 100644index 00000000..2b1f87ff--- /dev/null+++ b/e2e/send-without-a-model-keeps-the-message.spec.ts@@ -0,0 +1,100 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY } from './support/tauri-mock'+import { seedOnboardingDone } from './support/cloud-mock'++/**+ * Sending without a chat model must not lose the message.+ *+ * Found in the real Windows build of 3.0.5: with no chat model picked (the+ * picker reads "Select Model") the Send button was live, and a click with+ * text, with or without attachments, emptied the field and the chips. No+ * conversation appeared and nothing was said: the message was gone.+ *+ * The mock installs one model that is too small for the automatic pick, so+ * the app starts with a model on disk and none chosen. Send has to leave the+ * text and the attachment where they are and open the model picker, which+ * says what is missing. Nothing may be written in or above the prompt field.+ *+ * Run: CI=1 npx playwright test e2e/send-without-a-model-keeps-the-message.spec.ts+ */++const SMALL_MODEL = 'Hermes-3-Llama-3.2-3B.Q4_K_M'+const TEXT = 'a message that must not get lost'+const NOTE = { name: 'notes.txt', mimeType: 'text/plain', buffer: Buffer.from('the attachment stays too') }+const HINT = 'Pick a model to send your message. Your text and attachments are kept.'++async function boot(page: Page) {+ await page.addInitScript(tauriMockInit, { assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: SMALL_MODEL })+ await seedOnboardingDone(page)+ await page.goto('/')+}++const picker = (page: Page) => page.getByRole('button', { name: 'Select chat model', exact: true })+const menu = (page: Page) => page.getByTestId('model-picker-menu')+const LANDING = 'Choose a model below. Automatic picks require a known size of at least 7B.'++for (const how of ['the Send button', 'Enter'] as const) {+ test(`Chat, ${how}: text and attachment stay, and the model picker opens with the reason`, async ({ page }) => {+ await boot(page)+ await expect(picker(page)).toContainText('Select Model')+ const box = page.locator('textarea').first()+ await box.fill(TEXT)+ await page.locator('input[type="file"]').first().setInputFiles(NOTE)+ await expect(page.getByText('notes.txt')).toBeVisible()++ if (how === 'Enter') { await box.focus(); await page.keyboard.press('Enter') }+ else await page.getByRole('button', { name: 'Send message' }).click()++ // Nothing is lost.+ await expect(box).toHaveValue(TEXT)+ await expect(page.getByText('notes.txt')).toBeVisible()+ // No conversation was started: the landing page is still there.+ await expect(page.getByText(LANDING)).toBeVisible()+ // And the picker says what is missing.+ await expect(menu(page)).toBeVisible()+ await expect(menu(page).getByText(HINT)).toBeVisible()++ // The reason stands in the picker, nowhere else on the page.+ await expect(page.getByText(HINT)).toHaveCount(1)++ // Picking the model there and sending again delivers the kept message.+ await menu(page).getByRole('button').filter({ hasText: 'Hermes' }).click()+ await expect(picker(page)).toContainText('Hermes')+ await page.getByRole('button', { name: 'Send message' }).click()+ await expect(box).toHaveValue('')+ await expect(page.getByText(LANDING)).toHaveCount(0)+ await expect(page.getByText(TEXT).first()).toBeVisible()+ await expect(page.getByText(DEFAULT_ASSISTANT_REPLY).first()).toBeVisible({ timeout: 15_000 })+ })+}++test('Chat: closing the picker without a pick leaves a mark on the model button, and the draft stays', async ({ page }) => {+ await boot(page)+ const box = page.locator('textarea').first()+ await box.fill(TEXT)+ await expect(page.getByTestId('picker-send-needs-model-dot')).toHaveCount(0)+ await page.getByRole('button', { name: 'Send message' }).click()+ await expect(menu(page)).toBeVisible()+ await page.keyboard.press('Escape')+ await expect(menu(page)).toHaveCount(0)+ await expect(page.getByTestId('picker-send-needs-model-dot')).toBeVisible()+ await expect(box).toHaveValue(TEXT)+ await expect(page.getByText(HINT)).toHaveCount(0)+})++test('Code: the instruction stays and the model picker opens with the reason', async ({ page }) => {+ await boot(page)+ await page.getByRole('button', { name: 'Code', exact: true }).click()+ await expect(picker(page)).toContainText('Select Model')+ const box = page.locator('textarea').first()+ await box.fill(TEXT)+ await box.focus()+ await page.keyboard.press('Enter')+ await expect(box).toHaveValue(TEXT)+ await expect(menu(page)).toBeVisible()+ await expect(menu(page).getByText(HINT)).toBeVisible()+ await page.keyboard.press('Escape')+ await page.getByRole('button', { name: 'Send message' }).click()+ await expect(menu(page)).toBeVisible()+ await expect(box).toHaveValue(TEXT)+})diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex 5577a4f0..bdc2ce59 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -7,6 +7,7 @@ import { VoiceButton } from './VoiceButton'import { ApprovalDialog } from './ApprovalDialog'import { useVoiceStore } from '../../stores/voiceStore'import { useSettingsStore } from '../../stores/settingsStore'+import { useUIStore } from '../../stores/uiStore'import { useModelStore } from '../../stores/modelStore'import { useChatStore } from '../../stores/chatStore'import { isThinkingCompatible, isVisionCompatible, declaredVision } from '../../lib/model-compatibility'@@ -45,6 +46,13 @@ interface Props {onApprove?: () => voidonReject?: () => voiddisabled?: boolean+ /**+ * Does a send have a chat model to run on right now? Asked at the moment of+ * sending. Without one the send does not happen and nothing of the draft is+ * touched: the model picker opens and says what is missing. Left out, the+ * rule is simply "a model is picked".+ */+ modelReady?: () => boolean/*** Which commands this composer offers. Was a boolean meaning* "Coding-Agent-only"; since 2.6.8 it is the SCOPE, because the answer@@ -98,7 +106,7 @@ function passSendLock(lock: { current: number }): boolean {return true}-export function ChatInput({ onSend, onStop, isGenerating, waitingForLocalLane, pendingApproval, onApprove, onReject, disabled, slashCommands, composerModel, composerActions, composerAbove }: Props) {+export function ChatInput({ onSend, onStop, isGenerating, waitingForLocalLane, pendingApproval, onApprove, onReject, disabled, modelReady, slashCommands, composerModel, composerActions, composerAbove }: Props) {const [input, setInput] = useState('')const [images, setImages] = useState<ImageAttachment[]>([])// Files of any other kind (3.0.5). Each entry is a description plus the@@ -412,6 +420,15 @@ export function ChatInput({ onSend, onStop, isGenerating, waitingForLocalLane, pconst handleSend = () => {const trimmed = input.trim()if (imageJob.current.busy || fileJob.current.busy || (!trimmed && images.length === 0 && files.length === 0) || isGenerating || waitingForLocalLane || disabled) return+ // No chat model to answer: the send handlers return without a word in that+ // case, and the lines below would then empty the field and the chips for a+ // message that went nowhere (found in the Windows build of 3.0.5). The+ // draft stays as it is, and the model picker opens with the reason. The+ // Send button and Enter both come through here.+ if (!(modelReady ? modelReady() : !!useModelStore.getState().activeModel)) {+ useUIStore.getState().askForModel()+ return+ }if (!passSendLock(sendLockRef)) returnconst text = trimmed || (images.length > 0 ? '(image)' : FILE_ONLY_TEXT)const pictures = images.length > 0 ? images : undefineddiff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsxindex 92736553..b2077f76 100644--- a/src/components/chat/ChatView.tsx+++ b/src/components/chat/ChatView.tsx@@ -38,6 +38,7 @@ import { SmallModelModeToggle } from './SmallModelModeToggle'import { ABCompare } from './ABCompare'import { RecentChats } from './RecentChats'import { useUIStore } from '../../stores/uiStore'+import { chatModelReady } from '../../lib/chat-model-ready'import { useCompareStore } from '../../stores/compareStore'import { exportConversation, missingImagesNote } from '../../lib/chat-export'import { conversationMode } from '../../lib/conversation-mode'@@ -788,6 +789,7 @@ export function ChatView() {{/* Code mode brings its own composer (CodexView above). */}<ChatInputonSend={sendMessage}+ modelReady={chatModelReady}onStop={stopGeneration}isGenerating={busy.thisChat || queuedForLocalLane}waitingForLocalLane={queuedForLocalLane}diff --git a/src/components/chat/__tests__/any-file-attaches-as-a-chip.test.tsx b/src/components/chat/__tests__/any-file-attaches-as-a-chip.test.tsxindex 0646dbde..0a0581b3 100644--- a/src/components/chat/__tests__/any-file-attaches-as-a-chip.test.tsx+++ b/src/components/chat/__tests__/any-file-attaches-as-a-chip.test.tsx@@ -36,7 +36,7 @@ afterEach(cleanup)function setup() {const send = vi.fn()- const { container } = render(<ChatInput onSend={send} onStop={() => {}} isGenerating={false} />)+ const { container } = render(<ChatInput onSend={send} onStop={() => {}} isGenerating={false} modelReady={() => true} />)const input = container.querySelector<HTMLInputElement>('input[type=file]')!const attach = (...files: File[]) => fireEvent.change(input, { target: { files } })return { send, attach, input }diff --git a/src/components/chat/__tests__/image-upload-races.test.tsx b/src/components/chat/__tests__/image-upload-races.test.tsxindex 54daff2f..feaf7d62 100644--- a/src/components/chat/__tests__/image-upload-races.test.tsx+++ b/src/components/chat/__tests__/image-upload-races.test.tsx@@ -19,7 +19,7 @@ beforeEach(() => {afterEach(cleanup)function setup() {const send = vi.fn()- const { container } = render(<ChatInput onSend={send} onStop={() => {}} isGenerating={false} />)+ const { container } = render(<ChatInput onSend={send} onStop={() => {}} isGenerating={false} modelReady={() => true} />)const input = container.querySelector('input[type=file]')!const attach = () => fireEvent.change(input, { target: { files: [new File(['data'], 'test.png', { type: 'image/png' })] } })return { send, attach }diff --git a/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx b/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsxnew file mode 100644index 00000000..98f6ce02--- /dev/null+++ b/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx@@ -0,0 +1,212 @@+/**+ * @vitest-environment jsdom+ *+ * Sending without a chat model must not lose the message.+ *+ * Found in the real Windows build of 3.0.5: with no chat model picked the Send+ * button was live, and a click with text (with or without attachments) emptied+ * the field and the chips. `sendMessage` and `sendInstruction` return without+ * a word when there is no model, and the composer cleared the draft anyway.+ *+ * The composer now asks first. Without a model nothing is handed over and+ * nothing is cleared, and the model picker is asked to open (uiStore+ * `modelAskSeq`), where the reason is written. The whole way through the real+ * app is in e2e/send-without-a-model-keeps-the-message.spec.ts.+ *+ * Run: npx vitest run src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx+ */+import { describe, it, expect, beforeEach, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import { ChatInput } from '../ChatInput'+import { ModelSelector } from '../../models/ModelSelector'+import { chatModelReady } from '../../../lib/chat-model-ready'+import { useModelStore } from '../../../stores/modelStore'+import { useSettingsStore } from '../../../stores/settingsStore'+import { useUIStore } from '../../../stores/uiStore'++vi.mock('../../../hooks/useModels', async () => {+ const { useModelStore: store } = await import('../../../stores/modelStore')+ return {+ useModels: () => ({+ models: store((s) => s.models),+ activeModel: store((s) => s.activeModel),+ setActiveModel: store.getState().setActiveModel,+ fetchModels: async () => {},+ }),+ }+})++const TEXT = 'a message that must not get lost'+const LOCAL = 'qwen3:8b'+const CLOUD = 'lu-cloud::moonshotai/Kimi-K3'++const box = () => screen.getByRole('textbox') as HTMLTextAreaElement+const sendButton = () => screen.getByRole('button', { name: 'Send message' }) as HTMLButtonElement+const asked = () => useUIStore.getState().modelAskSeq++beforeEach(() => {+ cleanup()+ useModelStore.setState({ activeModel: null, models: [] } as never)+ useSettingsStore.getState().updateSettings({ appMode: 'local' })+ useUIStore.setState({ modelAskSeq: 0 })+})++describe('the composer with no chat model picked', () => {+ it('the Send button is live, a click sends nothing and keeps the text', () => {+ const onSend = vi.fn()+ render(<ChatInput onSend={onSend} onStop={() => {}} isGenerating={false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ expect(sendButton().disabled).toBe(false)+ fireEvent.click(sendButton())+ expect(onSend).not.toHaveBeenCalled()+ expect(box().value).toBe(TEXT)+ expect(asked()).toBe(1)+ })++ it('Enter does the same', () => {+ const onSend = vi.fn()+ render(<ChatInput onSend={onSend} onStop={() => {}} isGenerating={false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.keyDown(box(), { key: 'Enter' })+ expect(onSend).not.toHaveBeenCalled()+ expect(box().value).toBe(TEXT)+ expect(asked()).toBe(1)+ })++ it('every further try asks again, and the draft is still there', () => {+ render(<ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ fireEvent.click(sendButton())+ expect(asked()).toBe(2)+ expect(box().value).toBe(TEXT)+ })++ it('once a model is picked the kept message goes out and the field clears', () => {+ const onSend = vi.fn()+ render(<ChatInput onSend={onSend} onStop={() => {}} isGenerating={false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ useModelStore.setState({ activeModel: LOCAL } as never)+ fireEvent.click(sendButton())+ expect(onSend).toHaveBeenCalledTimes(1)+ expect(onSend).toHaveBeenCalledWith(TEXT, undefined)+ expect(box().value).toBe('')+ expect(asked()).toBe(1)+ })++ it('COUNTER-CHECK: with a model picked the first send goes out and nothing is asked', () => {+ useModelStore.setState({ activeModel: LOCAL } as never)+ const onSend = vi.fn()+ render(<ChatInput onSend={onSend} onStop={() => {}} isGenerating={false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.keyDown(box(), { key: 'Enter' })+ expect(onSend).toHaveBeenCalledWith(TEXT, undefined)+ expect(asked()).toBe(0)+ })++ it('the surface says what counts as ready: a refusal keeps the draft although a model is picked', () => {+ useModelStore.setState({ activeModel: LOCAL } as never)+ const onSend = vi.fn()+ render(<ChatInput onSend={onSend} onStop={() => {}} isGenerating={false} modelReady={() => false} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ expect(onSend).not.toHaveBeenCalled()+ expect(box().value).toBe(TEXT)+ expect(asked()).toBe(1)+ })+})++describe('what Chat counts as a model to send with', () => {+ it('nothing picked: not ready', () => {+ expect(chatModelReady()).toBe(false)+ })++ it('a local model in Local mode, a cloud model in Cloud mode: ready', () => {+ useModelStore.setState({ activeModel: LOCAL } as never)+ expect(chatModelReady()).toBe(true)+ useSettingsStore.getState().updateSettings({ appMode: 'cloud' })+ useModelStore.setState({ activeModel: CLOUD } as never)+ expect(chatModelReady()).toBe(true)+ })++ // sendMessage clears such a model and returns (the Cloud switch is a money+ // gate). The composer has to know before it clears the draft.+ it('a cloud model while the switch says Local: not ready, and the pick is cleared', () => {+ useModelStore.setState({ activeModel: CLOUD } as never)+ expect(chatModelReady()).toBe(false)+ expect(useModelStore.getState().activeModel).toBeNull()+ })+})++describe('the model picker after a send without a model', () => {+ const HINT = 'Pick a model to send your message. Your text and attachments are kept.'+ const picker = () => screen.getByRole('button', { name: 'Select chat model' })+ const withModels = () => useModelStore.setState({+ activeModel: null,+ models: [{ name: LOCAL, type: 'text', provider: 'ollama' }],+ } as never)++ it('stays closed and unmarked until a send asks for a model', () => {+ withModels()+ render(<ModelSelector openUpward />)+ expect(screen.queryByTestId('model-picker-menu')).toBeNull()+ expect(screen.queryByTestId('picker-send-needs-model-dot')).toBeNull()+ })++ it('opens by itself and says what is missing, in the menu', () => {+ withModels()+ render(<><ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} composerModel={<ModelSelector openUpward />} /></>)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ expect(screen.getByTestId('model-picker-menu')).toBeTruthy()+ expect(screen.getByTestId('picker-send-needs-model').textContent).toBe(HINT)+ expect(picker().getAttribute('aria-expanded')).toBe('true')+ expect(box().value).toBe(TEXT)+ })++ it('with no model listed the sentence says so', () => {+ render(<ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} composerModel={<ModelSelector openUpward />} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ expect(screen.getByTestId('picker-send-needs-model').textContent)+ .toBe('Your message needs a chat model, and none is listed yet. Your text and attachments are kept.')+ })++ it('closed without a pick: the dot on the button stays, the sentence comes back on opening', () => {+ withModels()+ render(<ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} composerModel={<ModelSelector openUpward />} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ fireEvent.click(picker())+ expect(screen.getByTestId('picker-send-needs-model-dot')).toBeTruthy()+ expect(picker().getAttribute('title')).toBe('Your message needs a chat model. Pick one here to send it.')+ fireEvent.click(picker())+ expect(screen.getByTestId('picker-send-needs-model')).toBeTruthy()+ })++ it('a picked model takes the dot and the sentence away', () => {+ withModels()+ render(<ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} composerModel={<ModelSelector openUpward />} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ fireEvent.click(picker())+ useModelStore.setState({ activeModel: LOCAL } as never)+ cleanup()+ render(<ModelSelector openUpward />)+ expect(screen.queryByTestId('picker-send-needs-model-dot')).toBeNull()+ fireEvent.click(picker())+ expect(screen.queryByTestId('picker-send-needs-model')).toBeNull()+ })++ it('nothing of it is written in the composer: the sentence lives in the menu only', () => {+ withModels()+ render(<ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} composerModel={<ModelSelector openUpward />} />)+ fireEvent.change(box(), { target: { value: TEXT } })+ fireEvent.click(sendButton())+ const menu = screen.getByTestId('model-picker-menu')+ const hits = screen.getAllByText(HINT)+ expect(hits).toHaveLength(1)+ expect(menu.contains(hits[0])).toBe(true)+ })+})diff --git a/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx b/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsxindex f42c615d..da6efa15 100644--- a/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx+++ b/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx@@ -88,7 +88,7 @@ describe('the composer of a chat that is NOT the one answering', () => {it('does fire a send while another chat is answering, no lock left to stop it', () => {let sent = 0render(- <ChatInput onSend={() => { sent += 1 }} onStop={() => {}} isGenerating={asSeenFromA.thisChat} />,+ <ChatInput onSend={() => { sent += 1 }} onStop={() => {}} isGenerating={asSeenFromA.thisChat} modelReady={() => true} />,)const box = screen.getByRole('textbox')fireEvent.change(box, { target: { value: 'hello' } })diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 60499c3f..9c92767d 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -730,6 +730,29 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredByconst [open, setOpen] = useState(false)useDismissOnEscape(open, () => setOpen(false))+ /**+ * A send was tried without a chat model (ChatInput.handleSend). The message+ * stays in the composer, and this picker is where the user learns why: it+ * opens, and its first line says what is missing. Nothing is written in or+ * above the prompt field. When the menu is closed without a pick, the dot+ * on the button stays as the way back to the sentence, until a model is+ * there.+ *+ * The counter is compared during render instead of in an effect: opening is+ * a reaction to one click somewhere else, and an effect would open the menu+ * one paint late.+ */+ const modelAskSeq = useUIStore((s) => s.modelAskSeq)+ const [seenModelAsk, setSeenModelAsk] = useState(modelAskSeq)+ const [modelAsked, setModelAsked] = useState(false)+ if (seenModelAsk !== modelAskSeq) {+ setSeenModelAsk(modelAskSeq)+ setModelAsked(true)+ setOpen(true)+ }+ if (modelAsked && activeModel) setModelAsked(false)+ const sendNeedsModel = modelAsked && !activeModel+/*** Die Lesezeit beginnt, wenn der Satz wirklich zu lesen ist.*@@ -1276,7 +1299,8 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBytitle={answeredBy? `The answers in this chat were written by ${answeredBy}. The next answer runs on the model picked here.`- : activeModel ? `Model: ${activeDisplayName}, click to switch` : 'Select a chat model'+ : activeModel ? `Model: ${activeDisplayName}, click to switch`+ : sendNeedsModel ? 'Your message needs a chat model. Pick one here to send it.' : 'Select a chat model'}aria-label="Select chat model"aria-expanded={open}@@ -1345,6 +1369,16 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy/>)}+ {/* A send is waiting for a model and the menu is closed: the same dot,+ as the way back to the sentence in the menu. */}+ {sendNeedsModel && !open && (+ <span+ data-testid="picker-send-needs-model-dot"+ aria-hidden+ className="absolute top-0 right-0 w-1.5 h-1.5 rounded-full bg-lu-accent pointer-events-none"+ />+ )}+{/* ── Dropdown ── */}<AnimatePresence>{open && (@@ -1360,6 +1394,18 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredByexit={{ opacity: 0, y: menue.nachOben ? 6 : -6, scale: 0.98 }}transition={{ duration: MOTION_S.fast, ease: 'easeOut' }}>+ {/* First of all: why the menu opened by itself. The message the+ user tried to send is still in the composer. */}+ {sendNeedsModel && (+ <div+ data-testid="picker-send-needs-model"+ className={`px-2.5 py-1.5 border-b border-black/5 dark:border-white/[0.06] t-micro leading-snug ${HINWEIS_TEXT.ruhig}`}+ >+ {textModels.length > 0+ ? 'Pick a model to send your message. Your text and attachments are kept.'+ : 'Your message needs a chat model, and none is listed yet. Your text and attachments are kept.'}+ </div>+ )}{/* Noch vor der Engine-Zeile: was sich am Modell selbst geaenderthat, waehrend der Nutzer woanders hinsah. Begruendung desPlatzes oben an `engineSwitchNote`. */}diff --git a/src/lib/chat-model-ready.ts b/src/lib/chat-model-ready.tsnew file mode 100644index 00000000..e0582110--- /dev/null+++ b/src/lib/chat-model-ready.ts@@ -0,0 +1,24 @@+import { useModelStore } from '../stores/modelStore'+import { useSettingsStore } from '../stores/settingsStore'+import { modelOutOfMode } from './modeGate'++/**+ * Does a chat send have a model to run on? The composer asks this before it+ * hands the message over, because `sendMessage` (hooks/useChat.ts) returns+ * without a word when it has none, and the composer would then clear a message+ * that went nowhere.+ *+ * The same two cases `sendMessage` turns away: nothing picked, and a model+ * from the other side of the Cloud switch. That one is cleared here exactly+ * as `sendMessage` clears it (the switch is a money gate), so the picker shows+ * the honest "Select Model" when it opens.+ */+export function chatModelReady(): boolean {+ const { activeModel, setActiveModel } = useModelStore.getState()+ if (!activeModel) return false+ if (modelOutOfMode(activeModel, useSettingsStore.getState().settings.appMode)) {+ setActiveModel(null)+ return false+ }+ return true+}diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.tsindex dc1c5780..68e80545 100644--- a/src/stores/uiStore.ts+++ b/src/stores/uiStore.ts@@ -130,6 +130,12 @@ interface UIState {/** Read once by SettingsPage when it mounts, then cleared. Never persisted:* it describes one navigation, not a preference. */settingsFocus: SettingsFocus | null+ /** Counts the sends that were tried with no chat model picked. The model+ * picker of the composer watches it: each step opens the picker, which says+ * there what is missing. A counter and not a flag, so a second try opens it+ * again. Never persisted: it describes one click, not a preference. */+ modelAskSeq: number+ askForModel: () => voidsetView: (view: View) => void/** Open Settings on a given tab, optionally with one section unfolded. */openSettingsAt: (focus: SettingsFocus) => void@@ -200,6 +206,8 @@ export const useUIStore = create<UIState>()(explorerWidth: EXPLORER_DEFAULT_WIDTH,explorerCollapsed: false,settingsFocus: null,+ modelAskSeq: 0,+ askForModel: () => set((s) => ({ modelAskSeq: s.modelAskSeq + 1 })),// Navigation no longer touches sidebarOpen. The conversation list only// makes sense in Chat, and that rule now lives in the Sidebar itself