From 52ba27f3e9fd5e8983abce872193ea72ebea99ae Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Fri, 4 Sep 2026 17:24:46 +0200 Subject: [PATCH] ui : share one download confirmation dialog across chips and rows Extract DialogConfirmDownload for the destructive download actions (cancel an in-flight download, delete a downloaded model), keyed by a DownloadConfirmAction enum, and mount a single instance per surface instead of one per quant chip or download row. The chips and download rows now only signal intent; the discover options panel and the selector list own the dialog. Assisted-by: llama-ui:Qwen3.8-Flash-Next --- .../app/dialogs/DialogConfirmDownload.svelte | 60 +++++++++++++++++++ .../src/lib/components/app/dialogs/index.ts | 11 ++++ .../ModelsSelectorDownloadItem.svelte | 28 +++------ .../ModelsSelector/ModelsSelectorList.svelte | 22 ++++++- ...odelsDiscoverDetailsDownloadOptions.svelte | 52 +++++++--------- tools/ui/src/lib/enums/index.ts | 2 +- tools/ui/src/lib/enums/model.enums.ts | 10 ++++ 7 files changed, 132 insertions(+), 53 deletions(-) create mode 100644 tools/ui/src/lib/components/app/dialogs/DialogConfirmDownload.svelte diff --git a/tools/ui/src/lib/components/app/dialogs/DialogConfirmDownload.svelte b/tools/ui/src/lib/components/app/dialogs/DialogConfirmDownload.svelte new file mode 100644 index 0000000000..a76d5c3fa1 --- /dev/null +++ b/tools/ui/src/lib/components/app/dialogs/DialogConfirmDownload.svelte @@ -0,0 +1,60 @@ + + + diff --git a/tools/ui/src/lib/components/app/dialogs/index.ts b/tools/ui/src/lib/components/app/dialogs/index.ts index e3963ba499..5f05f91750 100644 --- a/tools/ui/src/lib/components/app/dialogs/index.ts +++ b/tools/ui/src/lib/components/app/dialogs/index.ts @@ -108,6 +108,17 @@ export { default as DialogExportSettings } from './DialogExportSettings.svelte'; */ export { default as DialogConfirmation } from './DialogConfirmation.svelte'; +/** + * **DialogConfirmDownload** - Confirm a destructive download action + * + * Shared confirmation for stopping/cancelling an in-flight download or deleting + * a downloaded model, used by the discover quant chips and the model selector's + * download rows so both word the action identically. Owns the copy and the + * default store removal; render one instance per surface keyed by the acted-on + * repo:tag. + */ +export { default as DialogConfirmDownload } from './DialogConfirmDownload.svelte'; + /** * **DialogConversationRename** - Rename a conversation * diff --git a/tools/ui/src/lib/components/app/models/ModelsSelector/ModelsSelectorDownloadItem.svelte b/tools/ui/src/lib/components/app/models/ModelsSelector/ModelsSelectorDownloadItem.svelte index 963c380937..a4ff0150ca 100644 --- a/tools/ui/src/lib/components/app/models/ModelsSelector/ModelsSelectorDownloadItem.svelte +++ b/tools/ui/src/lib/components/app/models/ModelsSelector/ModelsSelectorDownloadItem.svelte @@ -3,7 +3,6 @@ import ModelsDiscoverAvatar from '../discover/ModelsDiscoverAvatar.svelte'; import { Loader2, Pause, Play, X } from '@lucide/svelte'; import { ModelId } from '$lib/components/app'; - import DialogConfirmation from '$lib/components/app/dialogs/DialogConfirmation.svelte'; import { HuggingFaceService, ModelsService } from '$lib/services'; import { modelsStore } from '$lib/stores'; import type { ModelDownloadProgress } from '$lib/types'; @@ -11,12 +10,14 @@ interface Props { /** One entry from the status feed: an in-flight or paused download. */ entry: { isPaused: boolean; progress: ModelDownloadProgress | null; repoWithTag: string }; + /** + * Ask the list to confirm cancelling this download. The row owns no dialog; + * the list renders a single shared confirmation. + */ + onRequestCancel?: (repoWithTag: string) => void; } - let { entry }: Props = $props(); - - // cancel confirmation state - let confirmCancelOpen = $state(false); + let { entry, onRequestCancel }: Props = $props(); let percent = $derived( entry.progress && entry.progress.totalBytes > 0 @@ -105,7 +106,7 @@