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
feat(context): Kontext pro Cloud-Modell im Kopfzeilen-Waehler einstellbar
purplef000c6770866
diff --git a/e2e/cloud-kontext-pro-modell.spec.ts b/e2e/cloud-kontext-pro-modell.spec.tsnew file mode 100644index 00000000..ff89bd46--- /dev/null+++ b/e2e/cloud-kontext-pro-modell.spec.ts@@ -0,0 +1,59 @@+import { test, expect } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate, cloudSwitch } from './support/cloud-mock'++/**+ * David 01.10.2026: "Kann man das Kontextfenster nicht bei jedem Cloud-Modell+ * aendern?" The model's own window is fixed on LU Cloud, the lever is how much+ * of the chat each step sends. The header dropdown sets it per model and the+ * next request really sends within it.+ */+test('a cloud model gets its own context pick from the header dropdown', async ({ page }) => {+ await page.addInitScript(tauriMockInit, { assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: DEFAULT_MODEL_NAME })+ await seedOnboardingDone(page)+ await routeCloud(page, { license: 'active', access: true, mediaLive: true, paidPlan: true })+ const cors = { 'access-control-allow-origin': '*', 'access-control-allow-headers': 'authorization, content-type' }+ await page.route('**/api/inference/v1/models', (route) => route.fulfill({+ status: 200, headers: cors, contentType: 'application/json',+ body: JSON.stringify({ object: 'list', data: [{+ id: 'moonshotai/Kimi-K2.6', name: 'Kimi K2.6', context_length: 262144, supports_tools: true, think: 'never',+ }] }),+ }))+ await page.route('**/api/inference/v1/chat/completions', (route) => {+ if (route.request().method() === 'OPTIONS') return route.fulfill({ status: 204, headers: cors })+ return route.fulfill({ status: 200, headers: cors, contentType: 'text/event-stream',+ body: `data: ${JSON.stringify({ choices: [{ index: 0, delta: { content: 'ok' }, finish_reason: 'stop' }] })}\n\ndata: [DONE]\n\n` })+ })++ await page.goto('/')+ await signInViaGate(page)+ await expect(cloudSwitch(page)).toBeChecked()+ await page.getByRole('button', { name: /New Chat/i }).first().click()+ await page.getByRole('button', { name: 'Select chat model', exact: true }).click()+ await page.getByRole('button', { name: /Kimi K2\.6/ }).first().click()++ const composer = page.locator('textarea').first()+ await composer.fill('hello')+ await composer.press('Enter')+ await expect(page.getByText('ok', { exact: true })).toBeVisible({ timeout: 15_000 })++ const knob = page.getByRole('button', { name: /Context window/ }).first()+ await expect(knob).toBeVisible({ timeout: 15_000 })+ // Default: the fill over the 32K send window, not over the model's 256K.+ await expect(knob).toContainText('/32K')++ await knob.click()+ await expect(page.getByRole('button', { name: /^Auto · 32K$/ })).toBeVisible()+ // Too small to hold one cloud step, so not offered.+ await expect(page.getByRole('button', { name: /^8K$/ })).toHaveCount(0)+ await page.getByRole('button', { name: /^64K$/ }).click()+ await expect(knob).toContainText('/64K')++ const saved = await page.evaluate(() => JSON.parse(localStorage.getItem('chat-settings') || '{}').state?.settings?.cloudSendWindowByModel)+ expect(Object.values(saved ?? {})).toEqual([65536])++ // Back to Auto clears the pick.+ await knob.click()+ await page.getByRole('button', { name: /^Auto · 32K$/ }).click()+ await expect(knob).toContainText('/32K')+})diff --git a/src/components/chat/ContextDropdown.tsx b/src/components/chat/ContextDropdown.tsxindex 687f3cf8..67e2d371 100644--- a/src/components/chat/ContextDropdown.tsx+++ b/src/components/chat/ContextDropdown.tsx@@ -52,7 +52,8 @@ function abschneidendeFlaeche(el: Element): { oben: number; unten: number } {* - LM Studio: `lms load -c <N>` (unload + reload, context is load-time there).* - Built-in: ctx lives in settings.builtinEngine (expert tuning), the* engine relaunches with the new -c via swapBundledModel.- * Hidden for cloud models (their context is fixed and not adjustable here).+ * Cloud models: their own window is fixed, so the pick there is the send+ * window per model (settings.cloudSendWindowByModel), saved without a reload.** D-S06, „Zwei Kontextanzeigen 24px nebeneinander in verschiedener Notation:* ‚32/8.2k' und ‚ctx 8K' → eine."@@ -163,11 +164,16 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {// in `contextWindowByModel`, im SELBEN Speicher wie die beiden anderen// (settingsStore), nur unter einem Schluessel statt in einem festen Feld.const byModel = useSettingsStore((s) => s.settings.contextWindowByModel)+ const cloudPicks = useSettingsStore((s) => s.settings.cloudSendWindowByModel)+ const globalSendWindow = useSettingsStore((s) => s.settings.codexSendWindowTokens)+ const cloud = ctx.provider === 'cloud'const selected = ctx.provider === 'builtin'? builtinCtx: ctx.provider === 'custom'? (ctx.windowKey ? byModel?.[ctx.windowKey] ?? 0 : 0)- : override+ : cloud+ ? (ctx.windowKey ? cloudPicks?.[ctx.windowKey] ?? 0 : 0)+ : override// Gibt es ueberhaupt einen Fuellstand zu zeigen? Genau die Bedingung, unter// der `TokenCounter` `null` zurueckgibt. Bewusst ein BOOLEAN als Selektor:// ein Abo auf `s.conversations` wuerde diesen Knopf bei jedem Streaming-Flush@@ -190,7 +196,10 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {* Voreinstellungen darueber fallen weg.*/const cap = ctx.modelMax > 0 ? Math.max(ctx.modelMax, 4096) : 0- const options = PRESETS.filter((p) => (cap > 0 ? p < cap : true))+ // A cloud step carries the system prompt and the tool catalogue before any+ // history (about 5k to 8k tokens), so the two smallest rungs could not hold+ // a single turn there.+ const options = PRESETS.filter((p) => (cap > 0 ? p < cap : true) && (!cloud || p >= 16384))const showMax = cap > 0/** Der Haken sitzt auf dem, was WIRKLICH gilt. Eine gespeicherte Wahl ueber@@ -201,6 +210,20 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {const apply = async (value: number) => {setOpen(false)+ /*+ * Cloud model: its own window is fixed, the pick is how much of the chat+ * each step SENDS (and pays for), saved per model. Nothing to reload, the+ * next request reads it through sendWindowFor. 0 = Auto (the default).+ */+ if (cloud) {+ if (!ctx.windowKey) return+ const next = { ...(useSettingsStore.getState().settings.cloudSendWindowByModel ?? {}) }+ if (value > 0) next[ctx.windowKey] = value+ else delete next[ctx.windowKey]+ updateSettings({ cloudSendWindowByModel: next })+ window.dispatchEvent(new Event('lu-context-reloaded'))+ return+ }/** Eigener OpenAI-kompatibler Server: die Zahl ist eine Angabe DARUEBER,* was der Server geladen hat, kein Befehl AN ihn. Sein `-c` steht in@@ -283,7 +306,9 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {onClick={() => setOpen((o) => !o)}disabled={busy}title={- ctx.provider === 'custom'+ cloud+ ? 'Context sent per step: how much of this chat the model sees on every step. More remembers more and costs more per step.'+ : ctx.provider === 'custom'? `Context window: ${SOURCE_LABEL[ctx.source]}. This server decides its own context; pick the value it actually runs with so the counter and the request budget match it.`: `Context window: ${ctx.provider === 'lmstudio' ? "LM Studio's loaded context" : ctx.provider === 'builtin' ? "the LU Engine's loaded context" : 'Ollama num_ctx'}. Changing it reloads the model so it takes effect now.`}@@ -320,7 +345,7 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {{/* Der Fuellstand IST die Beschriftung. Nur wenn es keinen gibt (leererChat), steht hier wieder das Fenster allein. */}<span id={valueId}>- {hasFill ? children : <span>ctx {formatContextWindow(ctx.contextWindow)}</span>}+ {hasFill ? children : <span>ctx {formatContextWindow(cloud ? ctx.sendWindow : ctx.contextWindow)}</span>}</span><ChevronDown size={8} className={`transition-transform ${open ? 'rotate-180' : ''}`} /></button>@@ -353,7 +378,7 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {}`}><button onClick={() => apply(0)} className={rowCls(selectedNow === 0)}>- <span>Auto{ctx.provider === 'ollama' ? ` · ${formatContextWindow(effectiveContextWindow(ctx.modelMax, 0))}` : ctx.provider === 'builtin' ? ` · ${formatContextWindow(ENGINE_DEFAULT_CTX)}` : ctx.provider === 'custom' && ctx.source !== 'user' ? ` · ${formatContextWindow(ctx.contextWindow)}` : ''}</span>+ <span>Auto{ctx.provider === 'ollama' ? ` · ${formatContextWindow(effectiveContextWindow(ctx.modelMax, 0))}` : ctx.provider === 'builtin' ? ` · ${formatContextWindow(ENGINE_DEFAULT_CTX)}` : ctx.provider === 'custom' && ctx.source !== 'user' ? ` · ${formatContextWindow(ctx.contextWindow)}` : cloud ? ` · ${formatContextWindow(globalSendWindow)}` : ''}</span>{selectedNow === 0 && <Check size={10} />}</button>{options.map((p) => (@@ -369,7 +394,9 @@ export function ContextDropdown({ children }: { children?: ReactNode }) {</button>)}<div className="mt-0.5 px-2 pt-1 border-t border-gray-100 dark:border-white/[0.06] text-[0.5rem] text-gray-400 leading-snug">- {ctx.provider !== 'custom'+ {cloud+ ? 'How much of the chat each step sends. More remembers more, and every step costs more. Saved for this model.'+ : ctx.provider !== 'custom'? 'Reloads the model on change.': (ctx.clampedFrom ?? 0) > 0? `Your saved ${formatContextWindow(ctx.clampedFrom ?? 0)} is more than this server runs, so ${formatContextWindow(ctx.contextWindow)} is used. Start the server larger to use it.`diff --git a/src/components/chat/__tests__/die-eingangsseite-hat-eine-tuer.test.ts b/src/components/chat/__tests__/die-eingangsseite-hat-eine-tuer.test.tsindex 856549ca..59fcd9a0 100644--- a/src/components/chat/__tests__/die-eingangsseite-hat-eine-tuer.test.ts+++ b/src/components/chat/__tests__/die-eingangsseite-hat-eine-tuer.test.ts@@ -154,7 +154,7 @@ describe('D-S06: eine Kontextanzeige, nicht zwei', () => {})it('der Knopf zeigt „ctx N" nur noch, wenn es keinen Fuellstand gibt', () => {- expect(DROPDOWN).toMatch(/\{hasFill \? children : <span>ctx \{formatContextWindow\(ctx\.contextWindow\)\}<\/span>\}/)+ expect(DROPDOWN).toMatch(/\{hasFill \? children : <span>ctx \{formatContextWindow\(cloud \? ctx\.sendWindow : ctx\.contextWindow\)\}<\/span>\}/)})it('und die beiden Schreibweisen koennen nicht gleichzeitig auf dem Schirm stehen', () => {diff --git a/src/hooks/__tests__/chat-budget-wiring.test.ts b/src/hooks/__tests__/chat-budget-wiring.test.tsindex b3c67394..bb92576a 100644--- a/src/hooks/__tests__/chat-budget-wiring.test.ts+++ b/src/hooks/__tests__/chat-budget-wiring.test.ts@@ -24,7 +24,7 @@ const agent = read('useAgentChat.ts')describe('plain chat sends under the A2 budget', () => {it('routes the built array through the budget', () => {expect(chat).toMatch(/applyChatSendBudget\(/)- expect(chat).toMatch(/sendWindowTokens: settings\.codexSendWindowTokens/)+ expect(chat).toMatch(/sendWindowTokens: sendWindowFor\(settings, \w+\)/)})it('keeps the message-count cap as the second barrier', () => {diff --git a/src/hooks/__tests__/decay-wiring.test.ts b/src/hooks/__tests__/decay-wiring.test.tsindex 50daaddd..7eca8405 100644--- a/src/hooks/__tests__/decay-wiring.test.ts+++ b/src/hooks/__tests__/decay-wiring.test.ts@@ -40,7 +40,7 @@ describe.each([it('derives the budget from the effective send window', () => {expect(source).toMatch(/effectiveSendWindow\(\{/)- expect(source).toMatch(/sendWindowTokens: settings\.codexSendWindowTokens/)+ expect(source).toMatch(/sendWindowTokens: sendWindowFor\(settings, \w+\)/)expect(source).toMatch(/capEnabled: decayOn/)})diff --git a/src/hooks/useABCompare.ts b/src/hooks/useABCompare.tsindex 2f3fa3c7..aba6351b 100644--- a/src/hooks/useABCompare.ts+++ b/src/hooks/useABCompare.ts@@ -2,6 +2,7 @@* A/B Compare Hook: sends the same prompt to two models in parallel.*/+import { sendWindowFor } from '../lib/send-window'import { useCallback, useRef } from 'react'import { useCompareStore } from '../stores/compareStore'import { useSettingsStore } from '../stores/settingsStore'@@ -99,7 +100,7 @@ export function useABCompare() {modelWindow: chatBudgetApplies(providerId, settings.contextDecay)? await getModelMaxTokens(m): 0,- sendWindowTokens: settings.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(settings, m),contextDecay: settings.contextDecay,localBackend: sendsToALanBackend(providerId),}diff --git a/src/hooks/useActiveContextWindow.ts b/src/hooks/useActiveContextWindow.tsindex e1f7e0e0..0b392178 100644--- a/src/hooks/useActiveContextWindow.ts+++ b/src/hooks/useActiveContextWindow.ts@@ -6,7 +6,7 @@ import { getModelContextCached } from '../api/ollama'import { getLmStudioModelContext } from '../api/lmstudio'import { getModelMaxTokens } from '../lib/context-compaction'import { effectiveContextWindow } from '../lib/context-window'-import { effectiveSendWindow } from '../lib/send-window'+import { effectiveSendWindow, isPaidProvider, sendWindowFor } from '../lib/send-window'import { isManagedBuiltinSlot } from '../api/builtin-ensure'import { ENGINE_DEFAULT_CTX } from '../lib/builtin-ctx'import { bundledEngineStatus, bundledCtxTrain } from '../api/engine'@@ -111,7 +111,8 @@ export function useActiveContextWindow(reloadTick = 0): ActiveContext {const activeModel = useModelStore((s) => s.activeModel)const override = useSettingsStore((s) => s.settings.contextWindowOverride)const builtinCtx = useSettingsStore((s) => s.settings.builtinEngine.ctx)- const sendWindowTokens = useSettingsStore((s) => s.settings.codexSendWindowTokens)+ const globalSendWindow = useSettingsStore((s) => s.settings.codexSendWindowTokens)+ const cloudPicks = useSettingsStore((s) => s.settings.cloudSendWindowByModel)const capEnabled = useSettingsStore((s) => s.settings.contextDecay)// The resolved window carries the model it was resolved FOR. That tag does// two jobs: the "no model" case becomes a derivation instead of a setState@@ -286,7 +287,7 @@ export function useActiveContextWindow(reloadTick = 0): ActiveContext {sendWindow: effectiveSendWindow({providerId,modelWindow: max,- sendWindowTokens,+ sendWindowTokens: sendWindowFor({ codexSendWindowTokens: globalSendWindow, cloudSendWindowByModel: cloudPicks }, activeModel),capEnabled,// Der Zweig oben kehrt nur um, wenn der eigene Server ein Fenster// GENANNT hat. Sagt er keins, faellt er bis hierher durch, und ohne@@ -294,18 +295,20 @@ export function useActiveContextWindow(reloadTick = 0): ActiveContext {localBackend: sendsToALanBackend(providerId),}),isTrue: false,- // Aus der Ferne ist das Fenster keine Sache des Nutzers: es gehoert- // einer fremden Bereitstellung, und der Sendedeckel ist hier der- // Hebel, der den Nenner regelt.- adjustable: false,+ // The model's own window belongs to the remote deployment, but on a+ // paid provider the send window is the user's lever: how much of the+ // conversation each step sends and pays for. The dropdown sets it per+ // model (settings.cloudSendWindowByModel). A LAN server that fell+ // through to here bills nobody, so there is nothing to choose.+ adjustable: capEnabled !== false && isPaidProvider(providerId, sendsToALanBackend(providerId)),// Woher die Zahl kommt, auch wenn sie hier niemand verstellen kann.source: remoteWindowSource(providerId, cloudResolved?.source, max),- windowKey: '',+ windowKey: activeModel,})})()return () => { cancelled = true }- }, [activeModel, override, builtinCtx, sendWindowTokens, capEnabled, reloadTick, reloadBump])+ }, [activeModel, override, builtinCtx, globalSendWindow, cloudPicks, capEnabled, reloadTick, reloadBump])return activeModel && resolved?.model === activeModel ? resolved.ctx : NO_CONTEXT}diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex fdb05933..b24b8744 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -46,7 +46,7 @@ import { summarizeTurn } from '../lib/turn-summary'import { buildVisionFeedback } from '../api/vision-feedback'import { getModelMaxTokens, estimateTokens } from '../lib/context-compaction'import { buildRequestMessages, trimWorkingHistory } from '../lib/context-decay'-import { effectiveSendWindow } from '../lib/send-window'+import { effectiveSendWindow, sendWindowFor } from '../lib/send-window'import { sendsToALanBackend } from '../lib/lan-openai-slot'import { useSendSizeStore } from '../stores/sendSizeStore'import { resolveAgentNumCtx } from '../lib/agent-num-ctx'@@ -1448,7 +1448,7 @@ export function useAgentChat() {const sendWindow = effectiveSendWindow({providerId,modelWindow: agentCtx,- sendWindowTokens: settings.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(settings, activeModel),capEnabled: decayOn,smallModelMode: settings.smallModelMode,localBackend: sendsToALanBackend(providerId),diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex 8433b1f5..c0b437cf 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -1,4 +1,5 @@import { useState, useCallback } from "react"+import { sendWindowFor } from '../lib/send-window'import { markCannotThink } from '../lib/model-compatibility'import { v4 as uuid } from "uuid"import { useChatStore } from "../stores/chatStore"@@ -125,7 +126,7 @@ async function runGroupTurn(convId: string, model: string, allModels: string[],modelWindow: chatBudgetApplies(providerId, settings.contextDecay)? await getModelMaxTokens(model): 0,- sendWindowTokens: settings.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(settings, model),contextDecay: settings.contextDecay,localBackend: sendsToALanBackend(providerId),},@@ -1009,7 +1010,7 @@ export function useChat() {{providerId,modelWindow: modelWindowTokens,- sendWindowTokens: settings.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(settings, activeModel),contextDecay: settings.contextDecay,// R2-3: der Hauptpfad des einfachen Chats liess dieses Feld weg, also// galt hier die Deckelung fuer bezahlte Anbieter und der eigenediff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex afe98db0..691fdc8c 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -78,7 +78,7 @@ import { toolCallCapMs, raceWithToolTimeout, SHELL_EXECUTE_DEFAULT_TIMEOUT_MS }import { getModelMaxTokens, estimateTokens } from '../lib/context-compaction'import { capToLearnedWindow, contextOverflowOf, learnSendWindow, shrunkSendWindow } from './codex/context-overflow'import { buildRequestMessages, trimWorkingHistory, decayRestoredToolResult, isToolResult } from '../lib/context-decay'-import { effectiveSendWindow } from '../lib/send-window'+import { effectiveSendWindow, sendWindowFor } from '../lib/send-window'import { sendsToALanBackend } from '../lib/lan-openai-slot'import { useSendSizeStore } from '../stores/sendSizeStore'import { resolveAgentNumCtx } from '../lib/agent-num-ctx'@@ -1245,7 +1245,7 @@ export function useCodex() {const sendWindow = capToLearnedWindow(effectiveSendWindow({providerId,modelWindow: numCtx,- sendWindowTokens: settings.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(settings, activeModel),capEnabled: decayOn,smallModelMode: settings.smallModelMode,localBackend: sendsToALanBackend(providerId),diff --git a/src/lib/__tests__/send-window.test.ts b/src/lib/__tests__/send-window.test.tsindex 3da1b69b..b5092791 100644--- a/src/lib/__tests__/send-window.test.ts+++ b/src/lib/__tests__/send-window.test.ts@@ -78,8 +78,8 @@ describe('A2: the paid-provider send cap', () => {})describe('A2: the shipped defaults', () => {- it('ships the cap at 32k and the decay switch on', () => {- expect(DEFAULT_SETTINGS.codexSendWindowTokens).toBe(32000)+ it('ships the cap at 32K and the decay switch on', () => {+ expect(DEFAULT_SETTINGS.codexSendWindowTokens).toBe(32768)expect(DEFAULT_SETTINGS.contextDecay).toBe(true)})})@@ -195,3 +195,13 @@ describe('A2 meter honesty: the tool catalog is part of the request', () => {expect(withCatalog.used - withoutCatalog.used).toBe(1856)})})++describe('sendWindowFor: the per-model pick from the context dropdown', () => {+ it('a pick for this model wins, other models keep the default', async () => {+ const { sendWindowFor } = await import('../send-window')+ const settings = { codexSendWindowTokens: 32768, cloudSendWindowByModel: { 'lu-cloud::Kimi': 131072 } }+ expect(sendWindowFor(settings, 'lu-cloud::Kimi')).toBe(131072)+ expect(sendWindowFor(settings, 'lu-cloud::GLM')).toBe(32768)+ expect(sendWindowFor({ codexSendWindowTokens: 32768 }, 'lu-cloud::Kimi')).toBe(32768)+ })+})diff --git a/src/lib/constants.ts b/src/lib/constants.tsindex 31a8c89b..1345eb1e 100644--- a/src/lib/constants.ts+++ b/src/lib/constants.ts@@ -66,6 +66,7 @@ export const DEFAULT_SETTINGS: Settings = {// default; the switch is the support way back without a rollback release.contextDecay: true,codexSendWindowTokens: DEFAULT_SEND_WINDOW_TOKENS,+ cloudSendWindowByModel: {},// 2.6.8: auto-compact is OFF until someone sets a threshold. 0 is the// switch, not a tuning value — see the field's comment in types/settings.ts.// No STORE_VERSION bump for this key: settingsStore's migrate mergesdiff --git a/src/lib/run-compact-command.ts b/src/lib/run-compact-command.tsindex 44fb6509..f3f1d1f0 100644--- a/src/lib/run-compact-command.ts+++ b/src/lib/run-compact-command.ts@@ -38,7 +38,7 @@ import {import { estimateTokens } from './context-compaction'import { computeContextFill, type FillMessage } from './token-usage'import { shouldAutoCompact, MIN_MESSAGES_SINCE_COMPACT } from './compact-trigger'-import { effectiveSendWindow } from './send-window'+import { effectiveSendWindow, sendWindowFor } from './send-window'import { sendsToALanBackend } from './lan-openai-slot'import { useSendSizeStore } from '../stores/sendSizeStore'import type { CompactionRecord, Message } from '../types/chat'@@ -316,7 +316,7 @@ export async function maybeAutoCompact(opts: {const gekappt = effectiveSendWindow({providerId: anbieter,modelWindow: window,- sendWindowTokens: st.codexSendWindowTokens,+ sendWindowTokens: sendWindowFor(st, opts.activeModel),capEnabled: st.contextDecay !== false,smallModelMode: st.smallModelMode,localBackend: sendsToALanBackend(anbieter),diff --git a/src/lib/send-window.ts b/src/lib/send-window.tsindex e55c49df..01108e0f 100644--- a/src/lib/send-window.ts+++ b/src/lib/send-window.ts@@ -48,7 +48,7 @@ export const PAID_PROVIDER_IDS: ReadonlySet<string> = new Set(['lu-cloud', 'open* decay capping old results and the run ledger keeping the dropped steps* known, 32k carries a coding run at half the price per step.*/-export const DEFAULT_SEND_WINDOW_TOKENS = 32000+export const DEFAULT_SEND_WINDOW_TOKENS = 32768/** The pre-3.0.4 default. No UI ever wrote this setting, so a stored 64000 is* the old default riding along in a profile, not anyone's choice. */@@ -61,6 +61,21 @@ export const WINDOW_SHARE = 0.8export const SMALL_MODEL_SHARE = 0.5export const SMALL_MODEL_CEILING = 6000+/**+ * The send window setting for one model: the user's per-model pick from the+ * context dropdown, else the global default. Every caller of+ * effectiveSendWindow reads it through here, so the counter, the request+ * builder and /compact always agree on the same number.+ */+export function sendWindowFor(+ settings: { codexSendWindowTokens?: number; cloudSendWindowByModel?: Record<string, number> },+ model: string,+): number | undefined {+ const pick = settings.cloudSendWindowByModel?.[model]+ if (typeof pick === 'number' && pick > 0) return Math.floor(pick)+ return settings.codexSendWindowTokens+}+export interface SendWindowInput {/** Provider id of the active model ('lu-cloud', 'ollama', …). */providerId: stringdiff --git a/src/stores/__tests__/send-window-retired-default.test.ts b/src/stores/__tests__/send-window-retired-default.test.tsindex 037c426e..e26b2d1d 100644--- a/src/stores/__tests__/send-window-retired-default.test.ts+++ b/src/stores/__tests__/send-window-retired-default.test.ts@@ -32,7 +32,7 @@ describe('the retired 64k send window', () => {it('a stored 64000 follows the new 32k default', async () => {seed(64000)await useSettingsStore.persist.rehydrate()- expect(useSettingsStore.getState().settings.codexSendWindowTokens).toBe(32000)+ expect(useSettingsStore.getState().settings.codexSendWindowTokens).toBe(32768)})it('a deliberate other value stays', async () => {diff --git a/src/types/settings.ts b/src/types/settings.tsindex 2177b853..10f1a474 100644--- a/src/types/settings.ts+++ b/src/types/settings.ts@@ -189,6 +189,14 @@ export interface Settings {* costs more. Local backends ignore it.*/codexSendWindowTokens: number+ /**+ * Per-model choice of the send window for paid cloud models, keyed by the+ * prefixed model name. Picked in the header's context dropdown; absent+ * means codexSendWindowTokens applies. The model's own window is fixed on a+ * cloud provider, so this is the one context lever there: how much of the+ * conversation each step sends, and pays for.+ */+ cloudSendWindowByModel?: Record<string, number>/*** Auto-compact trigger, as a fraction of the send window. 2.6.8.*