Skip to content

Commit f1bad23

Browse files
authored
Better UX for handling multiple attachments in WebUI (#17246)
1 parent becc481 commit f1bad23

File tree

11 files changed

+439
-116
lines changed

11 files changed

+439
-116
lines changed

tools/server/public/index.html.gz

-2.62 KB
Binary file not shown.

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentFilePreview.svelte

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
2-
import { X } from '@lucide/svelte';
3-
import { Button } from '$lib/components/ui/button';
2+
import { RemoveButton } from '$lib/components/app';
43
import { formatFileSize, getFileTypeLabel, getPreviewText } from '$lib/utils/file-preview';
54
import { FileTypeCategory, MimeTypeText } from '$lib/enums/files';
65
@@ -66,17 +65,15 @@
6665
</button>
6766
{:else}
6867
<!-- Non-readonly mode (ChatForm) -->
69-
<div class="relative rounded-lg border border-border bg-muted p-3 {className} w-64">
70-
<Button
71-
type="button"
72-
variant="ghost"
73-
size="sm"
74-
class="absolute top-2 right-2 h-6 w-6 bg-white/20 p-0 hover:bg-white/30"
75-
onclick={() => onRemove?.(id)}
76-
aria-label="Remove file"
77-
>
78-
<X class="h-3 w-3" />
79-
</Button>
68+
<button
69+
class="group relative rounded-lg border border-border bg-muted p-3 {className} {textContent
70+
? 'max-h-24 max-w-72'
71+
: 'max-w-36'} cursor-pointer text-left"
72+
onclick={onClick}
73+
>
74+
<div class="absolute top-2 right-2 opacity-0 transition-opacity group-hover:opacity-100">
75+
<RemoveButton {id} {onRemove} />
76+
</div>
8077

8178
<div class="pr-8">
8279
<span class="mb-3 block truncate text-sm font-medium text-foreground">{name}</span>
@@ -85,7 +82,7 @@
8582
<div class="relative">
8683
<div
8784
class="overflow-hidden font-mono text-xs leading-relaxed break-words whitespace-pre-wrap text-muted-foreground"
88-
style="max-height: 3.6em; line-height: 1.2em;"
85+
style="max-height: 3rem; line-height: 1.2em;"
8986
>
9087
{getPreviewText(textContent)}
9188
</div>
@@ -98,11 +95,11 @@
9895
</div>
9996
{/if}
10097
</div>
101-
</div>
98+
</button>
10299
{/if}
103100
{:else}
104101
<button
105-
class="flex items-center gap-2 gap-3 rounded-lg border border-border bg-muted p-3 {className}"
102+
class="group flex items-center gap-3 rounded-lg border border-border bg-muted p-3 {className} relative"
106103
onclick={onClick}
107104
>
108105
<div
@@ -112,7 +109,9 @@
112109
</div>
113110

114111
<div class="flex flex-col gap-1">
115-
<span class="max-w-36 truncate text-sm font-medium text-foreground md:max-w-72">
112+
<span
113+
class="max-w-24 truncate text-sm font-medium text-foreground group-hover:pr-6 md:max-w-32"
114+
>
116115
{name}
117116
</span>
118117

@@ -122,18 +121,9 @@
122121
</div>
123122

124123
{#if !readonly}
125-
<Button
126-
type="button"
127-
variant="ghost"
128-
size="sm"
129-
class="h-6 w-6 p-0"
130-
onclick={(e) => {
131-
e.stopPropagation();
132-
onRemove?.(id);
133-
}}
134-
>
135-
<X class="h-3 w-3" />
136-
</Button>
124+
<div class="absolute top-2 right-2 opacity-0 transition-opacity group-hover:opacity-100">
125+
<RemoveButton {id} {onRemove} />
126+
</div>
137127
{/if}
138128
</button>
139129
{/if}

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentImagePreview.svelte

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
2-
import { X } from '@lucide/svelte';
3-
import { Button } from '$lib/components/ui/button';
2+
import { RemoveButton } from '$lib/components/app';
43
54
interface Props {
65
id: string;
@@ -26,12 +25,12 @@
2625
class: className = '',
2726
// Default to small size for form previews
2827
width = 'w-auto',
29-
height = 'h-24',
28+
height = 'h-16',
3029
imageClass = ''
3130
}: Props = $props();
3231
</script>
3332

34-
<div class="relative overflow-hidden rounded-lg border border-border bg-muted {className}">
33+
<div class="group relative overflow-hidden rounded-lg border border-border bg-muted {className}">
3534
{#if onClick}
3635
<button
3736
type="button"
@@ -55,17 +54,9 @@
5554

5655
{#if !readonly}
5756
<div
58-
class="absolute top-1 right-1 flex items-center justify-center opacity-0 transition-opacity hover:opacity-100"
57+
class="absolute top-1 right-1 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100"
5958
>
60-
<Button
61-
type="button"
62-
variant="ghost"
63-
size="sm"
64-
class="h-6 w-6 bg-white/20 p-0 text-white hover:bg-white/30"
65-
onclick={() => onRemove?.(id)}
66-
>
67-
<X class="h-3 w-3" />
68-
</Button>
59+
<RemoveButton {id} {onRemove} class="text-white" />
6960
</div>
7061
{/if}
7162
</div>

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentPreviewDialog.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
<Dialog.Root bind:open>
154154
<Dialog.Content class="grid max-h-[90vh] max-w-5xl overflow-hidden !p-10 sm:w-auto sm:max-w-6xl">
155155
<Dialog.Header class="flex-shrink-0">
156-
<div class="flex items-center justify-between">
156+
<div class="flex items-center justify-between gap-6">
157157
<div class="flex items-center gap-3">
158158
{#if IconComponent}
159159
<IconComponent class="h-5 w-5 text-muted-foreground" />

0 commit comments

Comments
 (0)