From 8ff4ba6c94f35574fc36320c6a702c3c477ebd8d Mon Sep 17 00:00:00 2001 From: Arswarog Date: Wed, 8 Jul 2026 11:12:26 +0300 Subject: [PATCH] =?UTF-8?q?chat/widget:=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D1=8B=D1=85=20=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/chat/Message.module.css | 29 +++++++++++++++++++ plugins/docuservix/widgets/chat/Message.tsx | 21 +++++++++++++- plugins/docuservix/widgets/chat/Messages.tsx | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/plugins/docuservix/widgets/chat/Message.module.css b/plugins/docuservix/widgets/chat/Message.module.css index 4e3d362..0484719 100644 --- a/plugins/docuservix/widgets/chat/Message.module.css +++ b/plugins/docuservix/widgets/chat/Message.module.css @@ -34,6 +34,35 @@ border-bottom-right-radius: 0.25rem; } +.Message__sources { + margin-top: 8px; + padding: 8px 1rem 0; + border-top: 1px solid var(--ifm-color-emphasis-200); +} + +.Message__sourcesLabel { + margin-bottom: 4px; + color: var(--ifm-color-emphasis-600); + font-weight: var(--ifm-font-weight-semibold); + font-size: 0.75rem; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.Message__sourceLink { + display: block; + overflow: hidden; + color: var(--ifm-color-primary); + font-size: 0.8rem; + white-space: nowrap; + text-decoration: none; + text-overflow: ellipsis; +} + +.Message__sourceLink:hover { + text-decoration: underline; +} + @media (max-width: 576px) { .Message { max-width: 100%; diff --git a/plugins/docuservix/widgets/chat/Message.tsx b/plugins/docuservix/widgets/chat/Message.tsx index a09498f..fa120bd 100644 --- a/plugins/docuservix/widgets/chat/Message.tsx +++ b/plugins/docuservix/widgets/chat/Message.tsx @@ -1,8 +1,11 @@ +import Link from '@docusaurus/Link'; import block from 'bem-css-modules'; import React, { ReactNode } from 'react'; import { MD } from '@docuservix/entities/markdown'; +import { IChatSource, sourceToPath, sourceToUrl } from '@docuservix/models/chat'; + import styles from './Message.module.css'; const b = block(styles, 'Message'); @@ -10,14 +13,30 @@ const b = block(styles, 'Message'); interface MessageProps { role: 'user' | 'assistant'; content: string; + sources?: IChatSource[]; } -export function Message({ role, content }: MessageProps): ReactNode { +export function Message({ role, content, sources }: MessageProps): ReactNode { return (
{content}
+ + {sources && sources.length > 0 && ( +
+
Источники:
+ {sources.map((src, j) => ( + + {src.heading || sourceToPath(src.file)} + + ))} +
+ )}
); } diff --git a/plugins/docuservix/widgets/chat/Messages.tsx b/plugins/docuservix/widgets/chat/Messages.tsx index 776b728..878332f 100644 --- a/plugins/docuservix/widgets/chat/Messages.tsx +++ b/plugins/docuservix/widgets/chat/Messages.tsx @@ -21,6 +21,7 @@ export function Messages({ messages, typing }: MessagesProps): ReactNode { key={i} role={msg.role} content={msg.content} + sources={msg.sources} /> ))}