fix(ui): P1-1 线程切换残留内容 + P2-5 列表项来源标注渲染
- main.tsx: 切换 threadId 时清空 lastMessagesRef,避免空对话显示上一条对话内容 - MessageBubble.tsx: li 元素增加 renderWithSourceBadges,[工单][知识库] 等标注在列表项中也渲染为彩色 badge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
31bddf4fcd
commit
c610e23931
@@ -501,6 +501,20 @@ export default function MessageBubble({ content: rawContent, role, isStreaming,
|
||||
</ol>
|
||||
);
|
||||
},
|
||||
li({ children }) {
|
||||
const processedChildren = Array.isArray(children)
|
||||
? children.flatMap((child, idx) =>
|
||||
typeof child === "string"
|
||||
? renderWithSourceBadges(child).map((node, ni) =>
|
||||
typeof node === "string" ? node : <span key={`${idx}-${ni}`}>{node}</span>
|
||||
)
|
||||
: [child]
|
||||
)
|
||||
: typeof children === "string"
|
||||
? renderWithSourceBadges(children)
|
||||
: children;
|
||||
return <li>{processedChildren}</li>;
|
||||
},
|
||||
|
||||
// Paragraphs — inline source badges for [知识库] [工单] [网络] [推断]
|
||||
p({ children }) {
|
||||
|
||||
@@ -154,6 +154,12 @@ function App() {
|
||||
|
||||
// ── Active messages ──────────────────────────────────────────────────────
|
||||
const lastMessagesRef = useRef<Message[]>([]);
|
||||
const lastThreadIdRef = useRef<string | null>(null);
|
||||
// Clear stale messages when thread switches to avoid showing previous thread's content
|
||||
if (currentThreadId !== lastThreadIdRef.current) {
|
||||
lastMessagesRef.current = [];
|
||||
lastThreadIdRef.current = currentThreadId;
|
||||
}
|
||||
if (thread.messages.length > 0) {
|
||||
lastMessagesRef.current = thread.messages;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user