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>
This commit is contained in:
Pascal 2025-12-15 16:34:53 +01:00 committed by GitHub
parent 165caaf5fb
commit 0f4f35e7be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 38 additions and 12 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { RemoveButton } from '$lib/components/app'; import { RemoveButton } from '$lib/components/app';
import { getFileTypeLabel, getPreviewText, formatFileSize, isTextFile } from '$lib/utils'; import { formatFileSize, getFileTypeLabel, getPreviewText, isTextFile } from '$lib/utils';
import { AttachmentType } from '$lib/enums'; import { AttachmentType } from '$lib/enums';
interface Props { interface Props {

View File

@ -9,6 +9,7 @@
import Input from '$lib/components/ui/input/input.svelte'; import Input from '$lib/components/ui/input/input.svelte';
import { conversationsStore, conversations } from '$lib/stores/conversations.svelte'; import { conversationsStore, conversations } from '$lib/stores/conversations.svelte';
import { chatStore } from '$lib/stores/chat.svelte'; import { chatStore } from '$lib/stores/chat.svelte';
import { getPreviewText } from '$lib/utils/text';
import ChatSidebarActions from './ChatSidebarActions.svelte'; import ChatSidebarActions from './ChatSidebarActions.svelte';
const sidebar = Sidebar.useSidebar(); const sidebar = Sidebar.useSidebar();
@ -20,6 +21,9 @@
let showEditDialog = $state(false); let showEditDialog = $state(false);
let selectedConversation = $state<DatabaseConversation | null>(null); let selectedConversation = $state<DatabaseConversation | null>(null);
let editedName = $state(''); let editedName = $state('');
let selectedConversationNamePreview = $derived.by(() =>
selectedConversation ? getPreviewText(selectedConversation.name) : ''
);
let filteredConversations = $derived.by(() => { let filteredConversations = $derived.by(() => {
if (searchQuery.trim().length > 0) { if (searchQuery.trim().length > 0) {
@ -162,7 +166,7 @@
bind:open={showDeleteDialog} bind:open={showDeleteDialog}
title="Delete Conversation" title="Delete Conversation"
description={selectedConversation description={selectedConversation
? `Are you sure you want to delete "${selectedConversation.name}"? This action cannot be undone and will permanently remove all messages in this conversation.` ? `Are you sure you want to delete "${selectedConversationNamePreview}"? This action cannot be undone and will permanently remove all messages in this conversation.`
: ''} : ''}
confirmText="Delete" confirmText="Delete"
cancelText="Cancel" cancelText="Cancel"

View File

@ -504,6 +504,14 @@
background: hsl(var(--muted) / 0.1); background: hsl(var(--muted) / 0.1);
} }
/* User message markdown should keep table borders visible on light primary backgrounds */
div.markdown-user-content :global(table),
div.markdown-user-content :global(th),
div.markdown-user-content :global(td),
div.markdown-user-content :global(.table-wrapper) {
border-color: currentColor;
}
/* Horizontal rules */ /* Horizontal rules */
div :global(hr) { div :global(hr) {
border: none; border: none;
@ -642,6 +650,21 @@
background: var(--muted); background: var(--muted);
} }
/* Disable hover effects when rendering user messages */
.markdown-user-content :global(a),
.markdown-user-content :global(a:hover) {
color: var(--primary-foreground);
}
.markdown-user-content :global(table:hover) {
box-shadow: none;
}
.markdown-user-content :global(th:hover),
.markdown-user-content :global(td:hover) {
background: inherit;
}
/* Enhanced blockquotes */ /* Enhanced blockquotes */
div :global(blockquote) { div :global(blockquote) {
transition: all 0.2s ease; transition: all 0.2s ease;

View File

@ -34,12 +34,3 @@ export function getFileTypeLabel(input: string | undefined): string {
// Handle AttachmentType or other plain strings // Handle AttachmentType or other plain strings
return input.toUpperCase(); return input.toUpperCase();
} }
/**
* Truncates text content for preview display
* @param content - The text content to truncate
* @returns Truncated content with ellipsis if needed
*/
export function getPreviewText(content: string): string {
return content.length > 150 ? content.substring(0, 150) + '...' : content;
}

View File

@ -43,7 +43,8 @@ export { createMessageCountMap, getMessageCount } from './conversation-utils';
export { copyToClipboard, copyCodeToClipboard } from './copy'; export { copyToClipboard, copyCodeToClipboard } from './copy';
// File preview utilities // File preview utilities
export { getFileTypeLabel, getPreviewText } from './file-preview'; export { getFileTypeLabel } from './file-preview';
export { getPreviewText } from './text';
// File type utilities // File type utilities
export { export {

View File

@ -0,0 +1,7 @@
/**
* Returns a shortened preview of the provided content capped at the given length.
* Appends an ellipsis when the content exceeds the maximum.
*/
export function getPreviewText(content: string, max = 150): string {
return content.length > max ? content.slice(0, max) + '...' : content;
}