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:
1 parent
bc5c58d239
commit
08ca3b4525
42 files changed
+179
-1493
No files matched your search
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user