Skip to content

Commit bcf460f

Browse files
webui: limit conversation name length in dialogs
1 parent b9a3771 commit bcf460f

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
@@ -8,6 +8,7 @@
88
import * as AlertDialog from '$lib/components/ui/alert-dialog';
99
import Input from '$lib/components/ui/input/input.svelte';
1010
import { conversationsStore, conversations } from '$lib/stores/conversations.svelte';
11+
import { getPreviewText } from '$lib/utils/text';
1112
import ChatSidebarActions from './ChatSidebarActions.svelte';
1213
1314
const sidebar = Sidebar.useSidebar();
@@ -19,6 +20,9 @@
1920
let showEditDialog = $state(false);
2021
let selectedConversation = $state<DatabaseConversation | null>(null);
2122
let editedName = $state('');
23+
let selectedConversationNamePreview = $derived.by(() =>
24+
selectedConversation ? getPreviewText(selectedConversation.name) : ''
25+
);
2226
2327
let filteredConversations = $derived.by(() => {
2428
if (searchQuery.trim().length > 0) {
@@ -156,7 +160,7 @@
156160
bind:open={showDeleteDialog}
157161
title="Delete Conversation"
158162
description={selectedConversation
159-
? `Are you sure you want to delete "${selectedConversation.name}"? This action cannot be undone and will permanently remove all messages in this conversation.`
163+
? `Are you sure you want to delete "${selectedConversationNamePreview}"? This action cannot be undone and will permanently remove all messages in this conversation.`
160164
: ''}
161165
confirmText="Delete"
162166
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)