Skip to content

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

1.5 KB
Raw Blame
import React from "react";
import { Combine, Route, type IconComponent } from "@langfuse/icons";

import { Tabs } from "@/src/components/design-system/Tabs/Tabs";
import { type GraphViewMode } from "../types";

/**
 * Segmented mode switch overlaid on the graph canvas.
 */
const MODES: {
  mode: GraphViewMode;
  icon: IconComponent;
  label: string;
  title: string;
}[] = [
  {
    mode: "aggregated",
    icon: Combine,
    label: "Aggregated",
    title: "Repeated steps grouped into one node — the overall shape",
  },
  {
    mode: "expanded",
    icon: Route,
    label: "Expanded",
    title: "Every call as its own node, in the order it ran",
  },
];

export function GraphViewModeSwitch({
  value,
  onChange,
}: {
  value: GraphViewMode;
  onChange: (mode: GraphViewMode) => void;
}) {
  return (
    <div className="bg-background/80 rounded-md backdrop-blur">
      <Tabs
        value={value}
        onValueChange={(mode) => onChange(mode as GraphViewMode)}
      >
        <Tabs.List variant="inset" size="md" aria-label="Graph mode">
          {MODES.map(({ mode, icon: Icon, label, title }) => (
            <Tabs.Trigger key={mode} value={mode} title={title}>
              <Icon aria-hidden="true" size="base" />
              {/* Icons only on narrow canvases so the switch never collides
                  with the zoom stack. */}
              <span className="@max-[340px]/graphcanvas:sr-only">{label}</span>
            </Tabs.Trigger>
          ))}
        </Tabs.List>
      </Tabs>
    </div>
  );
}