diff --git a/frontend/src/lib/components/copilot/ChatModelSettings.svelte b/frontend/src/lib/components/copilot/ChatModelSettings.svelte index 70745eee1c..4201958ad6 100644 --- a/frontend/src/lib/components/copilot/ChatModelSettings.svelte +++ b/frontend/src/lib/components/copilot/ChatModelSettings.svelte @@ -5,7 +5,8 @@ * both. Driven entirely by ChatModelSettingsConfig, so the session chat and the flow * chat render the same control from different data — see chatModelSettings.ts. */ - import { ChevronDown, Check, Loader2 } from 'lucide-svelte' + import { ChevronDown, Check } from 'lucide-svelte' + import Tooltip from '$lib/components/meltComponents/Tooltip.svelte' import DropdownV2 from '$lib/components/DropdownV2.svelte' import DropdownSubmenuItem from '$lib/components/DropdownSubmenuItem.svelte' import MenuItem from '$lib/components/meltComponents/MenuItem.svelte' @@ -74,6 +75,19 @@ } }) + // Rows each section last showed, for the placeholder while it reloads. Seven fill the + // default list height; an empty or first load assumes a full list. + const FULL_LIST_ROWS = 7 + const settledRows = new Map() + $effect(() => { + for (const sec of config.sections ?? []) { + if (!sec.loading) settledRows.set(sec.label, sec.options.length) + } + }) + function placeholderRows(label: string): number { + return Math.min(settledRows.get(label) || FULL_LIST_ROWS, FULL_LIST_ROWS) + } + // Blocks are separated, not prefixed: a rule belongs between two of them, so the first // one rendered must not draw one above itself whichever block that turns out to be. const BLOCK_CLASS = @@ -95,7 +109,7 @@ disabled={config.readOnly} endIcon={config.readOnly ? undefined : { icon: ChevronDown }} btnClasses="w-full max-w-[200px] text-secondary font-normal" - title={config.readOnly ? config.readOnlyReason : config.title} + title={config.readOnly ? undefined : config.title} > {#if config.shortLabel} @@ -167,8 +181,15 @@ {#snippet section(sec: ChoiceSection, item: MeltItem, close: () => void)}
{sec.label}
{#if sec.loading} -
- Loading... + +
+ Loading models + {#each { length: placeholderRows(sec.label) }, i (i)} +
+
+
+ {/each}
{:else if sec.options.length === 0}
{sec.emptyMessage ?? 'Nothing to choose from'}
@@ -187,7 +208,7 @@ {/each}
{/if} - {#if sec.custom && !sec.loading} + {#if sec.custom} {@const custom = sec.custom}
{@render typedField( @@ -225,7 +246,13 @@ {/snippet} {#if config.readOnly} - {@render trigger()} + + + {@render trigger()} + {#snippet text()} + {config.readOnlyReason} + {/snippet} + {:else} void): Item { const rows: Item[] = resources.loading ? [{ displayName: 'Loading resources...', disabled: true }] : (resources.current ?? []).length === 0 - ? [{ displayName: 'No AI resource in this workspace', disabled: true }] + ? [{ displayName: noResourceLabel, tooltip: noResourceLabel, disabled: true }] : (resources.current ?? []).map((r) => ({ displayName: r.path, selected: r.path === resourcePath,