Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ 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 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.

## [1.0.19] - 2026-11-12

### Fixed
Expand Down
81 changes: 46 additions & 35 deletions src/features/chat/ui/toolbar/toolbar-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -419,13 +424,19 @@ export class ModelSelector {
const view = this.container.ownerDocument.defaultView;
if (!view) return;
const anchor = (dropdownEl.offsetParent ?? this.container).getBoundingClientRect();
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.
// 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),
);
dropdownEl.setCssProps({
'--qoderian-model-dropdown-max-height': `${modelDropdownMaxHeight(anchor.top)}px`,
});
// 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');
Expand Down
52 changes: 49 additions & 3 deletions src/qoder/commands/probe-runtime-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'],
Expand Down
23 changes: 16 additions & 7 deletions src/qoder/models/model-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,31 @@ export function createQoderModelPolicyProvider(

const parameters: Record<string, unknown> = {};
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);
// 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;
}
}
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);
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;
}
Expand Down
52 changes: 23 additions & 29 deletions src/style/toolbar/model-selector.css
Original file line number Diff line number Diff line change
Expand Up @@ -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(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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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). */
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/features/chat/ui/input-toolbar.model-selector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading
Loading