Skip to content

Automate browser based workflows with AI

fix(SKY-6790): truncate long block titles with ellipsis and tooltip (#5714)

Shuchang Zheng3c532b3ea65d
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx
index 4072ece00..30867574b 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/EditableNodeTitle.tsx
@@ -6,7 +6,7 @@ import {
} from "@/components/ui/tooltip";
import { cn } from "@/util/utils";
import { HorizontallyResizingInput } from "./HorizontallyResizingInput";
-import { useState } from "react";
+import { useLayoutEffect, useRef, useState } from "react";
type Props = {
value: string;
@@ -24,6 +24,27 @@ function EditableNodeTitle({
inputClassName,
}: Props) {
const [editing, setEditing] = useState(false);
+ const [isTruncated, setIsTruncated] = useState(false);
+ const titleRef = useRef<HTMLHeadingElement>(null);
+
+ useLayoutEffect(() => {
+ if (editing) {
+ return;
+ }
+ const el = titleRef.current;
+ if (!el) {
+ return;
+ }
+ const measure = () => {
+ setIsTruncated(el.scrollWidth > el.clientWidth);
+ };
+ measure();
+ const observer = new ResizeObserver(measure);
+ observer.observe(el);
+ return () => {
+ observer.disconnect();
+ };
+ }, [value, editing]);
if (!editing) {
return (
@@ -31,7 +52,8 @@ function EditableNodeTitle({
<Tooltip>
<TooltipTrigger asChild>
<h1
- className={cn("cursor-text", titleClassName)}
+ ref={titleRef}
+ className={cn("min-w-0 cursor-text truncate", titleClassName)}
onClick={() => {
setEditing(true);
}}
@@ -39,7 +61,9 @@ function EditableNodeTitle({
{value}
</h1>
</TooltipTrigger>
- <TooltipContent>Click to edit</TooltipContent>
+ <TooltipContent>
+ {isTruncated ? value : "Click to edit"}
+ </TooltipContent>
</Tooltip>
</TooltipProvider>
);
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
index f95f0a81d..2fbaf7aa8 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx
@@ -607,14 +607,14 @@ function NodeHeader({
<header className="!mt-0 flex h-[2.75rem] justify-between gap-2">
<div
- className={cn("flex gap-2", {
+ className={cn("flex min-w-0 gap-2", {
"opacity-50": thisBlockIsPlaying,
})}
>
<div className="flex h-[2.75rem] w-[2.75rem] items-center justify-center rounded border border-slate-600">
<WorkflowBlockIcon workflowBlockType={type} className="size-6" />
</div>
- <div className="flex flex-col gap-1">
+ <div className="flex min-w-0 flex-col gap-1">
<EditableNodeTitle
value={blockLabel}
editable={editable}