mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(settings-selector): nit ordering in default t.l. per model
This commit is contained in:
parent
768184923a
commit
cffe4d776c
3 changed files with 12 additions and 5 deletions
|
|
@ -224,12 +224,16 @@ export class ModelSelectorComponent extends Container implements Focusable {
|
|||
|
||||
private sortModels(models: ModelItem[]): ModelItem[] {
|
||||
const sorted = [...models];
|
||||
// Sort: current model first, then by provider
|
||||
// Sort: current model first, default model second, then by provider.
|
||||
sorted.sort((a, b) => {
|
||||
const aIsCurrent = modelsAreEqual(this.currentModel, a.model);
|
||||
const bIsCurrent = modelsAreEqual(this.currentModel, b.model);
|
||||
if (aIsCurrent && !bIsCurrent) return -1;
|
||||
if (!aIsCurrent && bIsCurrent) return 1;
|
||||
const aIsDefault = this.isDefaultModel(a.model);
|
||||
const bIsDefault = this.isDefaultModel(b.model);
|
||||
if (aIsDefault && !bIsDefault) return -1;
|
||||
if (!aIsDefault && bIsDefault) return 1;
|
||||
return a.provider.localeCompare(b.provider);
|
||||
});
|
||||
return sorted;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const DEFAULT_PROJECT_TRUST_BY_LABEL = new Map(
|
|||
export interface SettingsConfig {
|
||||
autoCompact: boolean;
|
||||
defaultModel: string;
|
||||
currentModel?: Model<any>;
|
||||
availableDefaultModels: readonly Model<any>[];
|
||||
showImages: boolean;
|
||||
imageWidthCells: number;
|
||||
|
|
@ -449,6 +450,7 @@ export class SettingsSelectorComponent extends Container {
|
|||
config.availableDefaultModels.map((model) => [modelSettingKey(model), model]),
|
||||
);
|
||||
const currentDefaultModelKey = defaultModelByValue.has(config.defaultModel) ? config.defaultModel : undefined;
|
||||
const currentModelKey = config.currentModel ? modelSettingKey(config.currentModel) : undefined;
|
||||
|
||||
const items: SettingItem[] = [
|
||||
{
|
||||
|
|
@ -581,11 +583,11 @@ export class SettingsSelectorComponent extends Container {
|
|||
const sorted = [...config.availableDefaultModels].sort((a, b) => {
|
||||
const aKey = modelSettingKey(a);
|
||||
const bKey = modelSettingKey(b);
|
||||
if (aKey === currentModelKey) return -1;
|
||||
if (bKey === currentModelKey) return 1;
|
||||
if (aKey === currentDefaultModelKey) return -1;
|
||||
if (bKey === currentDefaultModelKey) return 1;
|
||||
const pc = a.provider.localeCompare(b.provider);
|
||||
if (pc !== 0) return pc;
|
||||
return (a.name || a.id).localeCompare(b.name || b.id);
|
||||
return a.provider.localeCompare(b.provider);
|
||||
});
|
||||
const items: SelectItem[] = sorted.map((model) => {
|
||||
const key = modelSettingKey(model);
|
||||
|
|
@ -605,7 +607,7 @@ export class SettingsSelectorComponent extends Container {
|
|||
}
|
||||
return items;
|
||||
},
|
||||
preselect: () => currentDefaultModelKey,
|
||||
preselect: () => currentModelKey ?? currentDefaultModelKey,
|
||||
searchable: true,
|
||||
layout: MODEL_PICKER_LAYOUT,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4523,6 +4523,7 @@ export class InteractiveMode {
|
|||
{
|
||||
autoCompact: this.session.autoCompactionEnabled,
|
||||
defaultModel,
|
||||
currentModel: this.session.model,
|
||||
availableDefaultModels: this.session.modelRuntime.getAvailableSnapshot(),
|
||||
showImages: this.settingsManager.getShowImages(),
|
||||
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue