Skip to content

Commit e84352f

Browse files
webui: limit conversation name length in dialogs
1 parent b340299 commit e84352f

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 { getFileTypeLabel, getPreviewText, formatFileSize, isTextFile } from '$lib/utils';
3+
import { formatFileSize, getFileTypeLabel, isTextFile } from '$lib/utils';
4+
import { getPreviewText } from '$lib/utils/text';
45
import { AttachmentType } from '$lib/enums';
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
@@ -9,6 +9,7 @@
99
import Input from '$lib/components/ui/input/input.svelte';
1010
import { conversationsStore, conversations } from '$lib/stores/conversations.svelte';
1111
import { chatStore } from '$lib/stores/chat.svelte';
12+
import { getPreviewText } from '$lib/utils/text';
1213
import ChatSidebarActions from './ChatSidebarActions.svelte';
1314
1415
const sidebar = Sidebar.useSidebar();
@@ -20,6 +21,9 @@
2021
let showEditDialog = $state(false);
2122
let selectedConversation = $state<DatabaseConversation | null>(null);
2223
let editedName = $state('');
24+
let selectedConversationNamePreview = $derived.by(() =>
25+
selectedConversation ? getPreviewText(selectedConversation.name) : ''
26+
);
2327
2428
let filteredConversations = $derived.by(() => {
2529
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
@@ -34,12 +34,3 @@ export function getFileTypeLabel(input: string | undefined): string {
3434
// Handle AttachmentType or other plain strings
3535
return input.toUpperCase();
3636
}
37-
38-
/**
39-
* Truncates text content for preview display
40-
* @param content - The text content to truncate
41-
* @returns Truncated content with ellipsis if needed
42-
*/
43-
export function getPreviewText(content: string): string {
44-
return content.length > 150 ? content.substring(0, 150) + '...' : content;
45-
}
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)