diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 1acf3aa3f..8d82acb76 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -78,6 +78,8 @@ let showEventConfirmation = false; let eventConfirmationTitle = ''; let eventConfirmationMessage = ''; + let eventConfirmationInput = false; + let eventConfirmationInputPlaceholder = ''; let eventCallback = null; let showModelSelector = true; @@ -161,10 +163,21 @@ message.content += data.content; } else if (type === 'confirmation') { eventCallback = cb; + + eventConfirmationInput = false; showEventConfirmation = true; eventConfirmationTitle = data.title; eventConfirmationMessage = data.message; + } else if (type === 'input') { + eventCallback = cb; + + eventConfirmationInput = true; + showEventConfirmation = true; + + eventConfirmationTitle = data.title; + eventConfirmationMessage = data.message; + eventConfirmationInputPlaceholder = data.placeholder; } else { console.log('Unknown message type', data); } @@ -1411,8 +1424,14 @@ bind:show={showEventConfirmation} title={eventConfirmationTitle} message={eventConfirmationMessage} + input={eventConfirmationInput} + inputPlaceholder={eventConfirmationInputPlaceholder} on:confirm={(e) => { - eventCallback(true); + if (e.detail) { + eventCallback(e.detail); + } else { + eventCallback(true); + } }} on:cancel={() => { eventCallback(false); @@ -1545,7 +1564,6 @@ { const model = $models.find((m) => m.id === e); - if (model) { return [...a, model]; } diff --git a/src/lib/components/common/ConfirmDialog.svelte b/src/lib/components/common/ConfirmDialog.svelte index 2096a41cf..937370436 100644 --- a/src/lib/components/common/ConfirmDialog.svelte +++ b/src/lib/components/common/ConfirmDialog.svelte @@ -13,9 +13,14 @@ export let cancelLabel = $i18n.t('Cancel'); export let confirmLabel = $i18n.t('Confirm'); + export let input = false; + export let inputPlaceholder = ''; + export let show = false; + let modalElement = null; let mounted = false; + let inputValue = ''; const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape') { @@ -73,6 +78,16 @@ {:else} {$i18n.t('This action cannot be undone. Do you wish to continue?')} {/if} + + {#if input} +