From 0dafc7997cd2c8ca8a87ac3f7c40c49ba33b33cd Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Thu, 26 Nov 2026 09:05:53 +0800 Subject: [PATCH 1/5] fix(qoder): map flat daemon catalog fields for the per-model editor The daemon catalog replaced context_config/thinking_config with flat availableContextWindows/efforts fields, leaving the editor without tiers or efforts and hiding its entry point. Map the flat shapes as a fallback so the pencil editor returns while old servers keep working. Co-authored-by: QoderAI (Qwen 3.8 Max) --- src/qoder/commands/probe-runtime-commands.ts | 52 +++++++++++++++++-- .../commands/probe-runtime-commands.test.ts | 48 +++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/src/qoder/commands/probe-runtime-commands.ts b/src/qoder/commands/probe-runtime-commands.ts index 4f5f84d..e1882ad 100644 --- a/src/qoder/commands/probe-runtime-commands.ts +++ b/src/qoder/commands/probe-runtime-commands.ts @@ -95,8 +95,10 @@ function mapSdkModels(models: ModelInfo[]): QoderDiscoveredModel[] { if (!value || model.isEnabled === false) return []; const group = resolveSdkModelGroup(model); const promotion = mapSdkPromotion(model); - const contextTiers = mapContextTiers(model.context_config); - const thinkingEfforts = mapThinkingEfforts(model.thinking_config); + const contextTiers = mapContextTiers(model.context_config) + ?? mapFlatContextWindows(model.availableContextWindows, model.defaultContextWindow); + const thinkingEfforts = mapThinkingEfforts(model.thinking_config) + ?? mapFlatEfforts(model.efforts, model.defaultEffort); return [{ value, displayName: model.displayName?.trim() || value, @@ -108,12 +110,56 @@ function mapSdkModels(models: ModelInfo[]): QoderDiscoveredModel[] { : {}), ...(promotion ? { promotion } : {}), ...(contextTiers ? { contextTiers } : {}), - ...(model.thinking_config?.disabled !== undefined ? { thinkingDisableable: true } : {}), + ...(model.thinking_config?.disabled !== undefined || model.supportsDisabled === true + ? { thinkingDisableable: true } + : {}), ...(thinkingEfforts ? { thinkingEfforts } : {}), }]; }); } +/** Daemon catalog `availableContextWindows` into editor tiers. */ +function mapFlatContextWindows( + windows: number[] | undefined, + defaultWindow: number | undefined, +): QoderDiscoveredModel['contextTiers'] { + if (!windows) return undefined; + const tiers = windows.flatMap((tokenCount) => { + if (typeof tokenCount !== 'number' || !isFinite(tokenCount) || tokenCount <= 0) return []; + return [{ + label: formatTokenCountLabel(tokenCount), + tokenCount, + isDefault: tokenCount === defaultWindow, + }]; + }); + tiers.sort((a, b) => a.tokenCount - b.tokenCount); + return tiers.length > 0 ? tiers : undefined; +} + +function formatTokenCountLabel(tokenCount: number): string { + if (tokenCount >= 1_000_000 && tokenCount % 1_000_000 === 0) { + return `${tokenCount / 1_000_000}M`; + } + if (tokenCount >= 1_000 && tokenCount % 1_000 === 0) { + return `${tokenCount / 1_000}K`; + } + return String(tokenCount); +} + +/** Daemon catalog `efforts` into editor intensity choices. */ +function mapFlatEfforts( + efforts: string[] | undefined, + defaultEffort: string | undefined, +): QoderDiscoveredModel['thinkingEfforts'] { + if (!efforts) return undefined; + const mapped = efforts.flatMap((value) => { + const trimmed = value.trim(); + if (!trimmed) return []; + return [{ value: trimmed, isDefault: trimmed === defaultEffort }]; + }); + return mapped.length > 0 ? sortThinkingEfforts(mapped) : undefined; +} + /** Server `thinking_config.enabled.efforts` into editor intensity choices. */ function mapThinkingEfforts( config: ModelInfo['thinking_config'], diff --git a/tests/unit/qoder/commands/probe-runtime-commands.test.ts b/tests/unit/qoder/commands/probe-runtime-commands.test.ts index e24f84d..d053bbc 100644 --- a/tests/unit/qoder/commands/probe-runtime-commands.test.ts +++ b/tests/unit/qoder/commands/probe-runtime-commands.test.ts @@ -312,6 +312,54 @@ describe('probeRuntimeCatalog', () => { ]); }); + it('maps flat daemon catalog fields for the per-model editor', async () => { + setInitMessage(); + sdkMock.setMockAvailableModels([ + { + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + availableContextWindows: [400000, 200000, 1000000, -1], + defaultContextWindow: 200000, + efforts: ['xhigh', 'low', 'medium'], + defaultEffort: 'medium', + supportsDisabled: true, + }, + { + value: 'flat-minimal', + displayName: 'Flat minimal', + description: '', + efforts: ['high'], + }, + ]); + + const result = await probeRuntimeCatalog(createMockPlugin()); + expectSuccessfulProbe(result); + + expect(result.models[0]).toEqual({ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + group: 'Qoder', + contextTiers: [ + { label: '200K', tokenCount: 200000, isDefault: true }, + { label: '400K', tokenCount: 400000, isDefault: false }, + { label: '1M', tokenCount: 1000000, isDefault: false }, + ], + thinkingDisableable: true, + thinkingEfforts: [ + { value: 'low', isDefault: false }, + { value: 'medium', isDefault: true }, + { value: 'xhigh', isDefault: false }, + ], + }); + expect(result.models[1]).not.toHaveProperty('thinkingDisableable'); + expect(result.models[1]).not.toHaveProperty('contextTiers'); + expect(result.models[1]).toHaveProperty('thinkingEfforts', [ + { value: 'high', isDefault: false }, + ]); + }); + it('uses initialization pricing when a live catalog refresh returns empty', async () => { setInitMessage(); sdkMock.setMockAvailableModels([]); From b2a4f07612e14d44e4c797c7c86615df3e32bc50 Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Thu, 26 Nov 2026 09:05:53 +0800 Subject: [PATCH 2/5] fix(chat): keep model dropdown width stable and inside narrow panes Hovering a row revealed the edit affordance in flow, widening the content-sized dropdown whenever the longest row was hovered. Stack meta and the affordance in one trailing grid slot so swapping them never resizes the row, and cap the list by its anchor width so narrow sidebars ellipsize instead of clipping at the leaf edge. Co-authored-by: QoderAI (Qwen 3.8 Max) --- .../chat/ui/toolbar/toolbar-selectors.ts | 72 ++++++++++--------- src/style/toolbar/model-selector.css | 52 ++++++-------- 2 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/features/chat/ui/toolbar/toolbar-selectors.ts b/src/features/chat/ui/toolbar/toolbar-selectors.ts index 2a44675..a771c0a 100644 --- a/src/features/chat/ui/toolbar/toolbar-selectors.ts +++ b/src/features/chat/ui/toolbar/toolbar-selectors.ts @@ -257,42 +257,47 @@ export class ModelSelector { width: 12, })); option.createSpan({ cls: 'qoderian-model-option-label', text: model.label }); - if (model.promotionLabel || model.priceLabel) { - const meta = option.createSpan({ cls: 'qoderian-model-meta' }); - if (model.promotionLabel) { - meta.createSpan({ cls: 'qoderian-model-promo', text: model.promotionLabel }); - } - if (model.priceLabel) { - meta.createSpan({ cls: 'qoderian-model-price', text: model.priceLabel }); - } - } const editable = ((model.contextTiers?.length ?? 0) > 0 || (model.thinkingEfforts?.length ?? 0) > 0 || model.thinkingDisableable === true) && this.callbacks.onModelOverrideChange !== undefined; - if (editable) { - const editEl = option.createDiv({ cls: 'qoderian-model-edit' }); - editEl.setAttribute('role', 'button'); - editEl.setAttribute('tabindex', '0'); - editEl.setAttribute('aria-label', `${t('model.edit')} ${model.label}`); - editEl.appendChild(createIconSvg(PENCIL_ICON, { - className: 'qoderian-model-edit-icon', - height: 11, - ownerDocument: option.ownerDocument, - width: 11, - })); - editEl.createSpan({ cls: 'qoderian-model-edit-label', text: t('model.edit') }); - const enterEditing = (event: Event) => { - event.stopPropagation(); - this.editingModel = model.value; - this.renderOptions(); - }; - editEl.addEventListener('click', enterEditing); - editEl.addEventListener('keydown', (event) => { - if (event.key !== 'Enter' && event.key !== ' ') return; - event.preventDefault(); - enterEditing(event); - }); + // Meta and the edit affordance share one trailing slot so swapping them + // on hover never changes the row's width. + if (model.promotionLabel || model.priceLabel || editable) { + const trailing = option.createDiv({ cls: 'qoderian-model-trailing' }); + if (model.promotionLabel || model.priceLabel) { + const meta = trailing.createSpan({ cls: 'qoderian-model-meta' }); + if (model.promotionLabel) { + meta.createSpan({ cls: 'qoderian-model-promo', text: model.promotionLabel }); + } + if (model.priceLabel) { + meta.createSpan({ cls: 'qoderian-model-price', text: model.priceLabel }); + } + } + if (editable) { + const editEl = trailing.createDiv({ cls: 'qoderian-model-edit' }); + editEl.setAttribute('role', 'button'); + editEl.setAttribute('tabindex', '0'); + editEl.setAttribute('aria-label', `${t('model.edit')} ${model.label}`); + editEl.appendChild(createIconSvg(PENCIL_ICON, { + className: 'qoderian-model-edit-icon', + height: 11, + ownerDocument: option.ownerDocument, + width: 11, + })); + editEl.createSpan({ cls: 'qoderian-model-edit-label', text: t('model.edit') }); + const enterEditing = (event: Event) => { + event.stopPropagation(); + this.editingModel = model.value; + this.renderOptions(); + }; + editEl.addEventListener('click', enterEditing); + editEl.addEventListener('keydown', (event) => { + if (event.key !== 'Enter' && event.key !== ' ') return; + event.preventDefault(); + enterEditing(event); + }); + } } if (model.description) option.setAttribute('title', model.description); @@ -425,6 +430,9 @@ export class ModelSelector { ); dropdownEl.setCssProps({ '--qoderian-model-dropdown-max-height': `${modelDropdownMaxHeight(anchor.top)}px`, + // Keep the list inside the surrounding pane (e.g. a narrow sidebar); + // viewport-based caps alone let it overflow and clip at the leaf edge. + '--qoderian-model-list-max-width': `${Math.max(0, Math.floor(anchor.width))}px`, }); // Anchor the compact editor card to its edited row, IDE flyout style. if (this.editingModel !== null && this.listPaneEl && this.editorPaneEl) { diff --git a/src/style/toolbar/model-selector.css b/src/style/toolbar/model-selector.css index 7c07fae..75bffd2 100644 --- a/src/style/toolbar/model-selector.css +++ b/src/style/toolbar/model-selector.css @@ -64,7 +64,9 @@ min-height: 0; flex: 0 1 auto; overflow-y: auto; - max-width: min(340px, calc(100vw - 24px)); + /* Hug the content, capped by the surrounding pane (set from the anchor + width) so narrow sidebars ellipsize instead of overflowing. */ + max-width: min(var(--qoderian-model-list-max-width, 340px), calc(100vw - 24px)); /* Measured by updateDropdownPlacement(); fallback matches the repo-wide popover height convention. */ max-height: var(--qoderian-model-dropdown-max-height, 420px); @@ -251,13 +253,26 @@ font-weight: 500; } -/* Credit multiplier and promotion badge trail the row like the Qoder IDE. */ +/* Credit multiplier and promotion badge trail the row like the Qoder IDE. + Meta and the edit affordance stack in one grid cell: the slot sizes to the + wider of the two, so hovering swaps them without resizing the row. */ +.qoderian-model-trailing { + display: grid; + align-items: center; + justify-items: end; + margin-left: auto; + padding-left: 12px; + flex-shrink: 0; +} + +.qoderian-model-trailing > * { + grid-area: 1 / 1; +} + .qoderian-model-meta { display: flex; align-items: center; gap: 5px; - margin-left: auto; - padding-left: 12px; flex-shrink: 0; } @@ -274,18 +289,14 @@ font-size: 10px; } -/* Per-model edit affordance: collapsed and invisible until the row is hovered - (or the affordance is focused via keyboard / the row is being edited); the - label expands on hover/edit like the IDE. */ +/* Per-model edit affordance: invisible until the row is hovered (or the + affordance is focused via keyboard / the row is being edited). It keeps its + layout space while hidden so the dropdown width never jumps on hover. */ .qoderian-model-edit { display: flex; align-items: center; gap: 4px; - margin-inline-start: 0; - padding-left: 0; flex-shrink: 0; - width: 0; - overflow: hidden; color: var(--text-muted); border-radius: 3px; opacity: 0; @@ -296,8 +307,6 @@ .qoderian-model-option:hover .qoderian-model-edit, .qoderian-model-option.editing .qoderian-model-edit, .qoderian-model-edit:focus-visible { - width: auto; - overflow: visible; opacity: 1; pointer-events: auto; } @@ -309,27 +318,12 @@ } .qoderian-model-edit-label { - display: none; font-size: 11px; } -/* When the meta slot is hidden the edit affordance takes the trailing slot. */ -.qoderian-model-option:hover .qoderian-model-edit, -.qoderian-model-option.editing .qoderian-model-edit, -.qoderian-model-edit:focus-visible { - margin-inline-start: auto; - padding-left: 12px; -} - -.qoderian-model-option:hover .qoderian-model-edit-label, -.qoderian-model-option.editing .qoderian-model-edit-label, -.qoderian-model-edit:focus-visible .qoderian-model-edit-label { - display: inline; -} - .qoderian-model-option:hover .qoderian-model-meta, .qoderian-model-option.editing .qoderian-model-meta { - display: none; + visibility: hidden; } /* Per-model editor view (context window tiers + thinking toggle). */ From 8b48f4ed9085fae42964dfe45e3ffda5b4154858 Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Thu, 26 Nov 2026 09:06:42 +0800 Subject: [PATCH 3/5] docs: changelog the model editor and dropdown width fixes Co-authored-by: QoderAI (Qwen 3.8 Max) --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c76a4..cba5d1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ version with its date and start a fresh empty `[Unreleased]` above it. ## [Unreleased] +### Fixed + +- The per-model editor (context window tiers and thinking effort) disappeared + from the model selector after the CLI daemon upgrade: the catalog now + arrives in a flat field shape the plugin did not read, so the edit entry + hid itself. Both shapes are mapped again. +- The model dropdown no longer jumps wider when hovering a row, and no longer + overflows and clips inside narrow sidebars. + ## [1.0.19] - 2026-11-12 ### Fixed From 183a2205ff3ff7475efde2e0aa6a467afed8f85e Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Thu, 26 Nov 2026 09:11:17 +0800 Subject: [PATCH 4/5] fix(qoder): honor flat daemon catalog flags in the per-request model policy The resolveModel provider validated editor overrides against the legacy context_config/thinking_config blocks. Daemon catalogs carry flat fields instead, so a live entry without thinking_config silently dropped the disable-thinking override. Read the flat flags and window/effort lists with the same rich-first fallback the probe uses. Co-authored-by: QoderAI (Qwen 3.8 Max) --- CHANGELOG.md | 3 + src/qoder/models/model-policy.ts | 6 +- tests/unit/qoder/models/model-policy.test.ts | 78 ++++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cba5d1e..27d7788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ version with its date and start a fresh empty `[Unreleased]` above it. from the model selector after the CLI daemon upgrade: the catalog now arrives in a flat field shape the plugin did not read, so the edit entry hid itself. Both shapes are mapped again. +- The editor's "disable thinking" switch had no effect against the daemon + catalog: the per-request model policy only recognized the legacy + thinking_config block. Flat catalog flags are honored again. - The model dropdown no longer jumps wider when hovering a row, and no longer overflows and clips inside narrow sidebars. diff --git a/src/qoder/models/model-policy.ts b/src/qoder/models/model-policy.ts index b14e857..39ab80e 100644 --- a/src/qoder/models/model-policy.ts +++ b/src/qoder/models/model-policy.ts @@ -35,20 +35,20 @@ export function createQoderModelPolicyProvider( if (override.contextWindow !== undefined) { const knownWindows = live?.context_config ? Object.values(live.context_config).map(entry => entry.token_count) - : discovered?.contextTiers?.map(tier => tier.tokenCount); + : live?.availableContextWindows ?? discovered?.contextTiers?.map(tier => tier.tokenCount); if (!knownWindows || knownWindows.includes(override.contextWindow)) { parameters.contextWindow = override.contextWindow; } } const canDisableThinking = live - ? live.thinking_config?.disabled !== undefined + ? live.thinking_config?.disabled !== undefined || live.supportsDisabled === true : discovered?.thinkingDisableable === true; if (override.thinkingEnabled === false && canDisableThinking) { parameters.reasoningEffort = 'none'; } else if (override.thinkingEffort !== undefined) { const knownEfforts = live?.thinking_config?.enabled?.efforts ? Object.keys(live.thinking_config.enabled.efforts) - : discovered?.thinkingEfforts?.map(effort => effort.value); + : live?.efforts ?? discovered?.thinkingEfforts?.map(effort => effort.value); if (!knownEfforts || knownEfforts.includes(override.thinkingEffort)) { parameters.reasoningEffort = override.thinkingEffort; } diff --git a/tests/unit/qoder/models/model-policy.test.ts b/tests/unit/qoder/models/model-policy.test.ts index b7aa487..d8440ff 100644 --- a/tests/unit/qoder/models/model-policy.test.ts +++ b/tests/unit/qoder/models/model-policy.test.ts @@ -112,6 +112,32 @@ describe('createQoderModelPolicyProvider', () => { // The live catalog no longer offers 400K, so the override is withheld. expect(provider(liveOnly200K)).toEqual({ model: 'qmodel_38max' }); }); + + it('validates contextWindow against flat live context windows', () => { + const settings = settingsWith( + { qmodel_38max: { contextWindow: 400000 } }, + [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + contextTiers: [{ label: '200K', tokenCount: 200000, isDefault: true }], + }], + ); + const provider = createQoderModelPolicyProvider(() => 'qmodel_38max', settings); + const live = createContext({ + availableModels: [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + availableContextWindows: [200000, 400000], + }] as ModelPolicyContext['availableModels'], + }); + + expect(provider(live)).toEqual({ + model: 'qmodel_38max', + parameters: { contextWindow: 400000 }, + }); + }); }); describe('thinking override', () => { @@ -167,6 +193,32 @@ describe('createQoderModelPolicyProvider', () => { expect(provider(live)).toEqual({ model: 'qmodel_38max' }); }); + it('honors the flat supportsDisabled flag when thinking_config is absent', () => { + const settings = settingsWith( + { qmodel_38max: { thinkingEnabled: false } }, + [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + thinkingDisableable: true, + }], + ); + const provider = createQoderModelPolicyProvider(() => 'qmodel_38max', settings); + const live = createContext({ + availableModels: [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + supportsDisabled: true, + }] as ModelPolicyContext['availableModels'], + }); + + expect(provider(live)).toEqual({ + model: 'qmodel_38max', + parameters: { reasoningEffort: 'none' }, + }); + }); + it('does not emit reasoningEffort when thinking stays enabled', () => { const settings = settingsWith( { qmodel_38max: { thinkingEnabled: true } }, @@ -249,6 +301,32 @@ describe('createQoderModelPolicyProvider', () => { expect(provider(live)).toEqual({ model: 'qmodel_38max' }); }); + it('validates thinkingEffort against flat live efforts', () => { + const settings = settingsWith( + { qmodel_38max: { thinkingEffort: 'xhigh' } }, + [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + thinkingEfforts: [{ value: 'low', isDefault: true }], + }], + ); + const provider = createQoderModelPolicyProvider(() => 'qmodel_38max', settings); + const live = createContext({ + availableModels: [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + efforts: ['low', 'xhigh'], + }] as ModelPolicyContext['availableModels'], + }); + + expect(provider(live)).toEqual({ + model: 'qmodel_38max', + parameters: { reasoningEffort: 'xhigh' }, + }); + }); + it('prefers disabling thinking over a stored effort', () => { const settings = settingsWith( { qmodel_38max: { thinkingEnabled: false, thinkingEffort: 'low' } }, From 4b6e01d86215fcc32dc904bdd5f80205b91cddd7 Mon Sep 17 00:00:00 2001 From: liuxuezhuo Date: Thu, 26 Nov 2026 09:22:47 +0800 Subject: [PATCH 5/5] fix(chat): harden the model dropdown width cap and policy fallbacks Review follow-ups: skip the anchor-width cap when the anchor measures zero (hidden view) instead of collapsing the list, keep the 340px ceiling in wide panes, and apply the cap before measuring for the flip decision. Treat empty rich catalog blocks as absent in the model policy, matching the probe, and cover the trailing slot and width cap with unit tests. Co-authored-by: QoderAI (Qwen 3.8 Max) --- .../chat/ui/toolbar/toolbar-selectors.ts | 13 +++-- src/qoder/models/model-policy.ts | 21 +++++--- src/style/toolbar/model-selector.css | 2 +- .../ui/input-toolbar.model-selector.test.ts | 39 ++++++++++++++ tests/unit/qoder/models/model-policy.test.ts | 54 +++++++++++++++++++ 5 files changed, 117 insertions(+), 12 deletions(-) diff --git a/src/features/chat/ui/toolbar/toolbar-selectors.ts b/src/features/chat/ui/toolbar/toolbar-selectors.ts index a771c0a..a222528 100644 --- a/src/features/chat/ui/toolbar/toolbar-selectors.ts +++ b/src/features/chat/ui/toolbar/toolbar-selectors.ts @@ -424,16 +424,19 @@ export class ModelSelector { const view = this.container.ownerDocument.defaultView; if (!view) return; const anchor = (dropdownEl.offsetParent ?? this.container).getBoundingClientRect(); - dropdownEl.toggleClass( - 'qoderian-model-dropdown--flip', - shouldFlipModelDropdown(anchor, dropdownEl.offsetWidth, view.innerWidth), - ); + const listMaxWidth = Math.floor(anchor.width); dropdownEl.setCssProps({ '--qoderian-model-dropdown-max-height': `${modelDropdownMaxHeight(anchor.top)}px`, // Keep the list inside the surrounding pane (e.g. a narrow sidebar); // viewport-based caps alone let it overflow and clip at the leaf edge. - '--qoderian-model-list-max-width': `${Math.max(0, Math.floor(anchor.width))}px`, + // A zero-width anchor (hidden or unlayouted view) must not collapse it. + ...(listMaxWidth > 0 ? { '--qoderian-model-list-max-width': `${listMaxWidth}px` } : {}), }); + // Measure after the cap applies so the flip decision sees the real width. + dropdownEl.toggleClass( + 'qoderian-model-dropdown--flip', + shouldFlipModelDropdown(anchor, dropdownEl.offsetWidth, view.innerWidth), + ); // Anchor the compact editor card to its edited row, IDE flyout style. if (this.editingModel !== null && this.listPaneEl && this.editorPaneEl) { const rowEl = this.listPaneEl.querySelector('.qoderian-model-option.editing'); diff --git a/src/qoder/models/model-policy.ts b/src/qoder/models/model-policy.ts index 39ab80e..4582740 100644 --- a/src/qoder/models/model-policy.ts +++ b/src/qoder/models/model-policy.ts @@ -33,9 +33,14 @@ export function createQoderModelPolicyProvider( const parameters: Record = {}; if (override.contextWindow !== undefined) { - const knownWindows = live?.context_config - ? Object.values(live.context_config).map(entry => entry.token_count) - : live?.availableContextWindows ?? discovered?.contextTiers?.map(tier => tier.tokenCount); + // Empty rich blocks count as absent, mirroring the probe's mapping. + const liveConfig = live?.context_config; + const liveWindows = liveConfig && Object.keys(liveConfig).length > 0 + ? Object.values(liveConfig).map(entry => entry.token_count) + : undefined; + const knownWindows = liveWindows + ?? live?.availableContextWindows + ?? discovered?.contextTiers?.map(tier => tier.tokenCount); if (!knownWindows || knownWindows.includes(override.contextWindow)) { parameters.contextWindow = override.contextWindow; } @@ -46,9 +51,13 @@ export function createQoderModelPolicyProvider( if (override.thinkingEnabled === false && canDisableThinking) { parameters.reasoningEffort = 'none'; } else if (override.thinkingEffort !== undefined) { - const knownEfforts = live?.thinking_config?.enabled?.efforts - ? Object.keys(live.thinking_config.enabled.efforts) - : live?.efforts ?? discovered?.thinkingEfforts?.map(effort => effort.value); + const liveEffortMap = live?.thinking_config?.enabled?.efforts; + const liveEfforts = liveEffortMap && Object.keys(liveEffortMap).length > 0 + ? Object.keys(liveEffortMap) + : undefined; + const knownEfforts = liveEfforts + ?? live?.efforts + ?? discovered?.thinkingEfforts?.map(effort => effort.value); if (!knownEfforts || knownEfforts.includes(override.thinkingEffort)) { parameters.reasoningEffort = override.thinkingEffort; } diff --git a/src/style/toolbar/model-selector.css b/src/style/toolbar/model-selector.css index 75bffd2..6279268 100644 --- a/src/style/toolbar/model-selector.css +++ b/src/style/toolbar/model-selector.css @@ -66,7 +66,7 @@ overflow-y: auto; /* Hug the content, capped by the surrounding pane (set from the anchor width) so narrow sidebars ellipsize instead of overflowing. */ - max-width: min(var(--qoderian-model-list-max-width, 340px), calc(100vw - 24px)); + max-width: min(340px, var(--qoderian-model-list-max-width, 340px), calc(100vw - 24px)); /* Measured by updateDropdownPlacement(); fallback matches the repo-wide popover height convention. */ max-height: var(--qoderian-model-dropdown-max-height, 420px); diff --git a/tests/unit/features/chat/ui/input-toolbar.model-selector.test.ts b/tests/unit/features/chat/ui/input-toolbar.model-selector.test.ts index ee0c4f0..38cb844 100644 --- a/tests/unit/features/chat/ui/input-toolbar.model-selector.test.ts +++ b/tests/unit/features/chat/ui/input-toolbar.model-selector.test.ts @@ -329,6 +329,45 @@ describe('ModelSelector', () => { expect(parentEl.querySelectorAll('.qoderian-model-edit')).toHaveLength(0); }); + it('stacks meta and the edit affordance in one trailing slot', () => { + const parentEl = createMockEl(); + new ModelSelector(parentEl, { + onModelChange: jest.fn().mockResolvedValue(undefined), + onPermissionModeChange: jest.fn().mockResolvedValue(undefined), + onModelOverrideChange: jest.fn().mockResolvedValue(undefined), + getSettings: jest.fn().mockReturnValue({ model: 'qmodel', permissionMode: 'auto' }), + getModelConfig: jest.fn().mockReturnValue({ + getModelOptions: jest.fn().mockReturnValue([{ + value: 'qmodel', + label: 'Qwen 3.8 Max', + group: 'Qoder', + priceLabel: '0.5x', + contextTiers: [{ label: '200K', tokenCount: 200000, isDefault: true }], + }]), + }), + }); + + const trailing = parentEl.querySelector('.qoderian-model-trailing'); + expect(trailing?.querySelector('.qoderian-model-meta')).toBeTruthy(); + expect(trailing?.querySelector('.qoderian-model-edit')).toBeTruthy(); + }); + + it('caps the list by the anchor width and ignores zero-width anchors', () => { + const parentEl = createMockEl(); + new ModelSelector(parentEl, buildCallbacks({ + onModelOverrideChange: jest.fn().mockResolvedValue(undefined), + })); + const dropdown = parentEl.querySelector('.qoderian-model-dropdown'); + expect(dropdown?.style['--qoderian-model-list-max-width']).toBeUndefined(); + + parentEl.querySelector('.qoderian-model-selector')!.getBoundingClientRect = () => ({ + top: 0, left: 0, width: 300, height: 600, right: 300, bottom: 600, x: 0, y: 0, toJSON() {}, + }); + parentEl.querySelector('.qoderian-model-btn')?.click(); + + expect(dropdown?.style['--qoderian-model-list-max-width']).toBe('300px'); + }); + it('opens the editor view with tiers, default tag, and thinking toggle', () => { const parentEl = createMockEl(); new ModelSelector(parentEl, buildCallbacks({ diff --git a/tests/unit/qoder/models/model-policy.test.ts b/tests/unit/qoder/models/model-policy.test.ts index d8440ff..e01a213 100644 --- a/tests/unit/qoder/models/model-policy.test.ts +++ b/tests/unit/qoder/models/model-policy.test.ts @@ -138,6 +138,33 @@ describe('createQoderModelPolicyProvider', () => { parameters: { contextWindow: 400000 }, }); }); + + it('treats an empty live context_config as absent', () => { + const settings = settingsWith( + { qmodel_38max: { contextWindow: 400000 } }, + [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + contextTiers: [{ label: '200K', tokenCount: 200000, isDefault: true }], + }], + ); + const provider = createQoderModelPolicyProvider(() => 'qmodel_38max', settings); + const live = createContext({ + availableModels: [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + context_config: {}, + availableContextWindows: [200000, 400000], + }] as ModelPolicyContext['availableModels'], + }); + + expect(provider(live)).toEqual({ + model: 'qmodel_38max', + parameters: { contextWindow: 400000 }, + }); + }); }); describe('thinking override', () => { @@ -327,6 +354,33 @@ describe('createQoderModelPolicyProvider', () => { }); }); + it('treats an empty live efforts map as absent', () => { + const settings = settingsWith( + { qmodel_38max: { thinkingEffort: 'xhigh' } }, + [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + thinkingEfforts: [{ value: 'low', isDefault: true }], + }], + ); + const provider = createQoderModelPolicyProvider(() => 'qmodel_38max', settings); + const live = createContext({ + availableModels: [{ + value: 'qmodel_38max', + displayName: 'Qwen 3.8 Max', + description: '', + thinking_config: { enabled: { efforts: {} } }, + efforts: ['low', 'xhigh'], + }] as ModelPolicyContext['availableModels'], + }); + + expect(provider(live)).toEqual({ + model: 'qmodel_38max', + parameters: { reasoningEffort: 'xhigh' }, + }); + }); + it('prefers disabling thinking over a stored effort', () => { const settings = settingsWith( { qmodel_38max: { thinkingEnabled: false, thinkingEffort: 'low' } },