* Builds HTML for a single model option. * @param {Object} model - Model object * @returns {string} HTML string
(model)
| 342 | |
| 343 | // Render all unpinned models sorted alphabetically by display name |
| 344 | const sortedModels = [...unpinnedModels].sort((a, b) => |
| 345 | a.name.localeCompare(b.name) |
| 346 | ); |
| 347 | if (sortedModels.length > 0) { |
| 348 | html += ` |
| 349 | <div class="mb-3"> |
| 350 | <div class="model-category-header px-2 py-1 text-xs font-medium text-muted-foreground">All Models</div> |
| 351 | <div class="space-y-0"> |
| 352 | ${sortedModels.map(model => this.buildModelOptionHTML(model)).join('')} |
| 353 | </div> |
| 354 | </div> |
| 355 | `; |
| 356 | } |
| 357 | |
| 358 | this.app.elements.modelsList.innerHTML = html; |
| 359 | |
| 360 | // Auto-highlight first item so user can immediately press Enter |
| 361 | const modelOptions = this.getModelOptions(); |
| 362 | if (modelOptions.length > 0) { |
| 363 | this.highlightedIndex = 0; |
| 364 | this.updateHighlight(modelOptions, skipAutoScroll); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | warmRender() { |
| 369 | if (this.app.state.modelsLoading || this.app.state.models.length === 0) { |
| 370 | return; |
| 371 | } |
| 372 | const renderSignature = this.getRenderSignature(''); |
| 373 | if (this.hasRenderedOnce && renderSignature === this.lastRenderSignature) { |
| 374 | return; |
| 375 | } |
| 376 | const schedule = typeof requestIdleCallback === 'function' |
| 377 | ? (callback) => requestIdleCallback(callback, { timeout: 500 }) |
| 378 | : (callback) => setTimeout(callback, 0); |
| 379 | schedule(() => { |
| 380 | if (this.app.elements.modelPickerModal.classList.contains('hidden')) { |
| 381 | this.renderModels('', true); |
| 382 | } |
| 383 | }); |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Builds HTML for a single model option. |
no test coverage detected