Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

1.1 KB
Raw Blame
/**
 * InlineCommentBubble - floating button shown when text is selected in JSON view
 *
 * Appears near the selection and allows user to add an inline comment.
 */

import { Button } from "@/src/components/ui/button";
import { MessageSquarePlus } from "@langfuse/icons";

interface InlineCommentBubbleProps {
  onAddComment: () => void;
  positionRect: DOMRect;
}

export function InlineCommentBubble({
  onAddComment,
  positionRect,
}: InlineCommentBubbleProps) {
  const handleClick = () => {
    onAddComment();
  };

  return (
    <div
      style={{
        position: "fixed",
        top: positionRect.top - 6,
        left: positionRect.left,
        transform: "translateY(-100%)",
        zIndex: 50,
      }}
      className="animate-in fade-in-0 zoom-in-95 duration-100"
    >
      <Button
        size="xs"
        variant="secondary"
        onClick={handleClick}
        className="border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground border px-3 py-2.5 shadow-md"
      >
        <MessageSquarePlus size="sm" />
        <span className="ml-1">Comment</span>
      </Button>
    </div>
  );
}