{ searchValue = ''; // Do NOT reset filters - keep the previously selected tag/connection type await tick(); // First check if the currently selected model is visible in the filtered list const selectedInFiltered = filteredItems.findIndex((item) => item.value === value); if (selectedInFiltered >= 0) { // The selected model is visible in the current filter selectedModelIdx = selectedInFiltered; } else { // The selected model is not visible, default to first item in filtered list selectedModelIdx = 0; } await tick(); // Scroll to the selected item if it exists in the current filtered view const itemToScrollTo = selectedInFiltered >= 0 ? document.querySelector(`[data-value="${value}"]`) : document.querySelector('[data-arrow-selected="true"]'); if (itemToScrollTo) { const container = itemToScrollTo.closest('.overflow-y-auto'); if (container) { const itemTop = itemToScrollTo.offsetTop; const containerHeight = container.clientHeight; const itemHeight = itemToScrollTo.clientHeight; container.scrollTop = itemTop - containerHeight / 2 + itemHeight / 2; } } }} closeFocus={false} >
{#if selectedModel} {selectedModel.label} {:else} {placeholder} {/if}
{#if searchEnabled}
{ if (e.code === 'Enter' && filteredItems.length > 0) { value = filteredItems[selectedModelIdx].value; show = false; return; // dont need to scroll on selection } else if (e.code === 'ArrowDown') { selectedModelIdx = Math.min(selectedModelIdx + 1, filteredItems.length - 1); } else if (e.code === 'ArrowUp') { selectedModelIdx = Math.max(selectedModelIdx - 1, 0); } else { // if the user types something, reset to the top selection. selectedModelIdx = 0; } const item = document.querySelector(`[data-arrow-selected="true"]`); item?.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' }); }} />
{/if}
{#if tags}
{ if (e.deltaY !== 0) { e.preventDefault(); e.currentTarget.scrollLeft += e.deltaY; } }} >
{#if items.find((item) => item.model?.owned_by === 'ollama') && items.find((item) => item.model?.owned_by === 'openai')} {/if} {#if items.find((item) => item.model?.direct)} {/if} {#each tags as tag} {/each}
{/if} {#each filteredItems as item, index} {:else}
{$i18n.t('No results found')}
{/each} {#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user.role === 'admin'} {/if} {#each Object.keys($MODEL_DOWNLOAD_POOL) as model}
Downloading "{model}"
{'pullProgress' in $MODEL_DOWNLOAD_POOL[model] ? `(${$MODEL_DOWNLOAD_POOL[model].pullProgress}%)` : ''}
{#if 'digest' in $MODEL_DOWNLOAD_POOL[model] && $MODEL_DOWNLOAD_POOL[model].digest}
{$MODEL_DOWNLOAD_POOL[model].digest}
{/if}
{/each}
{#if showTemporaryChatControl}
{/if}