@f5-sales-demo/xcsh 21.7.0 → 21.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.7.0",
4
+ "version": "21.8.0",
5
5
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -61,13 +61,13 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@agentclientprotocol/sdk": "1.3.0",
64
- "@f5-sales-demo/pi-agent-core": "21.7.0",
65
- "@f5-sales-demo/pi-ai": "21.7.0",
66
- "@f5-sales-demo/pi-natives": "21.7.0",
67
- "@f5-sales-demo/pi-resource-management": "21.7.0",
68
- "@f5-sales-demo/pi-tui": "21.7.0",
69
- "@f5-sales-demo/pi-utils": "21.7.0",
70
- "@f5-sales-demo/xcsh-stats": "21.7.0",
64
+ "@f5-sales-demo/pi-agent-core": "21.8.0",
65
+ "@f5-sales-demo/pi-ai": "21.8.0",
66
+ "@f5-sales-demo/pi-natives": "21.8.0",
67
+ "@f5-sales-demo/pi-resource-management": "21.8.0",
68
+ "@f5-sales-demo/pi-tui": "21.8.0",
69
+ "@f5-sales-demo/pi-utils": "21.8.0",
70
+ "@f5-sales-demo/xcsh-stats": "21.8.0",
71
71
  "@mozilla/readability": "^0.6",
72
72
  "@sinclair/typebox": "^0.34",
73
73
  "@xterm/headless": "^6.0",
@@ -11,6 +11,7 @@ import {
11
11
  getBundledProviders,
12
12
  googleAntigravityModelManagerOptions,
13
13
  googleGeminiCliModelManagerOptions,
14
+ googleVertexModelManagerOptions,
14
15
  type Model,
15
16
  type ModelManagerOptions,
16
17
  type ModelRefreshStrategy,
@@ -1408,6 +1409,11 @@ export class ModelRegistry {
1408
1409
  resolveKey: (value: string | undefined) => string | undefined;
1409
1410
  createOptions: (key: string) => ModelManagerOptions<Api>;
1410
1411
  }> = [
1412
+ {
1413
+ providerId: "google-vertex",
1414
+ resolveKey: value => value,
1415
+ createOptions: apiKey => googleVertexModelManagerOptions({ apiKey }),
1416
+ },
1411
1417
  {
1412
1418
  providerId: "google-antigravity",
1413
1419
  resolveKey: extractGoogleOAuthToken,
@@ -1477,6 +1483,7 @@ export class ModelRegistry {
1477
1483
  options: ModelManagerOptions<Api>,
1478
1484
  strategy: ModelRefreshStrategy,
1479
1485
  ): Promise<Model<Api>[]> {
1486
+ const previous = this.#providerDiscoveryStates.get(options.providerId);
1480
1487
  try {
1481
1488
  const manager = createModelManager({ ...options, cacheDbPath: this.#cacheDbPath });
1482
1489
  const result = await manager.refresh(strategy);
@@ -1493,12 +1500,17 @@ export class ModelRegistry {
1493
1500
  });
1494
1501
  return models;
1495
1502
  } catch (error) {
1503
+ const retained =
1504
+ previous && (previous.status === "ok" || previous.status === "cached") && previous.models.length > 0
1505
+ ? previous
1506
+ : undefined;
1496
1507
  this.#providerDiscoveryStates.set(options.providerId, {
1497
1508
  provider: options.providerId,
1498
- status: "unavailable",
1509
+ status: retained ? "cached" : "unavailable",
1499
1510
  optional: false,
1500
1511
  stale: true,
1501
- models: [],
1512
+ fetchedAt: retained?.fetchedAt,
1513
+ models: retained?.models ?? [],
1502
1514
  error: error instanceof Error ? error.message : String(error),
1503
1515
  });
1504
1516
  logger.warn("model discovery failed for provider", {
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.7.0",
21
- "commit": "95f2f0d47bef5b8bd74e99e1f1656babc0115c99",
22
- "shortCommit": "95f2f0d",
20
+ "version": "21.8.0",
21
+ "commit": "1fbf4e99094587555f6270619aa5e24a8da8f340",
22
+ "shortCommit": "1fbf4e9",
23
23
  "branch": "main",
24
- "tag": "v21.7.0",
25
- "commitDate": "2026-09-02T21:22:58+00:00",
26
- "buildDate": "2026-09-02T21:59:57.287Z",
24
+ "tag": "v21.8.0",
25
+ "commitDate": "2026-09-03T01:24:51+00:00",
26
+ "buildDate": "2026-09-03T01:59:18.972Z",
27
27
  "dirty": true,
28
28
  "prNumber": "",
29
29
  "repoUrl": "https://github.com/f5-sales-demo/xcsh",
30
30
  "repoSlug": "f5-sales-demo/xcsh",
31
- "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/95f2f0d47bef5b8bd74e99e1f1656babc0115c99",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.7.0"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/1fbf4e99094587555f6270619aa5e24a8da8f340",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.8.0"
33
33
  };
@@ -12,7 +12,7 @@ import {
12
12
  type TUI,
13
13
  visibleWidth,
14
14
  } from "@f5-sales-demo/pi-tui";
15
- import type { ModelRegistry } from "../../config/model-registry";
15
+ import type { ModelRegistry, ProviderDiscoveryState, ProviderDiscoveryStatus } from "../../config/model-registry";
16
16
  import { getKnownRoleIds, getRoleInfo, MODEL_ROLE_IDS, MODEL_ROLES } from "../../config/model-registry";
17
17
  import { resolveModelRoleValue } from "../../config/model-resolver";
18
18
  import type { Settings } from "../../config/settings";
@@ -43,7 +43,7 @@ function getAlphaSearchTokens(query: string): string[] {
43
43
  return [...normalizeSearchText(query).matchAll(/[a-z]+/g)].map(match => match[0]).filter(token => token.length > 0);
44
44
  }
45
45
 
46
- interface ModelItem {
46
+ export interface ModelItem {
47
47
  kind: "provider";
48
48
  provider: string;
49
49
  id: string;
@@ -93,15 +93,207 @@ export function getModelSearchText(item: DefaultPickerModelPresentation): string
93
93
  .join(" ");
94
94
  }
95
95
 
96
+ function getModelDisplayName(model: Model): string {
97
+ const tieredName = [model.family, model.tier].filter(Boolean).join(" ");
98
+ if (tieredName && compactSearchText(tieredName) === compactSearchText(model.name)) return tieredName;
99
+ return model.name;
100
+ }
101
+
102
+ function getModelPublisher(model: Model): string {
103
+ if (model.publisher) return model.publisher;
104
+ if (model.provider.startsWith("google-")) return "Google";
105
+ if (model.provider === "openai" || model.provider === "openai-codex") return "OpenAI";
106
+ if (model.provider === "anthropic") return "Anthropic";
107
+ return getProviderDisplayName(model.provider);
108
+ }
109
+
110
+ function getModelFamily(model: Model): string {
111
+ if (model.family) return model.family;
112
+ return (
113
+ model.name.match(/^(?:Gemini\s+\d+(?:\.\d+)?|GPT-\d+(?:\.\d+)?|Claude\s+\S+(?:\s+\d+(?:\.\d+)?)?)/i)?.[0] ??
114
+ model.name
115
+ );
116
+ }
117
+
118
+ function modelHierarchyKey(item: ModelItem, includeProvider: boolean): string {
119
+ return [
120
+ includeProvider ? getProviderDisplayName(item.provider) : "",
121
+ getModelPublisher(item.model),
122
+ getModelFamily(item.model),
123
+ ]
124
+ .join("\0")
125
+ .toLocaleLowerCase();
126
+ }
127
+
128
+ function sortModelsByHierarchy(items: ModelItem[], includeProvider: boolean): void {
129
+ items.sort((left, right) =>
130
+ modelHierarchyKey(left, includeProvider).localeCompare(modelHierarchyKey(right, includeProvider)),
131
+ );
132
+ }
133
+
134
+ function compareVersions(left: string, right: string): number {
135
+ const leftParts = left.split(".").map(Number);
136
+ const rightParts = right.split(".").map(Number);
137
+ for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index += 1) {
138
+ const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
139
+ if (difference !== 0) return difference;
140
+ }
141
+ return 0;
142
+ }
143
+
144
+ /** Keep historical catalogs authoritative while presenting only current user-facing families. */
145
+ export function filterCurrentBrowserModels(models: readonly Model[]): Model[] {
146
+ const newestGeminiVersion = new Map<string, string>();
147
+ const newestClaudeVersion = new Map<string, string>();
148
+ for (const model of models) {
149
+ if (model.provider.startsWith("google-")) {
150
+ const gemini = model.id.match(/^gemini-(\d+(?:\.\d+)?)-(flash|pro)(?:-|$)/i);
151
+ if (gemini?.[1] && gemini[2]) {
152
+ const key = `${model.provider}:${gemini[2].toLowerCase()}`;
153
+ const previous = newestGeminiVersion.get(key);
154
+ if (!previous || compareVersions(gemini[1], previous) > 0) newestGeminiVersion.set(key, gemini[1]);
155
+ }
156
+ }
157
+ const claude = model.id.match(/^claude-(opus|sonnet|haiku)-(\d+)(?:[.-](\d+))?(?:-|$)/i);
158
+ if (claude?.[1] && claude[2]) {
159
+ const key = `${model.provider}:${claude[1].toLowerCase()}`;
160
+ const version = `${claude[2]}.${claude[3] ?? "0"}`;
161
+ const previous = newestClaudeVersion.get(key);
162
+ if (!previous || compareVersions(version, previous) > 0) newestClaudeVersion.set(key, version);
163
+ }
164
+ }
165
+
166
+ return models.filter(model => {
167
+ const gpt = model.id.match(/^gpt-(\d+(?:\.\d+)?)(?:-|$)/i);
168
+ if (gpt?.[1]) {
169
+ // Older GPT generations are still available through explicit --models scopes,
170
+ // but the general browser starts at the current 5.6 family.
171
+ if (compareVersions(gpt[1], "5.6") < 0) return false;
172
+ if (model.provider === "openai-codex") return /^gpt-5\.6-(?:sol|terra|luna)$/i.test(model.id);
173
+ }
174
+ const claude = model.id.match(/^claude-(opus|sonnet|haiku)-(\d+)(?:[.-](\d+))?(?:-|$)/i);
175
+ if (claude?.[1] && claude[2]) {
176
+ const version = `${claude[2]}.${claude[3] ?? "0"}`;
177
+ return newestClaudeVersion.get(`${model.provider}:${claude[1].toLowerCase()}`) === version;
178
+ }
179
+ if (!model.provider.startsWith("google-")) return true;
180
+ if (!model.id.startsWith("gemini-")) {
181
+ // Antigravity discovery can expose implementation-only experiment ids
182
+ // alongside its supported Gemini, Claude, and GPT-OSS catalog.
183
+ return model.provider === "google-antigravity" && /^gpt-oss-/i.test(model.id);
184
+ }
185
+ const match = model.id.match(/^gemini-(\d+(?:\.\d+)?)-(flash|pro)(?:-|$)/i);
186
+ if (!match?.[1] || !match[2]) return false;
187
+ return newestGeminiVersion.get(`${model.provider}:${match[2].toLowerCase()}`) === match[1];
188
+ });
189
+ }
190
+
96
191
  export function getProviderDisplayName(provider: string): string {
97
192
  if (provider === "openai-codex") return "ChatGPT Subscription";
98
193
  if (provider === "openai") return "OpenAI API Key";
194
+ if (provider === "google-vertex") return "Google Vertex";
195
+ if (provider === "google-antigravity") return "Antigravity (Gemini, Claude, GPT-OSS)";
196
+ if (provider === "vllm") return "vLLM";
197
+ if (provider === "lm-studio") return "LM Studio";
198
+ if (provider === "llama.cpp") return "llama.cpp";
199
+ if (provider === "ollama") return "Ollama";
99
200
  return provider
100
201
  .split("-")
101
202
  .map(part => part.charAt(0).toUpperCase() + part.slice(1))
102
203
  .join(" ");
103
204
  }
104
205
 
206
+ const LOCAL_PROVIDER_IDS = new Set(["ollama", "vllm", "lm-studio", "llama.cpp"]);
207
+ const LOCAL_PROVIDERS_TAB = "local-providers";
208
+
209
+ export interface ProviderModelGroup {
210
+ id: string;
211
+ label: string;
212
+ classification: "authenticated" | "local";
213
+ discoveryStatus: ProviderDiscoveryStatus;
214
+ stale: boolean;
215
+ models: ModelItem[];
216
+ }
217
+
218
+ function modelItems(models: readonly Model[], currentOnly = true): ModelItem[] {
219
+ return presentModelsForDefaultPicker(currentOnly ? filterCurrentBrowserModels(models) : models).map(item => ({
220
+ kind: "provider",
221
+ provider: item.model.provider,
222
+ id: item.displaySelector.slice(item.displaySelector.indexOf("/") + 1),
223
+ model: item.model,
224
+ selector: item.selector,
225
+ }));
226
+ }
227
+
228
+ /** Build tabs only from provider catalogs whose authenticated/local discovery produced models. */
229
+ export function buildProviderModelGroups(
230
+ models: readonly Model[],
231
+ getDiscoveryState: (provider: string) => ProviderDiscoveryState | undefined,
232
+ configuredProviderOrder: readonly string[] = [],
233
+ currentProvider?: string,
234
+ hasAuth: (provider: string) => boolean = () => true,
235
+ currentOnly = true,
236
+ ): ProviderModelGroup[] {
237
+ const items = modelItems(models, currentOnly);
238
+ const byProvider = new Map<string, ModelItem[]>();
239
+ for (const item of items) {
240
+ const providerItems = byProvider.get(item.provider) ?? [];
241
+ providerItems.push(item);
242
+ byProvider.set(item.provider, providerItems);
243
+ }
244
+
245
+ const authenticated: ProviderModelGroup[] = [];
246
+ const localItems: ModelItem[] = [];
247
+ for (const [provider, providerItems] of byProvider) {
248
+ const discovery = getDiscoveryState(provider);
249
+ if (LOCAL_PROVIDER_IDS.has(provider)) {
250
+ if (discovery?.status !== "ok") continue;
251
+ localItems.push(...providerItems);
252
+ continue;
253
+ }
254
+ if (!hasAuth(provider)) continue;
255
+ if (discovery?.status !== "ok" && discovery?.status !== "cached") continue;
256
+ sortModelsByHierarchy(providerItems, false);
257
+ authenticated.push({
258
+ id: provider,
259
+ label: getProviderDisplayName(provider),
260
+ classification: "authenticated",
261
+ discoveryStatus: discovery.status,
262
+ stale: discovery.stale || discovery.status === "cached",
263
+ models: providerItems,
264
+ });
265
+ }
266
+
267
+ const configuredRank = new Map<string, number>();
268
+ for (const provider of configuredProviderOrder) {
269
+ const normalized = provider.trim().toLowerCase();
270
+ if (normalized && !configuredRank.has(normalized)) configuredRank.set(normalized, configuredRank.size);
271
+ }
272
+ authenticated.sort((left, right) => {
273
+ if (left.id === currentProvider && right.id !== currentProvider) return -1;
274
+ if (right.id === currentProvider && left.id !== currentProvider) return 1;
275
+ const leftRank = configuredRank.get(left.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
276
+ const rightRank = configuredRank.get(right.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
277
+ if (leftRank !== rightRank) return leftRank - rightRank;
278
+ return left.label.localeCompare(right.label);
279
+ });
280
+
281
+ if (localItems.length > 0) {
282
+ sortModelsByHierarchy(localItems, true);
283
+ const localGroup: ProviderModelGroup = {
284
+ id: LOCAL_PROVIDERS_TAB,
285
+ label: "Local Providers",
286
+ classification: "local",
287
+ discoveryStatus: "ok",
288
+ stale: false,
289
+ models: localItems,
290
+ };
291
+ if (currentProvider && LOCAL_PROVIDER_IDS.has(currentProvider)) authenticated.unshift(localGroup);
292
+ else authenticated.push(localGroup);
293
+ }
294
+ return authenticated;
295
+ }
296
+
105
297
  interface RoleAssignment {
106
298
  model: Model;
107
299
  thinkingLevel: ThinkingLevel;
@@ -114,9 +306,6 @@ interface MenuRoleAction {
114
306
  role: string; // now accepts custom role strings
115
307
  }
116
308
 
117
- const QUICK_TAB = "QUICK";
118
- const ALL_TAB = "ALL MODELS";
119
-
120
309
  /**
121
310
  * Component that renders a model selector with provider tabs and context menu.
122
311
  * - Tab/Arrow Left/Right: Switch between provider tabs
@@ -145,11 +334,12 @@ export class ModelSelectorComponent extends Container {
145
334
  #scopedModels: ReadonlyArray<ScopedModelItem>;
146
335
  #temporaryOnly: boolean;
147
336
  #currentModel: Model | undefined;
337
+ #providerGroups: ProviderModelGroup[] = [];
148
338
 
149
339
  #menuRoleActions: MenuRoleAction[] = [];
150
340
 
151
341
  // Tab state
152
- #providers: string[] = [QUICK_TAB, ALL_TAB];
342
+ #providers: string[] = [];
153
343
  #activeTabIndex: number = 0;
154
344
 
155
345
  // Context menu state
@@ -421,14 +611,7 @@ export class ModelSelectorComponent extends Container {
421
611
 
422
612
  // Load available models (built-in models still work even if models.json failed)
423
613
  try {
424
- const availableModels = this.#modelRegistry.getAvailable();
425
- models = presentModelsForDefaultPicker(availableModels).map(item => ({
426
- kind: "provider",
427
- provider: item.model.provider,
428
- id: item.displaySelector.slice(item.displaySelector.indexOf("/") + 1),
429
- model: item.model,
430
- selector: item.selector,
431
- }));
614
+ models = modelItems(this.#modelRegistry.getAvailable());
432
615
  } catch (error) {
433
616
  this.#allModels = [];
434
617
  this.#filteredModels = [];
@@ -449,17 +632,52 @@ export class ModelSelectorComponent extends Container {
449
632
  }
450
633
 
451
634
  #buildProviderTabs(): void {
452
- this.#providers = [QUICK_TAB, ALL_TAB];
635
+ const previousProvider = this.#getActiveProvider();
636
+ const discoveryState = (provider: string): ProviderDiscoveryState | undefined => {
637
+ if (this.#scopedModels.length > 0 || typeof this.#modelRegistry.getProviderDiscoveryState !== "function") {
638
+ return { provider, status: "ok", optional: false, stale: false, models: [] };
639
+ }
640
+ return this.#modelRegistry.getProviderDiscoveryState(provider);
641
+ };
642
+ const configuredOrder = this.#settings.get("modelProviderOrder");
643
+ this.#providerGroups = buildProviderModelGroups(
644
+ this.#allModels.map(item => item.model),
645
+ discoveryState,
646
+ configuredOrder,
647
+ this.#currentModel?.provider,
648
+ provider =>
649
+ this.#scopedModels.length > 0 ||
650
+ typeof this.#modelRegistry.authStorage?.hasAuth !== "function" ||
651
+ this.#modelRegistry.authStorage.hasAuth(provider),
652
+ this.#scopedModels.length === 0,
653
+ );
654
+ this.#providers = this.#providerGroups.map(group => group.id);
655
+ const previousIndex = this.#providers.indexOf(previousProvider);
656
+ this.#activeTabIndex = previousIndex >= 0 ? previousIndex : 0;
453
657
  }
454
658
 
455
659
  async #refreshSelectedProvider(): Promise<void> {
456
- return;
660
+ const activeGroup = this.#providerGroups[this.#activeTabIndex];
661
+ if (!activeGroup || typeof this.#modelRegistry.refreshProvider !== "function" || this.#scopedModels.length > 0)
662
+ return;
663
+ const providers = new Set(activeGroup.models.map(item => item.provider));
664
+ await Promise.all([...providers].map(provider => this.#modelRegistry.refreshProvider(provider, "online")));
665
+ const models = modelItems(this.#modelRegistry.getAvailable());
666
+ this.#sortModels(models);
667
+ this.#allModels = models;
668
+ this.#buildProviderTabs();
669
+ this.#updateTabBar();
670
+ this.#applyTabFilter();
671
+ this.#tui.requestRender();
457
672
  }
458
673
 
459
674
  #updateTabBar(): void {
460
675
  this.#headerContainer.clear();
461
676
 
462
- const tabs: Tab[] = this.#providers.map(provider => ({ id: provider, label: provider }));
677
+ const tabs: Tab[] = this.#providerGroups.map(group => ({
678
+ id: group.id,
679
+ label: `${group.label}${group.stale ? " (stale)" : ""}`,
680
+ }));
463
681
  const tabBar = new TabBar("Models", tabs, getTabBarTheme(), this.#activeTabIndex);
464
682
  tabBar.onTabChange = (_tab, index) => {
465
683
  this.#activeTabIndex = index;
@@ -476,53 +694,25 @@ export class ModelSelectorComponent extends Container {
476
694
  }
477
695
 
478
696
  #getActiveProvider(): string {
479
- return this.#providers[this.#activeTabIndex] ?? ALL_TAB;
697
+ return this.#providers[this.#activeTabIndex] ?? "";
480
698
  }
481
699
 
482
700
  #isCanonicalTab(): boolean {
483
701
  return false;
484
702
  }
485
703
 
486
- #getQuickModels(): ModelItem[] {
487
- const wanted = new Set<string>();
488
- if (this.#currentModel) wanted.add(`${this.#currentModel.provider}/${this.#currentModel.id}`);
489
- for (const assigned of Object.values(this.#roles)) {
490
- if (assigned) wanted.add(`${assigned.model.provider}/${assigned.model.id}`);
491
- }
492
- for (const selector of (this.#settings.getStorage()?.getModelUsageOrder() ?? []).slice(0, 5))
493
- wanted.add(selector);
494
- const recommended = new Map<string, ModelItem>();
495
- for (const item of this.#allModels) {
496
- const previous = recommended.get(item.provider);
497
- if (!previous || (item.model.priority ?? Infinity) < (previous.model.priority ?? Infinity)) {
498
- recommended.set(item.provider, item);
499
- }
500
- }
501
- for (const item of recommended.values()) wanted.add(item.selector);
502
- return this.#allModels.filter(item => wanted.has(item.selector));
503
- }
504
-
505
704
  #filterModels(query: string): void {
506
- const activeProvider = this.#getActiveProvider();
507
705
  const isCanonicalTab = false;
706
+ const activeGroup = this.#providerGroups[this.#activeTabIndex];
508
707
 
509
- // Start with all models or filter by provider/canonical view
510
- let baseModels = activeProvider === QUICK_TAB ? this.#getQuickModels() : this.#allModels;
708
+ // Search is a temporary global grouped view; the active provider tab remains unchanged.
709
+ const baseModels = query.trim()
710
+ ? this.#providerGroups.flatMap(group => group.models)
711
+ : (activeGroup?.models ?? []);
511
712
  const baseCanonicalModels = this.#canonicalModels;
512
713
 
513
714
  // Apply fuzzy filter if query is present
514
715
  if (query.trim()) {
515
- // If user is searching from a provider tab, auto-switch to ALL to show global provider results.
516
- if (activeProvider !== ALL_TAB && !isCanonicalTab) {
517
- this.#activeTabIndex = 1;
518
- if (this.#tabBar && this.#tabBar.getActiveIndex() !== 1) {
519
- this.#tabBar.setActiveIndex(1);
520
- return;
521
- }
522
- this.#updateTabBar();
523
- baseModels = this.#allModels;
524
- }
525
-
526
716
  if (isCanonicalTab) {
527
717
  const alphaTokens = getAlphaSearchTokens(query);
528
718
  const alphaFiltered =
@@ -546,10 +736,24 @@ export class ModelSelectorComponent extends Container {
546
736
  this.#sortCanonicalModels(fuzzyMatches);
547
737
  this.#filteredCanonicalModels = fuzzyMatches;
548
738
  } else {
549
- const fuzzyMatches = fuzzyFilter(baseModels, query, ({ model, selector }) =>
550
- getModelSearchText({ model, selector, displaySelector: selector }),
739
+ const selectorQuery = query.trim().toLowerCase();
740
+ const selectorMatches = selectorQuery.includes("/")
741
+ ? baseModels.filter(item => item.selector.toLowerCase().includes(selectorQuery))
742
+ : undefined;
743
+ const alphaTokens = getAlphaSearchTokens(query);
744
+ const alphaFiltered = (selectorMatches ?? baseModels).filter(item => {
745
+ const searchText = normalizeSearchText(
746
+ getModelSearchText({ model: item.model, selector: item.selector, displaySelector: item.selector }),
747
+ );
748
+ return alphaTokens.every(token => searchText.includes(token));
749
+ });
750
+ const fuzzyMatches = fuzzyFilter(
751
+ selectorMatches ?? (alphaFiltered.length > 0 ? alphaFiltered : baseModels),
752
+ query,
753
+ ({ model, selector }) => getModelSearchText({ model, selector, displaySelector: selector }),
551
754
  );
552
755
  this.#sortModels(fuzzyMatches);
756
+ sortModelsByHierarchy(fuzzyMatches, true);
553
757
  this.#filteredModels = fuzzyMatches;
554
758
  }
555
759
  } else {
@@ -580,11 +784,11 @@ export class ModelSelectorComponent extends Container {
580
784
  }
581
785
 
582
786
  #getProviderEmptyStateMessage(): string | undefined {
583
- const activeProvider = this.#getActiveProvider();
584
- if (activeProvider === ALL_TAB || activeProvider === QUICK_TAB || this.#searchInput.getValue().trim()) {
787
+ const activeGroup = this.#providerGroups[this.#activeTabIndex];
788
+ if (!activeGroup || activeGroup.classification === "local" || this.#searchInput.getValue().trim()) {
585
789
  return undefined;
586
790
  }
587
- const state = this.#modelRegistry.getProviderDiscoveryState(activeProvider.toLowerCase());
791
+ const state = this.#modelRegistry.getProviderDiscoveryState(activeGroup.id);
588
792
  if (!state) {
589
793
  return undefined;
590
794
  }
@@ -617,8 +821,20 @@ export class ModelSelectorComponent extends Container {
617
821
  );
618
822
  const endIndex = Math.min(startIndex + maxVisible, visibleItems.length);
619
823
 
620
- const activeProvider = this.#getActiveProvider();
621
- const showProvider = activeProvider === ALL_TAB;
824
+ const activeGroup = this.#providerGroups[this.#activeTabIndex];
825
+ const searching = Boolean(this.#searchInput.getValue().trim());
826
+ const showProvider = searching || activeGroup?.classification === "local";
827
+ if (!searching && activeGroup?.stale) {
828
+ const providerState =
829
+ activeGroup.classification === "authenticated"
830
+ ? this.#modelRegistry.getProviderDiscoveryState(activeGroup.id)
831
+ : undefined;
832
+ const age = this.#formatDiscoveryAge(providerState?.fetchedAt);
833
+ this.#listContainer.addChild(
834
+ new Text(theme.fg("warning", ` Stale cached catalog${age ? ` from ${age}` : ""}`), 0, 0),
835
+ );
836
+ this.#listContainer.addChild(new Spacer(1));
837
+ }
622
838
 
623
839
  // Show visible slice of filtered models
624
840
  let previousGroup: string | undefined;
@@ -628,10 +844,14 @@ export class ModelSelectorComponent extends Container {
628
844
  const canonicalItem = isCanonicalTab ? (item as CanonicalModelItem) : undefined;
629
845
  const providerItem = isCanonicalTab ? undefined : (item as ModelItem);
630
846
  const group = showProvider
631
- ? [getProviderDisplayName(providerItem?.provider ?? ""), item.model.publisher, item.model.family]
847
+ ? [
848
+ getProviderDisplayName(providerItem?.provider ?? ""),
849
+ getModelPublisher(item.model),
850
+ getModelFamily(item.model),
851
+ ]
632
852
  .filter(Boolean)
633
853
  .join(" › ")
634
- : undefined;
854
+ : [getModelPublisher(item.model), getModelFamily(item.model)].filter(Boolean).join(" › ");
635
855
  if (group && group !== previousGroup) {
636
856
  if (previousGroup) this.#listContainer.addChild(new Spacer(1));
637
857
  this.#listContainer.addChild(new Text(theme.fg("muted", ` ${group}`), 0, 0));
@@ -669,10 +889,8 @@ export class ModelSelectorComponent extends Container {
669
889
  const variants = theme.fg("dim", ` [${canonicalItem?.variantCount ?? 0}]`);
670
890
  const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
671
891
  line = `${prefix}${theme.fg("accent", item.id)}${variants}${backing}${badgeText}`;
672
- } else if (showProvider) {
673
- line = `${prefix}${theme.fg("accent", item.model.name)} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
674
892
  } else {
675
- line = `${prefix}${theme.fg("accent", item.id)}${badgeText}`;
893
+ line = `${prefix}${theme.fg("accent", getModelDisplayName(item.model))} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
676
894
  }
677
895
  } else {
678
896
  const prefix = " ";
@@ -680,10 +898,8 @@ export class ModelSelectorComponent extends Container {
680
898
  const variants = theme.fg("dim", ` [${canonicalItem?.variantCount ?? 0}]`);
681
899
  const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
682
900
  line = `${prefix}${item.id}${variants}${backing}${badgeText}`;
683
- } else if (showProvider) {
684
- line = `${prefix}${item.model.name} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
685
901
  } else {
686
- line = `${prefix}${item.id}${badgeText}`;
902
+ line = `${prefix}${getModelDisplayName(item.model)} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
687
903
  }
688
904
  }
689
905
 
@@ -715,7 +931,7 @@ export class ModelSelectorComponent extends Container {
715
931
  ? ` (${selected.model.provider}/${selected.model.id}, ${(selected as CanonicalModelItem).variantCount} variants)`
716
932
  : "";
717
933
  this.#listContainer.addChild(
718
- new Text(theme.fg("muted", ` Model Name: ${selected.model.name}${suffix}`), 0, 0),
934
+ new Text(theme.fg("muted", ` Model Name: ${getModelDisplayName(selected.model)}${suffix}`), 0, 0),
719
935
  );
720
936
  }
721
937
  }
@@ -875,7 +1091,7 @@ export class ModelSelectorComponent extends Container {
875
1091
  }
876
1092
 
877
1093
  // Role assignment is deliberately secondary.
878
- if (keyData.toLowerCase() === "r" && !this.#temporaryOnly) {
1094
+ if (keyData.toLowerCase() === "r" && !this.#temporaryOnly && this.#searchInput.getValue().length === 0) {
879
1095
  this.#openMenu();
880
1096
  return;
881
1097
  }
@@ -1339,7 +1339,8 @@ export class SelectorController {
1339
1339
  loginModelChoice = GOOGLE_ANTIGRAVITY_LOGIN_MODEL_CHOICE;
1340
1340
  } else {
1341
1341
  await this.ctx.session.modelRegistry.authStorage.login(providerId as OAuthProvider, loginCallbacks);
1342
- await this.ctx.session.modelRegistry.refresh();
1342
+ // Force entitlement discovery after login so /model reflects the provider immediately.
1343
+ await this.ctx.session.modelRegistry.refresh("online");
1343
1344
  loginModelChoice = await applyOAuthLoginModel(this.ctx.session, providerId);
1344
1345
  }
1345
1346
  if (loginModelChoice) {
@@ -1456,6 +1457,7 @@ export class SelectorController {
1456
1457
  await validateVertexLogin(runtime, project, accessToken);
1457
1458
  }
1458
1459
 
1460
+ await this.ctx.session.modelRegistry.refreshProvider("google-vertex", "online");
1459
1461
  const applied = await applyModelAfterLogin(this.ctx.session, GOOGLE_VERTEX_LOGIN_MODEL_CHOICE);
1460
1462
  if (!applied) throw new Error("Gemini 3.7 Flash is unavailable in the local Vertex model registry");
1461
1463
  this.ctx.session.settings.set("providers.vertexProject", project);