Skip to content

Commit 218cbcf

Browse files
committed
feat: Improve destructive actions UI & interactions
1 parent aeaeada commit 218cbcf

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@
66
import { Tooltip, TooltipContent, TooltipTrigger } from '$lib/components/ui/tooltip';
77
import MessageBranchingControls from './MessageBranchingControls.svelte';
88
import type { MessageSiblingInfo } from '$lib/utils/branching';
9-
import {
10-
AlertDialog,
11-
AlertDialogAction,
12-
AlertDialogCancel,
13-
AlertDialogContent,
14-
AlertDialogDescription,
15-
AlertDialogFooter,
16-
AlertDialogHeader,
17-
AlertDialogTitle
18-
} from '$lib/components/ui/alert-dialog';
9+
import * as AlertDialog from '$lib/components/ui/alert-dialog';
1910
import { copyToClipboard } from '$lib/utils/copy';
2011
import { parseThinkingContent } from '$lib/utils/thinking';
2112
import { getDeletionInfo } from '$lib/stores/chat.svelte';
@@ -287,18 +278,18 @@
287278
</div>
288279
{/snippet}
289280

290-
<AlertDialog bind:open={showDeleteDialog}>
291-
<AlertDialogContent
281+
<AlertDialog.Root bind:open={showDeleteDialog}>
282+
<AlertDialog.Content
292283
onkeydown={(e) => {
293284
if (e.key === 'Enter') {
294285
e.preventDefault();
295286
handleConfirmDelete();
296287
}
297288
}}
298289
>
299-
<AlertDialogHeader>
300-
<AlertDialogTitle>Delete Message</AlertDialogTitle>
301-
<AlertDialogDescription>
290+
<AlertDialog.Header>
291+
<AlertDialog.Title>Delete Message</AlertDialog.Title>
292+
<AlertDialog.Description>
302293
{#if deletionInfo && deletionInfo.totalCount > 1}
303294
<div class="space-y-2">
304295
<p>This will delete <strong>{deletionInfo.totalCount} messages</strong> including:</p>
@@ -320,22 +311,22 @@
320311
{:else}
321312
Are you sure you want to delete this message? This action cannot be undone.
322313
{/if}
323-
</AlertDialogDescription>
324-
</AlertDialogHeader>
314+
</AlertDialog.Description>
315+
</AlertDialog.Header>
325316

326-
<AlertDialogFooter>
327-
<AlertDialogCancel>Cancel</AlertDialogCancel>
317+
<AlertDialog.Footer>
318+
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
328319

329-
<AlertDialogAction onclick={handleConfirmDelete} class="bg-destructive text-destructive-foreground hover:bg-destructive/90">
320+
<AlertDialog.Action onclick={handleConfirmDelete} class="bg-destructive hover:bg-destructive/80 text-white">
330321
{#if deletionInfo && deletionInfo.totalCount > 1}
331322
Delete {deletionInfo.totalCount} Messages
332323
{:else}
333324
Delete
334325
{/if}
335-
</AlertDialogAction>
336-
</AlertDialogFooter>
337-
</AlertDialogContent>
338-
</AlertDialog>
326+
</AlertDialog.Action>
327+
</AlertDialog.Footer>
328+
</AlertDialog.Content>
329+
</AlertDialog.Root>
339330

340331
<style>
341332
.processing-container {

tools/server/webui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@
217217
showDeleteDialog = false;
218218
}
219219
220+
function handleDeleteDialogKeydown(event: KeyboardEvent) {
221+
if (event.key === 'Enter') {
222+
event.preventDefault();
223+
handleDeleteConfirm();
224+
}
225+
}
226+
220227
$effect(() => {
221228
// This solution is not ideal, but it works for now. But can be tricky for long conversations
222229
// Eventually we might want to find a proper way to render the content scrolled down from the beginning
@@ -391,7 +398,7 @@
391398
<AlertDialog.Root bind:open={showDeleteDialog}>
392399
<AlertDialog.Portal>
393400
<AlertDialog.Overlay />
394-
<AlertDialog.Content class="max-w-md">
401+
<AlertDialog.Content class="max-w-md" onkeydown={handleDeleteDialogKeydown}>
395402
<AlertDialog.Header>
396403
<AlertDialog.Title>Delete Chat</AlertDialog.Title>
397404
<AlertDialog.Description class="text-muted-foreground text-sm">
@@ -403,7 +410,7 @@
403410
<AlertDialog.Cancel onclick={() => (showDeleteDialog = false)}>
404411
Cancel
405412
</AlertDialog.Cancel>
406-
<AlertDialog.Action onclick={handleDeleteConfirm} class="bg-destructive text-destructive-foreground hover:bg-destructive/90">
413+
<AlertDialog.Action onclick={handleDeleteConfirm} class="bg-destructive hover:bg-destructive/80 text-white">
407414
Delete
408415
</AlertDialog.Action>
409416
</AlertDialog.Footer>

tools/server/webui/src/lib/components/app/chat/ChatSidebar/ChatSidebarConversationItem.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@
133133
</AlertDialog.Header>
134134
<AlertDialog.Footer>
135135
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
136+
136137
<AlertDialog.Action
137-
class="bg-destructive text-destructive-foreground"
138+
class="bg-destructive hover:bg-destructive/80 text-white "
138139
onclick={handleConfirmDelete}>Delete</AlertDialog.Action
139140
>
140141
</AlertDialog.Footer>

0 commit comments

Comments
 (0)