feat: adjust tooltip position

This commit is contained in:
Li Xin 2025-05-01 11:42:36 +08:00
parent 63a7de2ec0
commit a21dff27bb
2 changed files with 22 additions and 8 deletions

View File

@ -37,7 +37,7 @@ import { useIntersectionObserver } from "~/hooks/use-intersection-observer";
import { Tooltip } from "./tooltip"; import { Tooltip } from "./tooltip";
const ROW_HEIGHT = 80; const ROW_HEIGHT = 85;
const ROW_1 = 0; const ROW_1 = 0;
const ROW_2 = ROW_HEIGHT; const ROW_2 = ROW_HEIGHT;
const ROW_3 = ROW_HEIGHT * 2; const ROW_3 = ROW_HEIGHT * 2;
@ -210,23 +210,26 @@ const WORKFLOW_STEPS = [
{ {
description: description:
"The Coordinator is responsible for engaging with the user to understand their problem and requirements.", "The Coordinator is responsible for engaging with the user to understand their problem and requirements.",
tooltipPosition: "right",
activeNodes: ["Start", "Coordinator"], activeNodes: ["Start", "Coordinator"],
activeEdges: ["Start->Coordinator"], activeEdges: ["Start->Coordinator"],
}, },
{ {
description: description:
"If the user's problem is clearly defined, the Coordinator will hand it over to the Planner.", "If the user's problem is clearly defined, the Coordinator will hand it over to the Planner.",
tooltipPosition: "left",
activeNodes: ["Coordinator", "Planner"], activeNodes: ["Coordinator", "Planner"],
activeEdges: ["Coordinator->Planner"], activeEdges: ["Coordinator->Planner"],
tooltipPosition: "left",
}, },
{ {
description: "Awaiting human feedback to refine the plan.", description: "Awaiting human feedback to refine the plan.",
tooltipPosition: "left",
activeNodes: ["Planner", "HumanFeedback"], activeNodes: ["Planner", "HumanFeedback"],
activeEdges: ["Planner->HumanFeedback"], activeEdges: ["Planner->HumanFeedback"],
}, },
{ {
description: "Updating the plan based on human feedback.", description: "Updating the plan based on human feedback.",
tooltipPosition: "left",
activeNodes: ["HumanFeedback", "Planner"], activeNodes: ["HumanFeedback", "Planner"],
activeEdges: ["HumanFeedback->Planner"], activeEdges: ["HumanFeedback->Planner"],
}, },
@ -240,32 +243,34 @@ const WORKFLOW_STEPS = [
{ {
description: description:
"The Researcher is responsible for gathering information using search and crawling tools.", "The Researcher is responsible for gathering information using search and crawling tools.",
tooltipPosition: "bottom", tooltipPosition: "left",
activeNodes: ["ResearchTeam", "Researcher"], activeNodes: ["ResearchTeam", "Researcher"],
activeEdges: ["ResearchTeam->Researcher", "Researcher->ResearchTeam"], activeEdges: ["ResearchTeam->Researcher", "Researcher->ResearchTeam"],
}, },
{ {
description: description:
"The Coder is responsible for writing and executing Python code to solve problems such as mathematical computations, data analysis, and more.", "The Coder is responsible for writing Python code to solve math problems, data analysis, and more.",
tooltipPosition: "bottom", tooltipPosition: "right",
activeNodes: ["ResearchTeam", "Coder"], activeNodes: ["ResearchTeam", "Coder"],
activeEdges: ["ResearchTeam->Coder", "Coder->ResearchTeam"], activeEdges: ["ResearchTeam->Coder", "Coder->ResearchTeam"],
}, },
{ {
description: description:
"Once the research tasks are completed, the Researcher will hand over to the Planner.", "Once the research tasks are completed, the Researcher will hand over to the Planner.",
tooltipPosition: "bottom", tooltipPosition: "left",
activeNodes: ["ResearchTeam", "Planner"], activeNodes: ["ResearchTeam", "Planner"],
activeEdges: ["ResearchTeam->Planner"], activeEdges: ["ResearchTeam->Planner"],
}, },
{ {
description: description:
"If no additional information is required, the Planner will handoff to the Reporter.", "If no additional information is required, the Planner will handoff to the Reporter.",
tooltipPosition: "right",
activeNodes: ["Reporter", "Planner"], activeNodes: ["Reporter", "Planner"],
activeEdges: ["Planner->Reporter"], activeEdges: ["Planner->Reporter"],
}, },
{ {
description: "The Reporter will prepare a report summarizing the results.", description: "The Reporter will prepare a report summarizing the results.",
tooltipPosition: "bottom",
activeNodes: ["End", "Reporter"], activeNodes: ["End", "Reporter"],
activeEdges: ["Reporter->End"], activeEdges: ["Reporter->End"],
}, },
@ -448,7 +453,11 @@ function AgentNode({
/> />
)} )}
<Tooltip <Tooltip
className="max-w-50 opacity-66" className="max-w-50 text-[15px] opacity-70"
style={{
["--primary" as string]: "#333",
["--primary-foreground" as string]: "white",
}}
open={data.active && !!data.stepDescription} open={data.active && !!data.stepDescription}
title={data.stepDescription} title={data.stepDescription}
side={data.stepTooltipPosition} side={data.stepTooltipPosition}

View File

@ -1,6 +1,8 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates // Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import type { CSSProperties } from "react";
import { import {
Tooltip as ShadcnTooltip, Tooltip as ShadcnTooltip,
TooltipContent, TooltipContent,
@ -10,6 +12,7 @@ import { cn } from "~/lib/utils";
export function Tooltip({ export function Tooltip({
className, className,
style,
children, children,
title, title,
open, open,
@ -17,6 +20,7 @@ export function Tooltip({
sideOffset, sideOffset,
}: { }: {
className?: string; className?: string;
style?: CSSProperties;
children: React.ReactNode; children: React.ReactNode;
title?: React.ReactNode; title?: React.ReactNode;
open?: boolean; open?: boolean;
@ -27,9 +31,10 @@ export function Tooltip({
<ShadcnTooltip delayDuration={750} open={open}> <ShadcnTooltip delayDuration={750} open={open}>
<TooltipTrigger asChild>{children}</TooltipTrigger> <TooltipTrigger asChild>{children}</TooltipTrigger>
<TooltipContent <TooltipContent
className={cn(className)}
style={style}
side={side} side={side}
sideOffset={sideOffset} sideOffset={sideOffset}
className={cn(className)}
> >
{title} {title}
</TooltipContent> </TooltipContent>