diff --git a/tools/ui/src/lib/components/app/dialogs/DialogManageModels.svelte b/tools/ui/src/lib/components/app/dialogs/DialogManageModels.svelte index 6df7d0ea1e..c8d98ead35 100644 --- a/tools/ui/src/lib/components/app/dialogs/DialogManageModels.svelte +++ b/tools/ui/src/lib/components/app/dialogs/DialogManageModels.svelte @@ -6,6 +6,7 @@ import { Button } from '$lib/components/ui/button'; import * as Dialog from '$lib/components/ui/dialog'; import { uiStore } from '$lib/stores'; + import { untrack } from 'svelte'; interface Props { open?: boolean; @@ -16,7 +17,38 @@ type View = 'discover' | 'manage' | 'providers'; + /** How long a view takes to fade out before the next one fades in. */ + const VIEW_FADE_MS = 150; + + // what the user asked for, and what is actually rendered: a view change fades the + // current one out, swaps, then fades the next one in let view = $state('manage'); + let shownView = $state('manage'); + let isSwapping = $state(false); + + $effect(() => { + const next = view; + + if (next === shownView) return; + + // nothing to fade while the dialog is closed, so the view is set before it opens + if (!open) { + untrack(() => (shownView = next)); + + return; + } + + untrack(() => (isSwapping = true)); + + const timer = setTimeout(() => { + untrack(() => { + shownView = next; + isSwapping = false; + }); + }, VIEW_FADE_MS); + + return () => clearTimeout(timer); + }); let title = $derived( view === 'discover' ? 'Discover' : view === 'providers' ? 'Providers' : 'Models' @@ -69,8 +101,8 @@ -
- {#if view === 'manage'} +
+ {#if shownView === 'manage'} {#snippet toolbarEnd()} {/snippet} - {:else if view === 'discover'} + {:else if shownView === 'discover'}
@@ -103,3 +135,21 @@
+ +