@@ -287,10 +287,8 @@ const FULL_CATALOG_DRIVERS: ReadonlySet<string> = new Set(["codex", "claudeAgent
287287const LISTED_MODEL_LIMIT = 8 ;
288288
289289/**
290- * Picks the models orchestrator_capabilities shows for one provider. Hidden models never
291- * appear. Search words naming the provider are dropped; other words list matches. With no
292- * words left, lists pinned models (custom, favorite, the caller's own) plus non-legacy
293- * models, or only the first few in the user's model order for large catalogs.
290+ * Lists visible models, keeping pinned models and limiting large catalogs by default.
291+ * Whole provider words select the provider; partial words filter models when any match.
294292 */
295293function listCapabilityModels ( input : {
296294 readonly provider : ServerProvider ;
@@ -306,10 +304,22 @@ function listCapabilityModels(input: {
306304 . toSorted ( ( a , b ) => ( rank . get ( a . slug ) ?? rank . size ) - ( rank . get ( b . slug ) ?? rank . size ) ) ;
307305 const { instanceId, driver, displayName } = input . provider ;
308306 const providerText = `${ instanceId } ${ driver } ${ displayName ?? "" } ` . toLowerCase ( ) ;
309- const modelTerms = input . searchTerms . filter ( ( term ) => ! providerText . includes ( term ) ) ;
307+ // Whole ids like "codex-work" and their parts both name the provider.
308+ const providerWords = new Set ( [
309+ ...providerText . split ( / \s + / ) ,
310+ ...providerText . split ( / [ ^ \p{ L} \p{ N} ] + / u) ,
311+ ] ) ;
312+ const modelText = ( model : ServerProviderModel ) =>
313+ `${ model . slug } ${ model . name } ${ model . subProvider ?? "" } ` . toLowerCase ( ) ;
314+ // Part of a provider word ("agent" in "claudeAgent") names the provider unless a model matches it.
315+ const modelTerms = input . searchTerms . filter (
316+ ( term ) =>
317+ ! providerWords . has ( term ) &&
318+ ( ! providerText . includes ( term ) || visible . some ( ( model ) => modelText ( model ) . includes ( term ) ) ) ,
319+ ) ;
310320 if ( modelTerms . length > 0 ) {
311321 const matches = visible . filter ( ( model ) => {
312- const text = ` ${ model . slug } ${ model . name } ${ model . subProvider ?? "" } ` . toLowerCase ( ) ;
322+ const text = modelText ( model ) ;
313323 return modelTerms . every ( ( term ) => text . includes ( term ) ) ;
314324 } ) ;
315325 const listed = matches . slice ( 0 , LISTED_MODEL_LIMIT ) ;
@@ -2138,7 +2148,7 @@ const make = Effect.gen(function* () {
21382148 Effect . mapError ( ( ) => failure ( "orchestration_error" , "Unable to read server settings." ) ) ,
21392149 ) ;
21402150 const inherited = parent ?. thread . modelSelection ;
2141- const searchTerms = input . search ?. toLowerCase ( ) . split ( / \s + / ) ?? [ ] ;
2151+ const searchTerms = input . search ?. toLowerCase ( ) . split ( / \s + / ) . filter ( Boolean ) ?? [ ] ;
21422152 return {
21432153 parentThreadId : parent ?. thread . id ?? null ,
21442154 inheritedProviderInstanceId : inherited ?. instanceId ?? null ,
0 commit comments