refactor(webui): use native link actions and remove website previews (#6391)

* refactor(webui): remove website previews and custom link menus

* docs(webui): focus guide on product-specific usage
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-22 16:34:54 +08:00
1 parent bc5c58d239
commit 08ca3b4525
42 files changed
+179 -1493

No files matched your search

+2 -13
View File
@@ -1,8 +1,7 @@
import { Fragment, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
import { Fragment, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { MoreHorizontal } from "lucide-react";
import { useTranslation } from "react-i18next";
import { MessageBlockMenuActions, MessageBubble, MessageCopyButton } from "@/components/MessageBubble";
import { MessageLinksMenu, useMessageWebLinks } from "@/components/MessageLinksMenu";
import { FallbackResponseSources } from "@/components/ResponseSourceBadge";
import {
AgentActivityCluster,
@@ -395,7 +394,6 @@ interface ThreadDisplayUnitProps {
interface MessageBlockMenuProps {
mobileActions: boolean;
messageRoot: RefObject<HTMLElement>;
message: UIMessage;
isTurnStreaming: boolean;
contextBlockKey: string;
@@ -414,7 +412,6 @@ interface MessageBlockMenuProps {
function MessageBlockMenu({
mobileActions,
messageRoot,
message,
isTurnStreaming,
contextBlockKey,
@@ -428,9 +425,6 @@ function MessageBlockMenu({
const { t } = useTranslation();
const contentRef = useRef<HTMLDivElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const links = useMessageWebLinks(messageRoot, open);
const [linksShown, setLinksShown] = useState(false);
useEffect(() => { if (!open) setLinksShown(false); }, [open]);
const [triggerHeight, setTriggerHeight] = useState(28);
useLayoutEffect(() => {
const trigger = triggerRef.current;
@@ -451,16 +445,12 @@ function MessageBlockMenu({
// Re-evaluated when this message becomes active, including after an overnight idle.
const shortTime = mobileActions ? "" : formatMessageHoverTime(timestamp);
const fullTime = shortTime ? fmtDateTime(timestamp) : "";
const actions = linksShown && links.length > 0 ? <MessageLinksMenu links={links}
expanded={mobileActions}
onBack={() => { setLinksShown(false); contentRef.current?.focus({ preventScroll: true }); }}
onClose={() => onOpenChange(false)} /> : <MessageBlockMenuActions
const actions = <MessageBlockMenuActions
message={message}
isTurnStreaming={isTurnStreaming}
onForkFromHere={onForkFromHere ? () => { if (mobileActions) onOpenChange(false); onForkFromHere(); } : undefined}
activity={activity}
sheet={mobileActions}
onViewLinks={links.length > 0 ? () => setLinksShown(true) : undefined}
/>;
if (mobileActions) {
return <div data-message-mobile-actions className={cn("mt-1 flex items-center", message.role === "user" ? "me-2 justify-end" : "-ms-2")}>
@@ -665,7 +655,6 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
const blockMenu = unit.type === "message" && contextBlockKey !== undefined ? (
<MessageBlockMenu
mobileActions={mobileActions}
messageRoot={elementRef}
message={unit.message}
isTurnStreaming={isTurnStreaming}
contextBlockKey={contextBlockKey}
+11 -25
View File
@@ -7,9 +7,6 @@ import { FilePreviewAvailabilityProvider } from "@/components/FilePreviewAvailab
import { FilePreviewPanel } from "@/components/FilePreviewPanel";
import { PreviewPane } from "@/components/PreviewPane";
import { FileActionsProvider } from "@/components/FileActions";
import { WebPreviewContext } from "@/components/WebLink";
import { WebPreviewPanel } from "@/components/WebPreviewPanel";
import { parseWebLink } from "@/lib/web-preview";
import { createFilePreviewResource } from "@/lib/file-preview-resource";
import { SessionHandleLabel } from "@/components/SessionHandleLabel";
import { PromptNavigator } from "@/components/thread/PromptNavigator";
@@ -538,7 +535,7 @@ export function ThreadShell({
} | null>(null);
const [heroGreetingKey, setHeroGreetingKey] = useState(randomHeroGreetingKey);
const [submittedViewportTurnId, setSubmittedViewportTurnId] = useState<string | null>(null);
const { state: previewState, openFile, resolveFile, openWeb, selectTab, closeTab, close: closePreview, setWidth: setFilePreviewWidth } =
const { state: previewState, openFile, resolveFile, selectTab, closeTab, close: closePreview, setWidth: setFilePreviewWidth } =
useFilePreviewState(previewSessionKey, filePreviewStore);
const [closingPreview, setClosingPreview] = useState<{ key: string; state: FilePreviewState } | null>(null);
const filePreviewClosing = closingPreview?.key === previewSessionKey;
@@ -1127,13 +1124,6 @@ export function ThreadShell({
loadPreview: filePreviews.load,
}), [resolveFileMetadata, filePreviews]);
const openWebPreview = useCallback((url: string) => {
const parsed = parseWebLink(url);
if (!parsed) return;
cancelPreviewClose();
openWeb(parsed.href);
}, [cancelPreviewClose, openWeb]);
useEffect(() => {
if (!previewOpen || !headerActive) return;
const onKeyDown = (event: KeyboardEvent) => {
@@ -1452,7 +1442,6 @@ export function ThreadShell({
resolve={previewSessionKey ? resolveFilePreviewAvailability : undefined}
>
<FileActionsProvider value={previewSessionKey ? fileActions : undefined}>
<WebPreviewContext.Provider value={previewSessionKey ? openWebPreview : undefined}>
<ThreadViewport
ref={viewportRef}
messages={displayMessages}
@@ -1485,7 +1474,6 @@ export function ThreadShell({
onForkFromMessage={onForkChat ? handleForkFromMessage : undefined}
onQuoteSelection={session ? handleQuoteSelection : undefined}
/>
</WebPreviewContext.Provider>
</FileActionsProvider>
</FilePreviewAvailabilityProvider>
</div>
@@ -1515,18 +1503,16 @@ export function ThreadShell({
onClose={handleCloseFilePreview}
onResizeStart={handleFilePreviewResizeStart}
>
{activePreview.kind === "file" ? (
<FilePreviewPanel
key={activePreview.id}
sessionKey={previewSessionKey}
path={activePreview.value}
token={token}
loadPreview={filePreviews.load}
initialPreview={filePreviews.peek(activePreview.value)}
onOpenFilePreview={openFilePreview}
onResolvePath={resolveFile}
/>
) : <WebPreviewPanel key={activePreview.id} url={activePreview.value} />}
<FilePreviewPanel
key={activePreview.id}
sessionKey={previewSessionKey}
path={activePreview.value}
token={token}
loadPreview={filePreviews.load}
initialPreview={filePreviews.peek(activePreview.value)}
onOpenFilePreview={openFilePreview}
onResolvePath={resolveFile}
/>
</PreviewPane>
</FileActionsProvider>
) : null}