From 3c2b29456ac7071f40ed0261a969ae507a14ca3b Mon Sep 17 00:00:00 2001 From: wizardchen Date: Wed, 22 Apr 2026 15:37:07 +0800 Subject: [PATCH] feat: Refactor wiki citation handling in chat bubbles for improved consistency - Simplified the rendering of wiki citations in chat bubbles by removing truncation and inline pill styles, replacing them with a standard link format. - Updated CSS styles to reflect the new inline link design, featuring a brand-blue dashed underline for better visual integration with surrounding text. - Enhanced accessibility by maintaining the use of the `data-slug` attribute for interaction handling. These changes streamline the presentation of wiki citations, improving user experience and visual consistency across the chat interface. --- .../chat/components/AgentStreamDisplay.vue | 66 +++++-------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index 652a3216..7e157b77 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -1647,27 +1647,9 @@ const preprocessMarkdown = (contentStr: string): string => { // as such, so the chat bubble must match. if (!slug) return match; - // Truncate long wiki labels the same way KB citations do, so both - // kinds of citation pills stay visually consistent in narrow bubbles. - const truncateMiddle = (text: string, maxLength = 13): string => { - if (!text) return ''; - if (text.length <= maxLength) return text; - const half = Math.floor((maxLength - 3) / 2); - const start = text.slice(0, half + ((maxLength - 3) % 2)); - const end = text.slice(-half); - return `${start}...${end}`; - }; - const safeSlug = escapeHtml(slug); - const safeDisplay = escapeHtml(truncateMiddle(display)); - const tipSlug = escapeHtml(slug); - const tipDisplay = escapeHtml(display); - // Render as the same pill shape the KB citation uses (class - // `citation citation-wiki`) so the two retrieval sources share a - // single visual language. Anchor tag is kept for accessibility - // and keyboard handling; `data-slug` is preserved for the - // existing click/keyboard handlers above. - return `${safeDisplay}${tipDisplay}${tipSlug}`; + const safeDisplay = escapeHtml(display); + return `${safeDisplay}`; } ); }; @@ -3065,13 +3047,6 @@ const handleAddToKnowledge = (answerEvent: any) => { background-image: url("../../../assets/img/zhishiku-thin.svg"); } -/* Wiki page icon — inline open-book SVG tinted brand blue (matches - .citation-wiki text color). Inlined as a data URI so no new asset - file is required. */ -:deep(.citation .citation-icon.wiki) { - background-image: url("data:image/svg+xml;utf8,"); -} - .kb-float-popup { position: absolute; z-index: 10000; @@ -3165,38 +3140,27 @@ const handleAddToKnowledge = (answerEvent: any) => { pointer-events: none; } -/* Wiki citation pill — same shape as KB / web citations but in brand blue - so the reader can tell at a glance whether evidence came from a - wiki-synthesized page or from a raw source chunk. */ -:deep(.citation.citation-wiki) { - background: var(--td-brand-color-light); +/* Inline wiki link style for chat bubbles — brand-blue dashed underline, + matching the style used inside the wiki drawer. Rendered inline with + the surrounding text, NOT as a pill, so it reads like a regular link. */ +:deep(a.wiki-content-link) { color: var(--td-brand-color); - border: 1px solid var(--td-brand-color-focus); + text-decoration: none; + border-bottom: 1px dashed var(--td-brand-color); cursor: pointer; - white-space: nowrap; - position: relative; - text-decoration: none; - transition: all 0.2s ease; + font-weight: 500; + transition: border-bottom-style 0.15s ease; } -:deep(.citation.citation-wiki:hover) { - background: var(--td-brand-color-light); - border-color: var(--td-brand-color); - color: var(--td-brand-color); - text-decoration: none; +:deep(a.wiki-content-link:hover) { + border-bottom-style: solid; + text-decoration: none !important; } -:deep(.citation.citation-wiki:focus-visible) { +:deep(a.wiki-content-link:focus-visible) { outline: 2px solid var(--td-brand-color); outline-offset: 2px; -} - -/* Embedded tooltip bubble — hidden; relies on browser-native `title` - attribute for hover preview. Keeps parity with citation-kb, which - also hides its inline tip in favor of the floatPopup. */ -:deep(.citation.citation-wiki .citation-tip) { - display: none !important; - pointer-events: none; + border-radius: 2px; } .tool-arguments-wrapper {