Skip to content

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

feat(evals): add next-step state line to evaluator setup footer (#16817)

Tobias Wochingerda05c4fbf28a
diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooter.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooter.tsx
index f1ece852d8..d274e06d99 100644
--- a/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooter.tsx
+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooter.tsx
@@ -1,14 +1,9 @@
import { useStore } from "zustand";
import { useShallow } from "zustand/react/shallow";
-import { Button } from "@/src/components/ui/button";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/src/components/ui/tooltip";
import { prepareEvaluatorDraft } from "@/src/features/evals/v2/fns/evaluators/prepareEvaluatorDraft";
import { getScoreOutputValidation } from "@/src/features/evals/v2/fns/scoreOutput/getScoreOutputValidation";
import type { EvaluatorSetupStore } from "@/src/features/evals/v2/store/evaluatorSetupStore/evaluatorSetupStore";
+import { EvaluatorSetupFooterView } from "./EvaluatorSetupFooterView";
export function EvaluatorSetupFooter({
store,
@@ -64,44 +59,32 @@ export function EvaluatorSetupFooter({
: codeValidation && !codeValidation.isPending && !codeValidation.isValid
? "Fix the code validation errors before saving."
: null;
- const saveButton = (
- <Button
- type="button"
- disabled={
- !canSubmit ||
- Boolean(
- codeValidation &&
- (codeValidation.isPending || !codeValidation.isValid),
- ) ||
- (nameMissing && !nameAIAssistanceAvailable) ||
- (isEditing && !hasUnsavedChanges) ||
- isSaving
- }
- loading={isSaving}
- className={disabledReason ? "pointer-events-none" : undefined}
- onClick={onSave}
- >
- {isEditing ? "Save changes" : "Create evaluator"}
- </Button>
- );
+ const saveDisabled =
+ !canSubmit ||
+ Boolean(
+ codeValidation && (codeValidation.isPending || !codeValidation.isValid),
+ ) ||
+ (nameMissing && !nameAIAssistanceAvailable) ||
+ (isEditing && !hasUnsavedChanges) ||
+ isSaving;
+
+ const sharedProps = {
+ closeLabel: hasUnsavedChanges ? "Cancel" : "Close",
+ saveLabel: isEditing ? "Save changes" : "Create evaluator",
+ isSaving,
+ saveDisabled,
+ disabledReason,
+ onClose,
+ onSave,
+ };
+
+ if (isEditing) {
+ return <EvaluatorSetupFooterView mode="edit" {...sharedProps} />;
+ }
return (
- <div className="flex shrink-0 justify-end gap-2 border-t px-6 py-3">
- <Button type="button" variant="outline" onClick={onClose}>
- {hasUnsavedChanges ? "Cancel" : "Close"}
- </Button>
- {disabledReason ? (
- <Tooltip>
- <TooltipTrigger asChild>
- <span className="inline-flex cursor-not-allowed" tabIndex={0}>
- {saveButton}
- </span>
- </TooltipTrigger>
- <TooltipContent>{disabledReason}</TooltipContent>
- </Tooltip>
- ) : (
- saveButton
- )}
- </div>
+ <EvaluatorSetupFooterView mode="create" {...sharedProps}>
+ Next: attach a rule to run this evaluator on incoming observations.
+ </EvaluatorSetupFooterView>
);
}
diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.stories.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.stories.tsx
new file mode 100644
index 0000000000..c9ea6d8387
--- /dev/null
+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.stories.tsx
@@ -0,0 +1,50 @@
+import { fn } from "storybook/test";
+
+import preview from "../../../../../../../.storybook/preview";
+import { EvaluatorSetupFooterView } from "./EvaluatorSetupFooterView";
+
+const meta = preview.meta({ component: EvaluatorSetupFooterView });
+
+const createNextStep =
+ "Next: attach a rule to run this evaluator on incoming observations.";
+
+export const Default = meta.story({
+ args: {
+ mode: "create",
+ children: createNextStep,
+ closeLabel: "Close",
+ saveLabel: "Create evaluator",
+ isSaving: false,
+ saveDisabled: false,
+ disabledReason: null,
+ onClose: fn(),
+ onSave: fn(),
+ },
+});
+
+export const Editing = meta.story({
+ args: {
+ mode: "edit",
+ closeLabel: "Close",
+ saveLabel: "Save changes",
+ isSaving: false,
+ saveDisabled: false,
+ disabledReason: null,
+ onClose: fn(),
+ onSave: fn(),
+ },
+});
+
+export const Disabled = meta.story({
+ args: {
+ mode: "create",
+ children: createNextStep,
+ closeLabel: "Close",
+ saveLabel: "Create evaluator",
+ isSaving: false,
+ saveDisabled: true,
+ disabledReason: "Add an evaluator name before saving.",
+ onClose: fn(),
+ onSave: fn(),
+ },
+});
diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.tsx
new file mode 100644
index 0000000000..b194cf1f2a
--- /dev/null
+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorSetupFooter/EvaluatorSetupFooterView.tsx
@@ -0,0 +1,75 @@
+import type { ReactNode } from "react";
+import { ArrowRight } from "lucide-react";
+import { Button } from "@/src/components/ui/button";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/src/components/ui/tooltip";
+import { cn } from "@/src/utils/tailwind";
+
+type EvaluatorSetupFooterViewBaseProps = {
+ closeLabel: string;
+ saveLabel: string;
+ isSaving: boolean;
+ saveDisabled: boolean;
+ disabledReason: string | null;
+ onClose: () => void;
+ onSave: () => void;
+};
+
+export type EvaluatorSetupFooterViewProps = EvaluatorSetupFooterViewBaseProps &
+ ({ mode: "create"; children: ReactNode } | { mode: "edit" });
+
+export function EvaluatorSetupFooterView(props: EvaluatorSetupFooterViewProps) {
+ const {
+ closeLabel,
+ saveLabel,
+ isSaving,
+ saveDisabled,
+ disabledReason,
+ onClose,
+ onSave,
+ } = props;
+ const saveButton = (
+ <Button
+ type="button"
+ disabled={saveDisabled}
+ loading={isSaving}
+ className={cn("gap-1.5", disabledReason && "pointer-events-none")}
+ onClick={onSave}
+ >
+ {saveLabel}
+ {props.mode === "create" ? (
+ <ArrowRight className="h-4 w-4 shrink-0" aria-hidden="true" />
+ ) : null}
+ </Button>
+ );
+
+ return (
+ <div className="flex shrink-0 items-center gap-4 border-t px-6 py-3">
+ {props.mode === "create" ? (
+ <p className="text-muted-foreground min-w-0 flex-1 text-sm">
+ {props.children}
+ </p>
+ ) : null}
+ <div className="ml-auto flex shrink-0 gap-2">
+ <Button type="button" variant="outline" onClick={onClose}>
+ {closeLabel}
+ </Button>
+ {disabledReason ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex cursor-not-allowed" tabIndex={0}>
+ {saveButton}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>{disabledReason}</TooltipContent>
+ </Tooltip>
+ ) : (
+ saveButton
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx
index 752a887465..dad66b0493 100644
--- a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx
+++ b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx
@@ -182,7 +182,7 @@ function EvaluatorRuleRelationshipsSheet({
<SheetDescription>
{assignments.isPending
? "Loading attached rules…"
- : `This evaluator is used by ${assignmentCount} ${assignmentCount === 1 ? "rule" : "rules"}. Attach it to another rule or remove an existing connection.`}
+ : `This evaluator is used by ${assignmentCount} ${assignmentCount === 1 ? "rule" : "rules"}. Attach it to a rule to run the evaluator on incoming observations.`}
</SheetDescription>
</SheetHeader>
diff --git a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/RuleRelationshipButton.tsx b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/RuleRelationshipButton.tsx
index 458f0394d1..b74255719e 100644
--- a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/RuleRelationshipButton.tsx
+++ b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/RuleRelationshipButton.tsx
@@ -20,7 +20,16 @@ export function RuleRelationshipButton({
onClick: () => void;
}) {
return (
- <Button type="button" variant="outline" onClick={onClick}>
+ <Button
+ type="button"
+ variant="outline"
+ title={
+ shouldCallAttention
+ ? "Attach this evaluator to a rule"
+ : "View attached rules"
+ }
+ onClick={onClick}
+ >
<ListTree className="mr-2 h-4 w-4" />
Rules
{shouldCallAttention ? (
diff --git a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
index 69b42fafd3..700a2a1619 100644
--- a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
+++ b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
@@ -669,6 +669,7 @@ export function EvaluatorSetupPage(
<Button
type="button"
variant="outline"
+ title="View version history"
onClick={() => {
capture("evaluators:version_history_interaction", {
action: "open",