Skip to content

Commit c35555e

Browse files
webui: limit conversation name length in dialogs
1 parent 1766517 commit c35555e

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import { RemoveButton } from '$lib/components/app';
3-
import { formatFileSize, getFileTypeLabel, getPreviewText } from '$lib/utils/file-preview';
3+
import { formatFileSize, getFileTypeLabel } from '$lib/utils/file-preview';
4+
import { getPreviewText } from '$lib/utils/text';
45
import { FileTypeCategory, MimeTypeText } from '$lib/enums/files';
56
67
interface Props {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
deleteConversation,
1313
updateConversationName
1414
} from '$lib/stores/chat.svelte';
15+
import { getPreviewText } from '$lib/utils/text';
1516
import ChatSidebarActions from './ChatSidebarActions.svelte';
1617
1718
const sidebar = Sidebar.useSidebar();
@@ -23,6 +24,9 @@
2324
let showEditDialog = $state(false);
2425
let selectedConversation = $state<DatabaseConversation | null>(null);
2526
let editedName = $state('');
27+
let selectedConversationNamePreview = $derived.by(() =>
28+
selectedConversation ? getPreviewText(selectedConversation.name) : ''
29+
);
2630
2731
let filteredConversations = $derived.by(() => {
2832
if (searchQuery.trim().length > 0) {
@@ -162,7 +166,7 @@
162166
bind:open={showDeleteDialog}
163167
title="Delete Conversation"
164168
description={selectedConversation
165-
? `Are you sure you want to delete "${selectedConversation.name}"? This action cannot be undone and will permanently remove all messages in this conversation.`
169+
? `Are you sure you want to delete "${selectedConversationNamePreview}"? This action cannot be undone and will permanently remove all messages in this conversation.`
166170
: ''}
167171
confirmText="Delete"
168172
cancelText="Cancel"

tools/server/webui/src/lib/utils/file-preview.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,3 @@ export function formatFileSize(bytes: number): string {
2121
export function getFileTypeLabel(fileType: string): string {
2222
return fileType.split('/').pop()?.toUpperCase() || 'FILE';
2323
}
24-
25-
/**
26-
* Truncates text content for preview display
27-
* @param content - The text content to truncate
28-
* @returns Truncated content with ellipsis if needed
29-
*/
30-
export function getPreviewText(content: string): string {
31-
return content.length > 150 ? content.substring(0, 150) + '...' : content;
32-
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Returns a shortened preview of the provided content capped at the given length.
3+
* Appends an ellipsis when the content exceeds the maximum.
4+
*/
5+
export function getPreviewText(content: string, max = 150): string {
6+
return content.length > max ? content.slice(0, max) + '...' : content;
7+
}

0 commit comments

Comments
 (0)