File tree Expand file tree Collapse file tree 4 files changed +14
-11
lines changed
tools/server/webui/src/lib Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 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 {
Original file line number Diff line number Diff line change 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 ();
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 ) {
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"
Original file line number Diff line number Diff line change @@ -21,12 +21,3 @@ export function formatFileSize(bytes: number): string {
2121export 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- }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments