From 394c012a581b799f6af329470d61ec6cda559c65 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Tue, 3 Feb 2026 14:48:45 +0100 Subject: [PATCH] refactor: Cleanup --- tools/server/webui/src/lib/constants/attachment-labels.ts | 3 +++ .../server/webui/src/lib/markdown/enhance-code-blocks.ts | 4 ++-- tools/server/webui/src/lib/services/chat.service.ts | 8 ++++++-- tools/server/webui/src/lib/stores/chat.svelte.ts | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 tools/server/webui/src/lib/constants/attachment-labels.ts diff --git a/tools/server/webui/src/lib/constants/attachment-labels.ts b/tools/server/webui/src/lib/constants/attachment-labels.ts new file mode 100644 index 0000000000..2a32e4e18b --- /dev/null +++ b/tools/server/webui/src/lib/constants/attachment-labels.ts @@ -0,0 +1,3 @@ +export const ATTACHMENT_LABEL_FILE = 'File'; +export const ATTACHMENT_LABEL_PDF_FILE = 'PDF File'; +export const ATTACHMENT_LABEL_MCP_PROMPT = 'MCP Prompt'; diff --git a/tools/server/webui/src/lib/markdown/enhance-code-blocks.ts b/tools/server/webui/src/lib/markdown/enhance-code-blocks.ts index 67a19b1b57..168de97403 100644 --- a/tools/server/webui/src/lib/markdown/enhance-code-blocks.ts +++ b/tools/server/webui/src/lib/markdown/enhance-code-blocks.ts @@ -107,7 +107,7 @@ function createScrollContainer(preElement: Element): Element { return { type: 'element', tagName: 'div', - properties: { className: ['code-block-scroll-container'] }, + properties: { className: [CODE_BLOCK_SCROLL_CONTAINER_CLASS] }, children: [preElement] }; } @@ -116,7 +116,7 @@ function createWrapper(header: Element, preElement: Element): Element { return { type: 'element', tagName: 'div', - properties: { className: ['code-block-wrapper', 'relative'] }, + properties: { className: [CODE_BLOCK_WRAPPER_CLASS, RELATIVE_CLASS] }, children: [header, createScrollContainer(preElement)] }; } diff --git a/tools/server/webui/src/lib/services/chat.service.ts b/tools/server/webui/src/lib/services/chat.service.ts index ebdd4374f8..9abe0515ff 100644 --- a/tools/server/webui/src/lib/services/chat.service.ts +++ b/tools/server/webui/src/lib/services/chat.service.ts @@ -1,5 +1,9 @@ import { getJsonHeaders, formatAttachmentText, isAbortError } from '$lib/utils'; import { AGENTIC_REGEX } from '$lib/constants/agentic'; +import { + ATTACHMENT_LABEL_PDF_FILE, + ATTACHMENT_LABEL_MCP_PROMPT +} from '$lib/constants/attachment-labels'; import { AttachmentType, ContentPartType, MessageRole, ReasoningFormat } from '$lib/enums'; import type { ApiChatMessageContentPart, ApiChatCompletionToolCall } from '$lib/types/api'; import type { DatabaseMessageExtraMcpPrompt } from '$lib/types'; @@ -764,7 +768,7 @@ export class ChatService { } else { contentParts.push({ type: ContentPartType.TEXT, - text: formatAttachmentText('PDF File', pdfFile.name, pdfFile.content) + text: formatAttachmentText(ATTACHMENT_LABEL_PDF_FILE, pdfFile.name, pdfFile.content) }); } } @@ -778,7 +782,7 @@ export class ChatService { contentParts.push({ type: ContentPartType.TEXT, text: formatAttachmentText( - 'MCP Prompt', + ATTACHMENT_LABEL_MCP_PROMPT, mcpPrompt.name, mcpPrompt.content, mcpPrompt.serverName diff --git a/tools/server/webui/src/lib/stores/chat.svelte.ts b/tools/server/webui/src/lib/stores/chat.svelte.ts index 869206aa70..7bb5e3b5f4 100644 --- a/tools/server/webui/src/lib/stores/chat.svelte.ts +++ b/tools/server/webui/src/lib/stores/chat.svelte.ts @@ -432,7 +432,7 @@ class ChatStore { return await DatabaseService.createMessageBranch( { convId: activeConv.id, - type: 'text', + type: MessageType.TEXT, role: MessageRole.ASSISTANT, content: '', timestamp: Date.now(), @@ -1234,7 +1234,7 @@ class ChatStore { const assistantMessage = await DatabaseService.createMessageBranch( { convId: activeConv.id, - type: 'text', + type: MessageType.TEXT, timestamp: Date.now(), role: MessageRole.ASSISTANT, content: '',