refactor(webui): unify code and diff highlighting (#6412)

* refactor(webui): unify code and diff highlighting

Replace Prism with shared Highlights tokens and Pierre read-only diffs, retaining rare grammars through lazy Shiki and preserving source, copy, preview and diff controls.

Restore single-session Composer ownership inside the conversation column while retaining the shared multi-pane footer. Keep the measured large-diff scroll regression explicit during review.

* fix(webui): contain highlighting errors and retain diff selections

Refs NAN-343

* test(webui): align pane fixtures after main rebase

* chore(webui): update highlighting dependencies

Keep grammar fallback coverage on a language that still requires Shiki, and align reading-size assertions with main.
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-06 16:41:12 +08:00
1 parent f5c359476b
commit 3a37269f3f
44 files changed
+2261 -1072

No files matched your search

@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
import { PromptRail } from "@/components/thread/PromptRail";
import { SubagentThreadMessages, useHasSubagentResults } from "@/components/thread/SubagentTaskResults";
import { DiagramScope } from "@/components/markdown-diagrams/context";
import { DiffViewportContext } from "./activity/DiffViewportContext";
import { ThreadHistoryStatus } from "@/components/thread/ThreadHistoryStatus";
import { isAgentActivityMember } from "@/components/thread/AgentActivityCluster";
import { ThreadCameraController } from "@/components/thread/thread-camera";
@@ -306,6 +307,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
const contentRef = useRef<HTMLDivElement>(null);
const messageRegionRef = useRef<HTMLDivElement | null>(null);
const messageContentRef = useRef<HTMLDivElement>(null);
const diffViewport = useMemo(() => ({ scroller: messageRegionRef, content: messageContentRef }), []);
const emptyStateRef = useRef<HTMLDivElement>(null);
const composerDockRef = useRef<HTMLDivElement>(null);
const composerLayoutChangeRef = useRef(onComposerLayoutChange);
@@ -1211,6 +1213,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
)}
>
<div ref={messageContentRef} className="w-full">
<DiffViewportContext.Provider value={diffViewport}>
<DiagramScope identity={conversationKey}>
<SubagentThreadMessages
key={messagesKey}
@@ -1239,6 +1242,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
onActivityToggle={yieldCameraToUser}
/>
</DiagramScope>
</DiffViewportContext.Provider>
</div>
<div aria-hidden className="thread-message-end-gap shrink-0" />
<div ref={bottomRef} aria-hidden className="h-px shrink-0" />