fix(coding-agent): prioritize provider matches in model selector

closes #5892
This commit is contained in:
Vegard Stikbakke
2026-06-19 12:25:02 +02:00
parent 47d1d90a8e
commit 373cd6ae52
3 changed files with 16 additions and 2 deletions

View File

@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed `/model` selector search to rank exact provider-prefixed matches before proxy-provider model ID matches ([#5892](https://github.com/earendil-works/pi/issues/5892)).
## [0.79.8] - 2026-06-19
### New Features

View File

@@ -11,7 +11,7 @@ import {
} from "@earendil-works/pi-tui";
import type { ModelRegistry } from "../../../core/model-registry.ts";
import type { SettingsManager } from "../../../core/settings-manager.ts";
import { getModelSearchText } from "../model-search.ts";
import { getModelSelectorSearchText } from "../model-search.ts";
import { theme } from "../theme/theme.ts";
import { DynamicBorder } from "./dynamic-border.ts";
import { keyHint } from "./keybinding-hints.ts";
@@ -219,7 +219,7 @@ export class ModelSelectorComponent extends Container implements Focusable {
private filterModels(query: string): void {
this.filteredModels = query
? fuzzyFilter(this.activeModels, query, ({ id, provider, model }) =>
getModelSearchText({ id, provider, name: model.name }),
getModelSelectorSearchText({ id, provider, name: model.name }),
)
: this.activeModels;
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredModels.length - 1));

View File

@@ -9,3 +9,13 @@ export function getModelSearchText(item: ModelSearchItem): string {
const name = item.name ? ` ${item.name}` : "";
return `${id} ${provider} ${provider}/${id} ${provider} ${id}${name}`;
}
/**
* The /model selector search should rank exact provider-prefixed queries before proxy-provider IDs
* like openrouter/openai/gpt-5, so keep the bare model ID out of the leading position.
*/
export function getModelSelectorSearchText(item: ModelSearchItem): string {
const { id, provider } = item;
const name = item.name ? ` ${item.name}` : "";
return `${provider} ${provider}/${id} ${provider} ${id}${name}`;
}