Skip to content

Commit 8dcf66d

Browse files
committed
refactor: Cleanup
1 parent 1f5276a commit 8dcf66d

File tree

5 files changed

+41
-39
lines changed

5 files changed

+41
-39
lines changed

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormActionFileAttachments.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import { supportsAudio, supportsVision } from '$lib/stores/server.svelte';
99
1010
interface Props {
11+
class?: string;
1112
disabled?: boolean;
1213
onFileUpload?: (fileType?: FileTypeCategory) => void;
13-
class?: string;
1414
}
1515
16-
let { disabled = false, onFileUpload, class: className = '' }: Props = $props();
16+
let { class: className = '', disabled = false, onFileUpload }: Props = $props();
1717
1818
const fileUploadTooltipText = $derived.by(() => {
1919
return !supportsVision()
@@ -32,9 +32,9 @@
3232
<Tooltip.Root delayDuration={TOOLTIP_DELAY_DURATION}>
3333
<Tooltip.Trigger>
3434
<Button
35-
type="button"
3635
class="file-upload-button h-8 w-8 rounded-full bg-transparent p-0 text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
3736
{disabled}
37+
type="button"
3838
>
3939
<span class="sr-only">Attach files</span>
4040

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormActionRecord.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
2-
import { Button } from '$lib/components/ui/button';
32
import { Mic } from '@lucide/svelte';
4-
import { supportsAudio } from '$lib/stores/server.svelte';
3+
import { Button } from '$lib/components/ui/button';
54
import * as Tooltip from '$lib/components/ui/tooltip';
5+
import { supportsAudio } from '$lib/stores/server.svelte';
66
77
interface Props {
88
class?: string;
@@ -25,16 +25,17 @@
2525
<Tooltip.Root delayDuration={100}>
2626
<Tooltip.Trigger>
2727
<Button
28-
type="button"
2928
class="h-8 w-8 rounded-full p-0 {isRecording
3029
? 'animate-pulse bg-red-500 text-white hover:bg-red-600'
3130
: 'bg-transparent text-muted-foreground hover:bg-foreground/10 hover:text-foreground'} {!supportsAudio()
3231
? 'cursor-not-allowed opacity-50'
3332
: ''}"
3433
disabled={disabled || isLoading || !supportsAudio()}
3534
onclick={onMicClick}
35+
type="button"
3636
>
3737
<span class="sr-only">{isRecording ? 'Stop recording' : 'Start recording'}</span>
38+
3839
<Mic class="h-4 w-4" />
3940
</Button>
4041
</Tooltip.Trigger>

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormFileInputInvisible.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
44
interface Props {
55
accept?: string;
6+
class?: string;
67
multiple?: boolean;
78
onFileSelect?: (files: File[]) => void;
8-
class?: string;
99
}
1010
1111
let {
1212
accept = $bindable(),
13+
class: className = '',
1314
multiple = true,
14-
onFileSelect,
15-
class: className = ''
15+
onFileSelect
1616
}: Props = $props();
1717
1818
let fileInputElement: HTMLInputElement | undefined;
1919
2020
// Use modality-aware accept string by default, but allow override
21-
const finalAccept = $derived(accept ?? generateModalityAwareAcceptString());
21+
let finalAccept = $derived(accept ?? generateModalityAwareAcceptString());
2222
2323
export function click() {
2424
fileInputElement?.click();

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormTextarea.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
bind:this={textareaElement}
5050
bind:value
5151
class="text-md max-h-32 min-h-12 w-full resize-none border-0 bg-transparent p-0 leading-6 outline-none placeholder:text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0"
52+
class:cursor-not-allowed={disabled}
53+
{disabled}
5254
onkeydown={onKeydown}
5355
oninput={(event) => autoResizeTextarea(event.currentTarget)}
5456
onpaste={onPaste}
5557
{placeholder}
56-
{disabled}
57-
class:cursor-not-allowed={disabled}
5858
></textarea>
5959
</div>

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

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,38 @@
77
ChatMessageThinkingBlock,
88
MarkdownContent
99
} from '$lib/components/app';
10-
import { inputClasses } from '$lib/constants/input-classes';
11-
import type { MessageSiblingInfo } from '$lib/utils/branching';
1210
import * as AlertDialog from '$lib/components/ui/alert-dialog';
1311
import * as Tooltip from '$lib/components/ui/tooltip';
12+
import { inputClasses } from '$lib/constants/input-classes';
13+
import { useProcessingState } from '$lib/hooks/use-processing-state.svelte';
14+
import { getDeletionInfo, isLoading } from '$lib/stores/chat.svelte';
15+
import type { MessageSiblingInfo } from '$lib/utils/branching';
1416
import { copyToClipboard } from '$lib/utils/copy';
1517
import { parseThinkingContent } from '$lib/utils/thinking';
16-
import { getDeletionInfo } from '$lib/stores/chat.svelte';
17-
import { isLoading } from '$lib/stores/chat.svelte';
18-
import { useProcessingState } from '$lib/hooks/use-processing-state.svelte';
1918
import type { Component } from 'svelte';
2019
import { fade } from 'svelte/transition';
2120
import MessageBranchingControls from './MessageBranchingControls.svelte';
2221
2322
interface Props {
2423
class?: string;
2524
message: DatabaseMessage;
26-
siblingInfo?: MessageSiblingInfo | null;
2725
onCopy?: (message: DatabaseMessage) => void;
2826
onDelete?: (message: DatabaseMessage) => void;
29-
onNavigateToSibling?: (siblingId: string) => void;
3027
onEditWithBranching?: (message: DatabaseMessage, newContent: string) => void;
28+
onNavigateToSibling?: (siblingId: string) => void;
3129
onRegenerateWithBranching?: (message: DatabaseMessage) => void;
30+
siblingInfo?: MessageSiblingInfo | null;
3231
}
3332
3433
let {
3534
class: className = '',
3635
message,
37-
siblingInfo = null,
3836
onCopy,
3937
onDelete,
40-
onNavigateToSibling,
4138
onEditWithBranching,
42-
onRegenerateWithBranching
39+
onNavigateToSibling,
40+
onRegenerateWithBranching,
41+
siblingInfo = null
4342
}: Props = $props();
4443
4544
let showDeleteDialog = $state(false);
@@ -77,14 +76,24 @@
7776
return message.content?.replace('<|channel|>analysis', '');
7877
});
7978
79+
function handleCancelEdit() {
80+
isEditing = false;
81+
editedContent = message.content;
82+
}
83+
84+
function handleConfirmDelete() {
85+
onDelete?.(message);
86+
showDeleteDialog = false;
87+
}
88+
8089
async function handleCopy() {
8190
await copyToClipboard(message.content, 'Message copied to clipboard');
8291
onCopy?.(message);
8392
}
8493
85-
function handleCancelEdit() {
86-
isEditing = false;
87-
editedContent = message.content;
94+
async function handleDelete() {
95+
deletionInfo = await getDeletionInfo(message.id);
96+
showDeleteDialog = true;
8897
}
8998
9099
function handleEdit() {
@@ -121,47 +130,39 @@
121130
}
122131
isEditing = false;
123132
}
124-
125-
async function handleDelete() {
126-
deletionInfo = await getDeletionInfo(message.id);
127-
showDeleteDialog = true;
128-
}
129-
130-
function handleConfirmDelete() {
131-
onDelete?.(message);
132-
showDeleteDialog = false;
133-
}
134133
</script>
135134

136135
{#if message.role === 'user'}
137136
<div
137+
aria-label="User message with actions"
138138
class="group flex flex-col items-end gap-2 {className}"
139139
role="group"
140-
aria-label="User message with actions"
141140
>
142141
{#if isEditing}
143142
<div class="w-full max-w-[80%]">
144143
<textarea
145144
bind:this={textareaElement}
146145
bind:value={editedContent}
147-
onkeydown={handleEditKeydown}
148146
class="min-h-[60px] w-full resize-none rounded-2xl px-3 py-2 text-sm {inputClasses}"
147+
onkeydown={handleEditKeydown}
149148
placeholder="Edit your message..."
150149
></textarea>
151150

152151
<div class="mt-2 flex justify-end gap-2">
153-
<Button variant="outline" size="sm" class="h-8 px-3" onclick={handleCancelEdit}>
152+
<Button class="h-8 px-3" onclick={handleCancelEdit} size="sm" variant="outline" >
154153
<X class="mr-1 h-3 w-3" />
154+
155155
Cancel
156156
</Button>
157157

158158
<Button
159-
size="sm"
160159
class="h-8 px-3"
161160
onclick={handleSaveEdit}
162161
disabled={!editedContent.trim() || editedContent === message.content}
162+
size="sm"
163163
>
164164
<Check class="mr-1 h-3 w-3" />
165+
165166
Send
166167
</Button>
167168
</div>

0 commit comments

Comments
 (0)