Skip to content

Commit 0f4f35e

Browse files
Fix unreadable user markdown colors and truncate long texts in deletion dialogs (#17555)
* webui: limit conversation name length in dialogs * webui: fix unreadable colors on links and table cell hover in user markdown * webui: keep table borders visible in user markdown * webui: updating unified exports * Update tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentThumbnailFile.svelte Co-authored-by: Aleksander Grygier <aleksander.grygier@gmail.com> * chore: update webui build output * chore: update webui build output * chore: update webui build output --------- Co-authored-by: Aleksander Grygier <aleksander.grygier@gmail.com>
1 parent 165caaf commit 0f4f35e

File tree

7 files changed

+38
-12
lines changed

7 files changed

+38
-12
lines changed

tools/server/public/index.html.gz

1.3 KB
Binary file not shown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { RemoveButton } from '$lib/components/app';
3-
import { getFileTypeLabel, getPreviewText, formatFileSize, isTextFile } from '$lib/utils';
3+
import { formatFileSize, getFileTypeLabel, getPreviewText, isTextFile } from '$lib/utils';
44
import { AttachmentType } from '$lib/enums';
55
66
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/components/app/misc/MarkdownContent.svelte

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@
504504
background: hsl(var(--muted) / 0.1);
505505
}
506506
507+
/* User message markdown should keep table borders visible on light primary backgrounds */
508+
div.markdown-user-content :global(table),
509+
div.markdown-user-content :global(th),
510+
div.markdown-user-content :global(td),
511+
div.markdown-user-content :global(.table-wrapper) {
512+
border-color: currentColor;
513+
}
514+
507515
/* Horizontal rules */
508516
div :global(hr) {
509517
border: none;
@@ -642,6 +650,21 @@
642650
background: var(--muted);
643651
}
644652
653+
/* Disable hover effects when rendering user messages */
654+
.markdown-user-content :global(a),
655+
.markdown-user-content :global(a:hover) {
656+
color: var(--primary-foreground);
657+
}
658+
659+
.markdown-user-content :global(table:hover) {
660+
box-shadow: none;
661+
}
662+
663+
.markdown-user-content :global(th:hover),
664+
.markdown-user-content :global(td:hover) {
665+
background: inherit;
666+
}
667+
645668
/* Enhanced blockquotes */
646669
div :global(blockquote) {
647670
transition: all 0.2s ease;

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-
}

tools/server/webui/src/lib/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export { createMessageCountMap, getMessageCount } from './conversation-utils';
4343
export { copyToClipboard, copyCodeToClipboard } from './copy';
4444

4545
// File preview utilities
46-
export { getFileTypeLabel, getPreviewText } from './file-preview';
46+
export { getFileTypeLabel } from './file-preview';
47+
export { getPreviewText } from './text';
4748

4849
// File type utilities
4950
export {
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)