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(lint): die vierzehn any und der Zustand im Effekt sind weg
purple56c8281eb950
diff --git a/src/api/__tests__/provider-effort-ladder.test.ts b/src/api/__tests__/provider-effort-ladder.test.tsindex f40e20b8..8ed3f6c9 100644--- a/src/api/__tests__/provider-effort-ladder.test.ts+++ b/src/api/__tests__/provider-effort-ladder.test.ts@@ -52,9 +52,12 @@ const refuse = (status = 400) =>new Response(JSON.stringify({ error: { message: 'Unexpected reasoning effort high.' } }), { status })const okStream = () => new Response('data: {"choices":[{"delta":{"content":"hi"}}]}\n\ndata: [DONE]\n\n', { status: 200 })-const bodyOf = (spy: any, call: number) => JSON.parse(spy.mock.calls[call][1]?.body as string)+// Die Form, die `vi.spyOn(globalThis, 'fetch')` wirklich hat. Ein `any` an+// dieser Stelle haette jeden Tippfehler im Zugriff verschluckt.+type FetchSpy = { mock: { calls: Parameters<typeof fetch>[] } }+const bodyOf = (spy: FetchSpy, call: number) => JSON.parse(spy.mock.calls[call][1]?.body as string)-async function drain(gen: AsyncGenerator<any>) {+async function drain(gen: AsyncGenerator<unknown>) {for await (const _ of gen) { /* consume, the fetch only happens on first next() */ }}diff --git a/src/api/__tests__/rag-context-reaches-the-cloud.test.ts b/src/api/__tests__/rag-context-reaches-the-cloud.test.tsindex d0762dc3..0df44523 100644--- a/src/api/__tests__/rag-context-reaches-the-cloud.test.ts+++ b/src/api/__tests__/rag-context-reaches-the-cloud.test.ts@@ -46,7 +46,10 @@ const okStream = () =>/** The passage a user's PDF would contribute after chunking and ranking. */const SECRET = 'The service level target for the Bergheim site is 99.95 percent.'-async function drain(gen: AsyncGenerator<any>) {+/** Eine Nachricht so, wie sie auf der Leitung steht. */+type Wire = { role: string; content: string }++async function drain(gen: AsyncGenerator<unknown>) {for await (const _ of gen) { /* the fetch only happens on the first next() */ }}@@ -100,7 +103,7 @@ describe('a cloud request carries the document context', () => {expect(String(url)).toContain('/api/inference/v1/chat/completions')expect((init.headers as Record<string, string>).Authorization).toBe('Bearer session-token-abc')- const system = body.messages.find((m: any) => m.role === 'system')+ const system = body.messages.find((m: Wire) => m.role === 'system')expect(system).toBeDefined()expect(system.content).toContain(SECRET)expect(system.content).toContain('[Source 1]')@@ -115,7 +118,7 @@ describe('a cloud request carries the document context', () => {const systemPrompt = 'You are a terse assistant.'const { body, init } = await sendCloudTurn(systemPrompt)- const system = body.messages.find((m: any) => m.role === 'system')+ const system = body.messages.find((m: Wire) => m.role === 'system')expect(system.content).toBe(systemPrompt)expect(String(init.body)).not.toContain('Bergheim site is 99.95')expect(String(init.body)).not.toContain('[Source 1]')diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex 35d69b8d..9fc9f34d 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -570,9 +570,10 @@ let cachedVRAM: number | null = null* for that one `vram_total` is `psutil.virtual_memory().total`. It is system* RAM wearing a VRAM field's name.*/-function isCpuDevice(dev: any): boolean {- const type = String(dev?.type ?? '').trim().toLowerCase()- const name = String(dev?.name ?? '').trim().toLowerCase()+function isCpuDevice(dev: unknown): boolean {+ const d = (dev ?? {}) as { type?: unknown; name?: unknown }+ const type = String(d.type ?? '').trim().toLowerCase()+ const name = String(d.name ?? '').trim().toLowerCase()return type === 'cpu' || name === 'cpu' || name.startsWith('cpu:') || name.startsWith('cpu ')}@@ -617,7 +618,7 @@ export function pickDeviceVramBytes(let best = 0for (const dev of devices) {if (!opts.unifiedMemory && isCpuDevice(dev)) continue- const bytes = (dev as any)?.vram_total+ const bytes = (dev as { vram_total?: unknown } | null)?.vram_totalif (typeof bytes === 'number' && Number.isFinite(bytes) && bytes > best) best = bytes}return best > 0 ? best : nulldiff --git a/src/hooks/__tests__/rag-context-reaches-a-cloud-send.test.ts b/src/hooks/__tests__/rag-context-reaches-a-cloud-send.test.tsindex e7722935..09bd8b75 100644--- a/src/hooks/__tests__/rag-context-reaches-a-cloud-send.test.ts+++ b/src/hooks/__tests__/rag-context-reaches-a-cloud-send.test.ts@@ -28,7 +28,7 @@ import type { TextChunk } from '../../types/rag'const retrieveContext = vi.fn()vi.mock('../../api/rag', () => ({- retrieveContext: (...a: any[]) => retrieveContext(...a),+ retrieveContext: (...a: unknown[]) => retrieveContext(...a),generateEmbeddings: async () => [[0.1, 0.2]],}))vi.mock('../../api/cloud/supabase', () => ({@@ -67,7 +67,11 @@ function seed(chunks: TextChunk[]) {const convId = useChatStore.getState().createConversation(MODEL, '')useChatStore.getState().setActiveConversation(convId)useRAGStore.setState({- documents: { [convId]: [{ id: 'doc-1', name: 'sla.pdf', size: 1, chunks: chunks.length } as any] },+ // Ein echtes DocumentMeta. Das `as any`, das hier stand, hat eine falsche+ // Form verdeckt: `chunks` statt `chunkCount`, kein `type`, kein `addedAt`.+ documents: {+ [convId]: [{ id: 'doc-1', name: 'sla.pdf', type: 'pdf', size: 1, addedAt: 0, chunkCount: chunks.length }],+ },chunks,ragEnabled: { [convId]: true },chunksLoaded: true,@@ -107,7 +111,10 @@ async function sendAsAgent(text = 'What is the target for Bergheim?') {}}-const systemOf = (body: any) => body.messages.find((m: any) => m.role === 'system')?.content ?? ''+/** Eine Nachricht so, wie sie auf der Leitung steht. */+type Wire = { role: string; content: string }+const systemOf = (body: { messages: Wire[] } | null) =>+ body?.messages.find((m) => m.role === 'system')?.content ?? ''beforeEach(() => {retrieveContext.mockReset()@@ -116,7 +123,7 @@ beforeEach(() => {useSettingsStore.setState({settings: { ...DEFAULT_SETTINGS, appMode: 'cloud', cavemanMode: 'off' },})- useProviderStore.setState((s: any) => ({+ useProviderStore.setState((s) => ({providers: {...s.providers,'lu-cloud': { ...s.providers['lu-cloud'], enabled: true },diff --git a/src/hooks/__tests__/the-install-card-has-a-working-path.test.ts b/src/hooks/__tests__/the-install-card-has-a-working-path.test.tsindex 85256c36..80a23ddd 100644--- a/src/hooks/__tests__/the-install-card-has-a-working-path.test.ts+++ b/src/hooks/__tests__/the-install-card-has-a-working-path.test.ts@@ -31,7 +31,7 @@ vi.mock('../../api/embed-availability', () => ({EMBED_PROBE_TIMEOUT_MS: 3000,}))vi.mock('../../api/embed-install', () => ({- installBundledEmbedModel: (...a: any[]) => installBundled(...(a as [])),+ installBundledEmbedModel: (...a: unknown[]) => installBundled(...(a as [])),}))const connectionArgs: (number | undefined)[] = []vi.mock('../../api/ollama', () => ({@@ -40,7 +40,7 @@ vi.mock('../../api/ollama', () => ({return ollamaUp},getModelContext: async () => 8192,- pullModelTauri: (...a: any[]) => pullTauri(...(a as [])),+ pullModelTauri: (...a: unknown[]) => pullTauri(...(a as [])),}))vi.mock('../../api/rag', () => ({indexDocument: async () => ({ chunks: [] }),diff --git a/src/hooks/useEmbedLane.ts b/src/hooks/useEmbedLane.tsindex eee7273c..02744e26 100644--- a/src/hooks/useEmbedLane.ts+++ b/src/hooks/useEmbedLane.ts@@ -27,7 +27,7 @@* subscriber leaves, so switching from Cloud to Local does not carry a poll* along with it (review points 1 and 2).*/-import { useEffect, useState } from 'react'+import { useCallback, useSyncExternalStore } from 'react'import { useRAGStore } from '../stores/ragStore'import { embeddingLane, type EmbedLaneInfo } from '../api/embed-availability'@@ -42,10 +42,37 @@ let retryTimer: ReturnType<typeof setTimeout> | null = null* again exists, never by the retry itself. */let retryUsed = falselet listenerArmed = false-const subscribers = new Set<(v: EmbedLaneInfo | null) => void>()+const subscribers = new Set<() => void>()function publish() {- for (const fn of subscribers) fn(current)+ for (const fn of subscribers) fn()+}++/**+ * Ein Leser meldet sich an und bekommt seine Abmeldung zurueck.+ *+ * Das stand bis 04.09.2026 im Effekt des Hooks und war deshalb an React+ * gebunden, obwohl nichts daran mit Rendern zu tun hat. Hier ist es das, was+ * es ist: der Anmeldeteil eines Speichers, der ausserhalb von React lebt.+ */+function anmelden(melden: () => void): () => void {+ // A fresh mount is a fresh reason to look, so it gets its own retry.+ const fresh = subscribers.size === 0+ if (fresh) retryUsed = false+ subscribers.add(melden)+ if (!listenerArmed) {+ listenerArmed = true+ window.addEventListener('lu-models-refresh', onRefresh)+ }+ // Never measured yet, or the cache holds a NO and this is a new mount: a+ // user who left Cloud mode, installed an engine and came back must not read+ // a stale refusal. A cached YES is kept; nothing about it goes stale in a+ // way that hurts, and a real change fires lu-models-refresh anyway.+ if (current === null || (fresh && current.lane === 'none')) void measure()+ return () => {+ subscribers.delete(melden)+ if (subscribers.size === 0) teardown()+ }}/** Measure once. Concurrent callers share the one round trip. */@@ -111,32 +138,23 @@ export function __resetEmbedLaneForTests(): void {* @returns the lane, or null while it is still unknown.*/export function useEmbedLane(active: boolean): EmbedLaneInfo | null {- const [value, setValue] = useState<EmbedLaneInfo | null>(active ? current : null)-- useEffect(() => {- if (!active) {- setValue(null)- return- }- // A fresh mount is a fresh reason to look, so it gets its own retry.- const fresh = subscribers.size === 0- if (fresh) retryUsed = false- subscribers.add(setValue)- if (!listenerArmed) {- listenerArmed = true- window.addEventListener('lu-models-refresh', onRefresh)- }- setValue(current)- // Never measured yet, or the cache holds a NO and this is a new mount: a- // user who left Cloud mode, installed an engine and came back must not read- // a stale refusal. A cached YES is kept; nothing about it goes stale in a- // way that hurts, and a real change fires lu-models-refresh anyway.- if (current === null || (fresh && current.lane === 'none')) void measure()- return () => {- subscribers.delete(setValue)- if (subscribers.size === 0) teardown()- }- }, [active])-- return active ? value : null+ // `useSyncExternalStore` und nicht `useState` plus Effekt. Der gemessene Wert+ // liegt in einem Modul, nicht in React, und genau dafuer ist dieser Haken+ // gebaut: React fragt den Stand selbst ab, nachdem es sich angemeldet hat,+ // und es kann waehrend eines unterbrochenen Durchlaufs nicht passieren, dass+ // zwei Stellen der Oberflaeche verschiedene Antworten zeigen.+ //+ // Vorher lag der Wert doppelt: einmal im Modul und einmal in einem+ // `useState`, das ein Effekt nachzog. Daraus kam die eslint-Meldung+ // `react-hooks/set-state-in-effect`, und sie hatte recht: jedes Anmelden+ // zeichnete zweimal, einmal mit dem alten und einmal mit dem neuen Wert.+ //+ // `active` false heisst: gar nicht erst anmelden, also auch keine Messung+ // und keine Rundreise. Der Stand ist dann null, und zwar ohne dass ihn+ // jemand loeschen muesste.+ const abonnieren = useCallback(+ (melden: () => void) => (active ? anmelden(melden) : () => {}),+ [active],+ )+ return useSyncExternalStore(abonnieren, () => (active ? current : null))}