Skip to content

Commit b368674

Browse files
committed
refactor: Enums folder
1 parent a9a493e commit b368674

26 files changed

+311
-221
lines changed

tools/server/public/index.html.gz

276 Bytes
Binary file not shown.

tools/server/webui/src/app.d.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,6 @@ import type {
3434
DatabaseMessageExtraPdfFile
3535
} from '$lib/types/database';
3636

37-
import type {
38-
FileTypeCategory,
39-
FileTypeImage,
40-
FileTypeAudio,
41-
FileTypePdf,
42-
FileTypeText,
43-
FileExtensionImage,
44-
FileExtensionAudio,
45-
FileExtensionPdf,
46-
FileExtensionText,
47-
MimeTypeApplication,
48-
MimeTypeAudio,
49-
MimeTypeImage,
50-
MimeTypeText
51-
} from '$lib/types/files';
52-
5337
import type {
5438
SettingsConfigValue,
5539
SettingsFieldConfig,
@@ -89,19 +73,6 @@ declare global {
8973
DatabaseMessageExtraImageFile,
9074
DatabaseMessageExtraTextFile,
9175
DatabaseMessageExtraPdfFile,
92-
FileTypeCategory,
93-
FileTypeImage,
94-
FileTypeAudio,
95-
FileTypePdf,
96-
FileTypeText,
97-
FileExtensionImage,
98-
FileExtensionAudio,
99-
FileExtensionPdf,
100-
FileExtensionText,
101-
MimeTypeApplication,
102-
MimeTypeAudio,
103-
MimeTypeImage,
104-
MimeTypeText,
10576
SettingsConfigValue,
10677
SettingsFieldConfig,
10778
SettingsConfigType,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { X } from '@lucide/svelte';
33
import { Button } from '$lib/components/ui/button';
44
import { formatFileSize, getFileTypeLabel, getPreviewText } from '$lib/utils/file-preview';
5+
import { FileTypeCategory, MimeTypeText } from '$lib/enums/files';
56
67
interface Props {
78
class?: string;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import * as Dialog from '$lib/components/ui/dialog';
33
import { FileText, Image, Music, FileIcon, Eye } from '@lucide/svelte';
4+
import { FileTypeCategory, MimeTypeApplication } from '$lib/enums/files';
45
import { convertPDFToImage } from '$lib/utils/pdf-processing';
56
import { Button } from '$lib/components/ui/button';
67
import { getFileTypeCategory } from '$lib/utils/file-type';

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { ChatAttachmentImagePreview, ChatAttachmentFilePreview } from '$lib/components/app';
3+
import { FileTypeCategory } from '$lib/enums/files';
34
import { getFileTypeCategory } from '$lib/utils/file-type';
45
import ChatAttachmentPreviewDialog from './ChatAttachmentPreviewDialog.svelte';
56

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@
99
} from '$lib/components/app';
1010
import { INPUT_CLASSES } from '$lib/constants/input-classes';
1111
import { config } from '$lib/stores/settings.svelte';
12+
import { FileTypeCategory, MimeTypeApplication } from '$lib/enums/files';
1213
import {
1314
AudioRecorder,
1415
convertToWav,
1516
createAudioFile,
1617
isAudioRecordingSupported
1718
} from '$lib/utils/audio-recording';
1819
import { onMount } from 'svelte';
20+
import {
21+
FileExtensionAudio,
22+
FileExtensionImage,
23+
FileExtensionPdf,
24+
FileExtensionText,
25+
MimeTypeAudio,
26+
MimeTypeImage,
27+
MimeTypeText
28+
} from '$lib/enums/files';
1929
2030
interface Props {
2131
class?: string;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
55
import * as Tooltip from '$lib/components/ui/tooltip';
66
import { TOOLTIP_DELAY_DURATION } from '$lib/constants/tooltip-config';
7+
import { FileTypeCategory } from '$lib/enums/files';
78
import { supportsAudio, supportsVision } from '$lib/stores/server.svelte';
89
910
interface Props {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Button } from '$lib/components/ui/button';
44
import ChatFormActionFileAttachments from './ChatFormActionFileAttachments.svelte';
55
import ChatFormActionRecord from './ChatFormActionRecord.svelte';
6+
import type { FileTypeCategory } from '$lib/enums/files';
67
78
interface Props {
89
canSend?: boolean;
Lines changed: 20 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<script lang="ts">
22
import { Edit, Copy, RefreshCw, Trash2 } from '@lucide/svelte';
3-
import { Button } from '$lib/components/ui/button';
4-
import * as AlertDialog from '$lib/components/ui/alert-dialog';
5-
import * as Tooltip from '$lib/components/ui/tooltip';
6-
import type { Component } from 'svelte';
3+
import { ActionButton, ConfirmationDialog } from '$lib/components/app';
74
import ChatMessageBranchingControls from './ChatMessageBranchingControls.svelte';
85
96
interface Props {
@@ -73,95 +70,33 @@
7370
<div
7471
class="pointer-events-none inset-0 flex items-center gap-1 opacity-0 transition-all duration-150 group-hover:pointer-events-auto group-hover:opacity-100"
7572
>
76-
{@render actionButton({ icon: Copy, tooltip: 'Copy', onclick: onCopy })}
73+
<ActionButton icon={Copy} tooltip="Copy" onclick={onCopy} />
7774

7875
{#if onEdit}
79-
{@render actionButton({ icon: Edit, tooltip: 'Edit', onclick: onEdit })}
76+
<ActionButton icon={Edit} tooltip="Edit" onclick={onEdit} />
8077
{/if}
8178

8279
{#if role === 'assistant' && onRegenerate}
83-
{@render actionButton({ icon: RefreshCw, tooltip: 'Regenerate', onclick: onRegenerate })}
80+
<ActionButton icon={RefreshCw} tooltip="Regenerate" onclick={onRegenerate} />
8481
{/if}
8582

86-
{@render actionButton({ icon: Trash2, tooltip: 'Delete', onclick: onDelete })}
83+
<ActionButton icon={Trash2} tooltip="Delete" onclick={onDelete} />
8784
</div>
8885
</div>
8986
</div>
9087

91-
{#snippet actionButton(config: { icon: Component; tooltip: string; onclick: () => void })}
92-
<Tooltip.Root>
93-
<Tooltip.Trigger>
94-
<Button variant="ghost" size="sm" class="h-6 w-6 p-0" onclick={config.onclick}>
95-
{@const IconComponent = config.icon}
96-
97-
<IconComponent class="h-3 w-3" />
98-
</Button>
99-
</Tooltip.Trigger>
100-
101-
<Tooltip.Content>
102-
<p>{config.tooltip}</p>
103-
</Tooltip.Content>
104-
</Tooltip.Root>
105-
{/snippet}
106-
107-
<AlertDialog.Root bind:open={showDeleteDialog}>
108-
<AlertDialog.Content
109-
onkeydown={(e) => {
110-
if (e.key === 'Enter') {
111-
e.preventDefault();
112-
handleConfirmDelete();
113-
}
114-
}}
115-
>
116-
<AlertDialog.Header>
117-
<AlertDialog.Title>Delete Message</AlertDialog.Title>
118-
119-
<AlertDialog.Description>
120-
{#if deletionInfo && deletionInfo.totalCount > 1}
121-
<div class="space-y-2">
122-
<p>This will delete <strong>{deletionInfo.totalCount} messages</strong> including:</p>
123-
124-
<ul class="ml-4 list-inside list-disc space-y-1 text-sm">
125-
{#if deletionInfo.userMessages > 0}
126-
<li>
127-
{deletionInfo.userMessages} user message{deletionInfo.userMessages > 1 ? 's' : ''}
128-
</li>
129-
{/if}
130-
131-
{#if deletionInfo.assistantMessages > 0}
132-
<li>
133-
{deletionInfo.assistantMessages} assistant response{deletionInfo.assistantMessages >
134-
1
135-
? 's'
136-
: ''}
137-
</li>
138-
{/if}
139-
</ul>
140-
141-
<p class="mt-2 text-sm text-muted-foreground">
142-
All messages in this branch and their responses will be permanently removed. This
143-
action cannot be undone.
144-
</p>
145-
</div>
146-
{:else}
147-
Are you sure you want to delete this message? This action cannot be undone.
148-
{/if}
149-
</AlertDialog.Description>
150-
</AlertDialog.Header>
151-
152-
<AlertDialog.Footer>
153-
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
154-
155-
<AlertDialog.Action
156-
onclick={handleConfirmDelete}
157-
class="bg-destructive text-white hover:bg-destructive/80"
158-
>
159-
{#if deletionInfo && deletionInfo.totalCount > 1}
160-
Delete {deletionInfo.totalCount} Messages
161-
{:else}
162-
Delete
163-
{/if}
164-
</AlertDialog.Action>
165-
</AlertDialog.Footer>
166-
</AlertDialog.Content>
167-
</AlertDialog.Root>
88+
<ConfirmationDialog
89+
bind:open={showDeleteDialog}
90+
title="Delete Message"
91+
description={deletionInfo && deletionInfo.totalCount > 1
92+
? `This will delete ${deletionInfo.totalCount} messages including: ${deletionInfo.userMessages} user message${deletionInfo.userMessages > 1 ? 's' : ''} and ${deletionInfo.assistantMessages} assistant response${deletionInfo.assistantMessages > 1 ? 's' : ''}. All messages in this branch and their responses will be permanently removed. This action cannot be undone.`
93+
: 'Are you sure you want to delete this message? This action cannot be undone.'}
94+
confirmText={deletionInfo && deletionInfo.totalCount > 1
95+
? `Delete ${deletionInfo.totalCount} Messages`
96+
: 'Delete'}
97+
cancelText="Cancel"
98+
variant="destructive"
99+
icon={Trash2}
100+
onConfirm={handleConfirmDelete}
101+
onCancel={() => onShowDeleteDialogChange(false)}
102+
/>

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

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
ChatProcessingInfo,
88
EmptyFileAlertDialog,
99
ServerInfo,
10-
ServerLoadingSplash
10+
ServerLoadingSplash,
11+
ConfirmationDialog
1112
} from '$lib/components/app';
1213
import * as AlertDialog from '$lib/components/ui/alert-dialog';
1314
import {
@@ -37,6 +38,7 @@
3738
import { processFilesToChatUploaded } from '$lib/utils/process-uploaded-files';
3839
import { onMount } from 'svelte';
3940
import { fade, fly, slide } from 'svelte/transition';
41+
import { Trash2 } from '@lucide/svelte';
4042
import ChatScreenDragOverlay from './ChatScreenDragOverlay.svelte';
4143
4244
let { showCenteredEmpty = false } = $props();
@@ -84,13 +86,6 @@
8486
showDeleteDialog = false;
8587
}
8688
87-
function handleDeleteDialogKeydown(event: KeyboardEvent) {
88-
if (event.key === 'Enter') {
89-
event.preventDefault();
90-
handleDeleteConfirm();
91-
}
92-
}
93-
9489
function handleDragEnter(event: DragEvent) {
9590
event.preventDefault();
9691
dragCounter++;
@@ -431,29 +426,17 @@
431426
</AlertDialog.Portal>
432427
</AlertDialog.Root>
433428

434-
<AlertDialog.Root bind:open={showDeleteDialog}>
435-
<AlertDialog.Portal>
436-
<AlertDialog.Overlay />
437-
<AlertDialog.Content class="max-w-md" onkeydown={handleDeleteDialogKeydown}>
438-
<AlertDialog.Header>
439-
<AlertDialog.Title>Delete Chat</AlertDialog.Title>
440-
<AlertDialog.Description class="text-sm text-muted-foreground">
441-
Are you sure you want to delete this chat? This action cannot be undone.
442-
</AlertDialog.Description>
443-
</AlertDialog.Header>
444-
445-
<AlertDialog.Footer>
446-
<AlertDialog.Cancel onclick={() => (showDeleteDialog = false)}>Cancel</AlertDialog.Cancel>
447-
<AlertDialog.Action
448-
onclick={handleDeleteConfirm}
449-
class="bg-destructive text-white hover:bg-destructive/80"
450-
>
451-
Delete
452-
</AlertDialog.Action>
453-
</AlertDialog.Footer>
454-
</AlertDialog.Content>
455-
</AlertDialog.Portal>
456-
</AlertDialog.Root>
429+
<ConfirmationDialog
430+
bind:open={showDeleteDialog}
431+
title="Delete Conversation"
432+
description="Are you sure you want to delete this conversation? This action cannot be undone and will permanently remove all messages in this conversation."
433+
confirmText="Delete"
434+
cancelText="Cancel"
435+
variant="destructive"
436+
icon={Trash2}
437+
onConfirm={handleDeleteConfirm}
438+
onCancel={() => (showDeleteDialog = false)}
439+
/>
457440

458441
<EmptyFileAlertDialog
459442
bind:open={showEmptyFileDialog}

0 commit comments

Comments
 (0)