🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(v4): route AI-disabled eval migrations to wizard (#15894)
marliessophie4329b22a6035
diff --git a/web/src/components/table/peek/peek-evaluator-config-detail.tsx b/web/src/components/table/peek/peek-evaluator-config-detail.tsxindex a5de0bd46f..53a577691b 100644--- a/web/src/components/table/peek/peek-evaluator-config-detail.tsx+++ b/web/src/components/table/peek/peek-evaluator-config-detail.tsx@@ -9,7 +9,7 @@ import {TooltipContent,TooltipTrigger,} from "@/src/components/ui/tooltip";-import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";+import { V4MigrationEvaluatorUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";import { UserCircle2Icon } from "lucide-react";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { DeleteEvalConfigButton } from "@/src/components/deleteButton";@@ -26,7 +26,6 @@ import { useLazyEvaluatorExecutionCounts } from "@/src/features/evals/hooks/useLimport { TablePeekView } from "@/src/components/table/peek";import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";-import { useCanUseInAppAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";const PeekViewEvaluatorConfigDetail = ({@@ -48,8 +47,6 @@ const PeekViewEvaluatorConfigDetail = ({evaluatorId: evalConfig?.id,evaluator: evalConfig,});- const canUseAgent = useCanUseInAppAgent();-const hasAccess = useHasProjectAccess({ projectId, scope: "evalJob:CUD" });if (!evalConfig) {@@ -121,8 +118,11 @@ const PeekViewEvaluatorConfigDetail = ({</div></div>- {evaluatorRequiresMigration && evalConfig.evalTemplate && canUseAgent && (- <V4MigrationUpdateRequiredBadge />+ {evaluatorRequiresMigration && evalConfig.evalTemplate && (+ <V4MigrationEvaluatorUpdateRequiredBadge+ projectId={projectId}+ evaluatorId={evalConfig.id}+ />)}<EvaluatorPausedCallout projectId={projectId} evalConfig={evalConfig} />diff --git a/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx b/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsxindex 2f10254c33..7728f260be 100644--- a/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx@@ -25,7 +25,12 @@ export function InAppAgentDisabledDialog({<DialogTitle>AI features are disabled</DialogTitle></DialogHeader><DialogBody>- <AIFeaturesDisabledNotice organizationId={organizationId}>+ <AIFeaturesDisabledNotice+ organizationId={organizationId}+ onSettingsOpened={() => {+ onOpenChange(false);+ }}+ >The Langfuse Assistant requires AI features to be enabled for thisorganization.</AIFeaturesDisabledNotice>diff --git a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsxindex 092d7c7cf7..7886975554 100644--- a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx+++ b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx@@ -109,7 +109,8 @@ const EMPTY_BACKGROUND_VIEW: BackgroundExecutionView = {export type InAppAgentEntryPoint =| "top_nav"| "keyboard_shortcut"- | "dashboard_widget";+ | "dashboard_widget"+ | "v4_migration";const getConversationAgentState = (projectId: string,diff --git a/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx b/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsxindex 4ed9deb8de..a3bd477970 100644--- a/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx+++ b/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx@@ -15,9 +15,11 @@ export function openAIFeaturesSettings(organizationId: string) {export function AIFeaturesDisabledNotice({organizationId,children,+ onSettingsOpened,}: {organizationId: string | undefined;children: ReactNode;+ onSettingsOpened?: () => void;}) {const canUpdateOrgSettings = useHasOrganizationAccess({organizationId,@@ -34,7 +36,10 @@ export function AIFeaturesDisabledNotice({</p>{canUpdateOrgSettings && organizationId ? (<Button- onClick={() => openAIFeaturesSettings(organizationId)}+ onClick={() => {+ openAIFeaturesSettings(organizationId);+ onSettingsOpened?.();+ }}variant="outline"size="sm"className="w-fit"diff --git a/web/src/features/v4-migration/EvaluatorMigrationDialog.tsx b/web/src/features/v4-migration/EvaluatorMigrationDialog.tsxnew file mode 100644index 0000000000..e367a17787--- /dev/null+++ b/web/src/features/v4-migration/EvaluatorMigrationDialog.tsx@@ -0,0 +1,244 @@+import { BotMessageSquare, Wrench } from "lucide-react";+import { useState } from "react";+import {+ Dialog,+ DialogBody,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@/src/components/ui/dialog";+import { Button } from "@/src/components/ui/button";+import { CodeBlock } from "@/src/components/design-system/Codeblock/Codeblock";+import {+ useCanUseInAppAgent,+ useInAppAiAgent,+} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";++type EvaluatorMigrationScope = { type: "all" } | { type: "single" };++type EvaluatorMigrationDialogProps = {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ scope: EvaluatorMigrationScope;+ assistantPrompt: string;+ onManualUpgrade: () => void;+ onAssistantStarted: () => void;+};++type SelectedMigrationAction = "assistant";++const ADMIN_REQUEST_MESSAGE =+ "Hi! Could you enable AI features for our Langfuse organization? I need them to use the Assistant to upgrade our deprecated evaluators for v4. Thanks!";++export function EvaluatorMigrationDialog({+ open,+ onOpenChange,+ scope,+ assistantPrompt,+ onManualUpgrade,+ onAssistantStarted,+}: EvaluatorMigrationDialogProps) {+ const canUseAssistant = useCanUseInAppAgent();+ const { organization } = useQueryProjectOrOrganization();+ const { openAssistant, submit } = useInAppAiAgent();+ const canUpdateOrgSettings = useHasOrganizationAccess({+ organizationId: organization?.id,+ scope: "organization:update",+ });+ const [selectedAction, setSelectedAction] =+ useState<SelectedMigrationAction | null>(null);+ const [orgAdminNoticeOpen, setOrgAdminNoticeOpen] = useState(false);++ const aiFeaturesEnabled = Boolean(organization?.aiFeaturesEnabled);+ const isSingleEvaluator = scope.type === "single";+ const showAssistantOption = canUseAssistant;++ const startAssistant = async () => {+ const opened = openAssistant("v4_migration");+ if (!opened) return;++ onAssistantStarted();+ onOpenChange(false);+ await submit(assistantPrompt, { newConversation: true });+ };++ const handleAssistantClick = () => {+ if (!aiFeaturesEnabled && !canUpdateOrgSettings) {+ onOpenChange(false);+ setOrgAdminNoticeOpen(true);+ return;+ }++ setSelectedAction("assistant");+ if (!aiFeaturesEnabled) {+ openAssistant("v4_migration");+ }+ };++ const handleManualClick = () => {+ if (isSingleEvaluator) {+ onManualUpgrade();+ return;+ }+ onManualUpgrade();+ };++ const closeOrgAdminNotice = () => {+ setOrgAdminNoticeOpen(false);+ if (!isSingleEvaluator) {+ onOpenChange(true);+ }+ };++ return (+ <>+ <Dialog+ open={open}+ onOpenChange={(nextOpen) => {+ if (!nextOpen) setSelectedAction(null);+ onOpenChange(nextOpen);+ }}+ >+ <DialogContent>+ <DialogHeader>+ <DialogTitle>+ {selectedAction === "assistant"+ ? "Ready to start your evaluator upgrade?"+ : isSingleEvaluator+ ? "How would you like to upgrade this evaluator?"+ : "How would you like to upgrade your evaluators?"}+ </DialogTitle>+ </DialogHeader>+ <DialogBody className="gap-3">+ {selectedAction === "assistant" ? (+ <p className="text-muted-foreground text-sm">+ {aiFeaturesEnabled+ ? "The Assistant will review your deprecated evaluators and suggest upgrading all of them at once."+ : "Enable AI features in the other tab, then return here to start the upgrade with the Assistant."}+ </p>+ ) : (+ <>+ {showAssistantOption ? (+ <Button+ type="button"+ variant="outline"+ className="h-auto justify-start gap-3 p-4 text-left"+ onClick={handleAssistantClick}+ >+ <BotMessageSquare className="h-5 w-5 shrink-0" />+ <span className="flex flex-col gap-1">+ <span className="font-bold">Use Assistant</span>+ <span className="text-muted-foreground text-sm font-normal">+ Suggest upgrading all deprecated evaluators at once.+ </span>+ </span>+ </Button>+ ) : null}+ <Button+ type="button"+ variant="outline"+ className="h-auto justify-start gap-3 p-4 text-left"+ onClick={handleManualClick}+ >+ <Wrench className="h-5 w-5 shrink-0" />+ <span className="flex flex-col gap-1">+ <span className="font-bold">+ {isSingleEvaluator+ ? "Upgrade just this evaluator"+ : "Upgrade manually"}+ </span>+ <span className="text-muted-foreground text-sm font-normal">+ {isSingleEvaluator ? (+ "Open the evaluator upgrade form."+ ) : (+ <>+ Click evaluators with the Deprecated label to review{" "}+ <br />+ them and start each upgrade individually.+ </>+ )}+ </span>+ </span>+ </Button>+ </>+ )}+ </DialogBody>+ {selectedAction ? (+ <DialogFooter>+ <Button+ type="button"+ variant="outline"+ onClick={() => {+ setSelectedAction(null);+ }}+ >+ Back+ </Button>+ <Button+ type="button"+ onClick={startAssistant}+ disabled={!aiFeaturesEnabled}+ >+ Start upgrade now+ </Button>+ </DialogFooter>+ ) : null}+ </DialogContent>+ </Dialog>++ <Dialog open={orgAdminNoticeOpen} onOpenChange={setOrgAdminNoticeOpen}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>+ Ask your organization admin to enable AI features+ </DialogTitle>+ </DialogHeader>+ <DialogBody className="gap-3">+ <p className="text-muted-foreground text-sm">+ The Assistant can help you upgrade all deprecated evaluators at+ once. An organization admin needs to enable AI features for your+ organization before you can use it.+ </p>+ <a+ href="https://langfuse.com/security/ai-features"+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary text-sm underline"+ >+ Learn more about AI features+ </a>+ <div className="flex flex-col gap-2">+ <p className="text-muted-foreground text-sm">+ You can send your admin this message:+ </p>+ <CodeBlock language="text" value={ADMIN_REQUEST_MESSAGE} />+ </div>+ </DialogBody>+ <DialogFooter>+ <Button+ type="button"+ variant="outline"+ onClick={closeOrgAdminNotice}+ >+ Close+ </Button>+ {isSingleEvaluator ? (+ <Button+ type="button"+ onClick={() => {+ setOrgAdminNoticeOpen(false);+ onManualUpgrade();+ }}+ >+ Start manual upgrade+ </Button>+ ) : null}+ </DialogFooter>+ </DialogContent>+ </Dialog>+ </>+ );+}diff --git a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsxindex 30bcf9a61f..d46ca5fb3f 100644--- a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx+++ b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx@@ -19,7 +19,7 @@ import { type V4MigrationSdkState } from "./sdkVersionStatus";const mocks = vi.hoisted(() => ({routerPush: vi.fn(),- setAgentOpen: vi.fn(),+ openAssistant: vi.fn(),submitAgentMessage: vi.fn(),upgradePlan: {canUseAssistant: true,@@ -53,6 +53,8 @@ const mocks = vi.hoisted(() => ({},canToggleV4: true,hasApiKeyCreateAccess: true,+ canUpdateOrgSettings: true,+ aiFeaturesEnabled: true,createProjectApiKey: vi.fn(),}));@@ -89,12 +91,22 @@ vi.mock("@/src/utils/api", () => ({vi.mock("@/src/features/projects/hooks", () => ({useProject: () => ({ organization: { id: "org-1" } }),+ useQueryProjectOrOrganization: () => ({+ organization: {+ id: "org-1",+ aiFeaturesEnabled: mocks.aiFeaturesEnabled,+ },+ }),}));vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({useHasProjectAccess: () => mocks.hasApiKeyCreateAccess,}));+vi.mock("@/src/features/rbac/utils/checkOrganizationAccess", () => ({+ useHasOrganizationAccess: () => mocks.canUpdateOrgSettings,+}));+vi.mock("@/src/features/v4-migration/hooks/useV4MigrationData", () => ({useProjectV4MigrationData: () => mocks.migrationData,useProjectV4SdkData: () => mocks.migrationData.sdk,@@ -110,7 +122,7 @@ vi.mock("@/src/features/v4-migration/useV4UpgradeAssistantSupport", () => ({vi.mock("@/src/features/in-app-agent/components/InAppAiAgentProvider", () => ({useCanUseInAppAgent: () => true,useInAppAiAgent: () => ({- setOpen: mocks.setAgentOpen,+ openAssistant: mocks.openAssistant,submit: mocks.submitAgentMessage,}),}));@@ -150,6 +162,8 @@ describe("V4MigrationDetailsContent", () => {};mocks.migrationData.experimentInstrumentationUpgradePath = null;mocks.canToggleV4 = true;+ mocks.canUpdateOrgSettings = true;+ mocks.aiFeaturesEnabled = true;mocks.migrationData.sdk.status = "latest";mocks.migrationData.apis = { status: "loaded", count: 1 };mocks.migrationData.exports = { status: "loaded", count: 3 };@@ -305,44 +319,60 @@ describe("V4MigrationDetailsContent", () => {).not.toBeInTheDocument();});- it("navigates to evals when migrating with the assistant", async () => {+ it("starts the assistant only after confirmation", async () => {mocks.migrationData.evals = { status: "loaded", count: 1 };+ mocks.openAssistant.mockReturnValue(true);render(<V4MigrationDetailsContent projectId="project-1" />);+ fireEvent.click(screen.getByRole("button", { name: "Use Assistant" }));+ const migrationDialog = screen.getByRole("dialog");+ fireEvent.click(+ within(migrationDialog).getByRole("button", {+ name: /^Use Assistant/,+ }),+ );fireEvent.click(- screen.getByRole("button", { name: "Migrate with assistant" }),+ within(migrationDialog).getByRole("button", {+ name: "Start upgrade now",+ }),);await waitFor(() => {- expect(mocks.routerPush).toHaveBeenCalledWith("/project/project-1/evals");+ expect(mocks.openAssistant).toHaveBeenCalledWith("v4_migration");});- expect(mocks.setAgentOpen).toHaveBeenCalledWith(true);expect(mocks.submitAgentMessage).toHaveBeenCalledWith("eval-upgrade-prompt",{ newConversation: true },);});- it("opens the assistant when navigation to evals is interrupted", async () => {+ it("shows the admin handoff after a non-admin chooses the Assistant", () => {mocks.migrationData.evals = { status: "loaded", count: 1 };- mocks.routerPush.mockRejectedValueOnce(- new Error("Abort fetching component for route"),- );+ mocks.canUpdateOrgSettings = false;+ mocks.aiFeaturesEnabled = false;render(<V4MigrationDetailsContent projectId="project-1" />);+ fireEvent.click(screen.getByRole("button", { name: "Use Assistant" }));+ const migrationDialog = screen.getByRole("dialog");fireEvent.click(- screen.getByRole("button", { name: "Migrate with assistant" }),+ within(migrationDialog).getByRole("button", {+ name: /^Use Assistant/,+ }),);- await waitFor(() => {- expect(mocks.setAgentOpen).toHaveBeenCalledWith(true);- });- expect(mocks.submitAgentMessage).toHaveBeenCalledWith(- "eval-upgrade-prompt",- { newConversation: true },- );+ expect(+ screen.getByRole("heading", {+ name: "Ask your organization admin to enable AI features",+ }),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/enable AI features for our Langfuse organization/),+ ).toBeInTheDocument();+ expect(+ screen.queryByRole("button", { name: "Continue with manual upgrade" }),+ ).not.toBeInTheDocument();});});diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsxindex 179521fdb4..e640bb3528 100644--- a/web/src/features/v4-migration/V4MigrationContent.tsx+++ b/web/src/features/v4-migration/V4MigrationContent.tsx@@ -10,7 +10,7 @@ import {LifeBuoy,TriangleAlert,} from "lucide-react";-import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { useCanUseInAppAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { Button } from "@/src/components/ui/button";import { CodeView } from "@/src/components/ui/CodeJsonViewer";@@ -47,6 +47,8 @@ import {} from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api, reportNonTrpcError } from "@/src/utils/api";+import { EvaluatorMigrationDialog } from "@/src/features/v4-migration/EvaluatorMigrationDialog";+import { buildDeprecatedEvaluatorsUrl } from "@/src/features/v4-migration/evaluatorMigrationUrls";// Single source of truth for the v4-migration copy and content. Both surfaces// (side panel and modal) render these components — edit copy here only.@@ -520,25 +522,25 @@ export function V4MigrationDetailsContent({onNavigate?.();openSupportDrawerWithMode("form", { topic: "V4 Migration" });};- const { setOpen: setAgentOpen, submit: submitAgentMessage } =- useInAppAiAgent();+ const canUseAssistant = useCanUseInAppAgent();+ const [evalMigrationDialogOpen, setEvalMigrationDialogOpen] = useState(false);const upgradePlan = useEvalUpgradeAssistantPlan({projectId,orgId: organization?.id,enabled: Boolean(projectId),});const evalsUrl =- typeof projectId === "string" ? `/project/${projectId}/evals` : undefined;- const handleMigrateEvalsWithAgent = async () => {+ typeof projectId === "string"+ ? buildDeprecatedEvaluatorsUrl(projectId)+ : undefined;+ const handleMigrateEvalsWithAgent = () => {capture("v4_migration:migrate_evals_with_agent_clicked");+ setEvalMigrationDialogOpen(true);+ };+ const handleManualEvalUpgrade = () => {+ setEvalMigrationDialogOpen(false);onNavigate?.();- if (evalsUrl) {- await router.push(evalsUrl).catch(() => undefined);- }- setAgentOpen(true);- await submitAgentMessage(upgradePlan.assistantPrompt, {- newConversation: true,- });+ if (evalsUrl) router.push(evalsUrl);};const integrationsUrl =typeof projectId === "string"@@ -629,7 +631,7 @@ export function V4MigrationDetailsContent({</span>. Repointing {migrationData.evals.count === 1 ? "it" : "them"}{" "}at observations or experiments requires minimal changes- {upgradePlan.showAssistantButton+ {canUseAssistant? upgradePlan.mode === "evals-ready"? " — the assistant can do it for you": " — the assistant can help you choose the upgrade order"@@ -637,14 +639,14 @@ export function V4MigrationDetailsContent({.</p><div className="flex items-center gap-3">- {upgradePlan.showAssistantButton && (+ {canUseAssistant && (<Buttonvariant="outline"size="sm"onClick={handleMigrateEvalsWithAgent}><BotMessageSquare className="mr-1.5 h-4 w-4" />- Migrate with assistant+ Use Assistant</Button>)}{evalsUrl ? (@@ -884,6 +886,16 @@ export function V4MigrationDetailsContent({</Button></div></div>+ {projectId ? (+ <EvaluatorMigrationDialog+ open={evalMigrationDialogOpen}+ onOpenChange={setEvalMigrationDialogOpen}+ scope={{ type: "all" }}+ assistantPrompt={upgradePlan.assistantPrompt}+ onManualUpgrade={handleManualEvalUpgrade}+ onAssistantStarted={() => onNavigate?.()}+ />+ ) : null}</>);}diff --git a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx b/web/src/features/v4-migration/V4MigrationDelayBadge.tsxindex d1bb6adfd0..8ef7bbe2ee 100644--- a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx+++ b/web/src/features/v4-migration/V4MigrationDelayBadge.tsx@@ -1,3 +1,5 @@+import { useState } from "react";+import { useRouter } from "next/router";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useQueryProject } from "@/src/features/projects/hooks";@@ -6,12 +8,14 @@ import {useProjectV4EvalData,useProjectV4SdkData,} from "@/src/features/v4-migration/hooks/useV4MigrationData";-import {- useCanUseInAppAgent,- useInAppAiAgent,-} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { useEvalUpgradeAssistantPlan } from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";+import { useCanUseInAppAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { V4MigrationBadgeContent } from "@/src/features/v4-migration/V4MigrationBadgeContent";+import { EvaluatorMigrationDialog } from "@/src/features/v4-migration/EvaluatorMigrationDialog";+import {+ buildDeprecatedEvaluatorsUrl,+ buildEvaluatorUpgradeUrl,+} from "@/src/features/v4-migration/evaluatorMigrationUrls";export function V4MigrationDelayBadge() {const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();@@ -63,15 +67,13 @@ function useEvalUpdateRequiredBadgeState() {return { project, organization, enabled, visible };}-/** Opens the v4 migration drawer if no in-app agent is available, otherwise opens the in-app agent */+/** Opens the evaluator migration choices from the v4 migration badge. */export function V4MigrationUpdateRequiredBadge() {- const openMigrationPanel = useOpenV4MigrationPanel();+ const router = useRouter();+ const [dialogOpen, setDialogOpen] = useState(false);const capture = usePostHogClientCapture();- const canUseAgent = useCanUseInAppAgent();const { project, visible, enabled, organization } =useEvalUpdateRequiredBadgeState();- const { setOpen: setAgentOpen, submit: submitAgentMessage } =- useInAppAiAgent();const upgradePlan = useEvalUpgradeAssistantPlan({projectId: project?.id,orgId: organization?.id,@@ -82,23 +84,91 @@ export function V4MigrationUpdateRequiredBadge() {return null;}- const handleClick = async () => {+ const handleClick = () => {capture("v4_migration:update_required_badge_clicked");- if (canUseAgent) {- setAgentOpen(true);- await submitAgentMessage(upgradePlan.assistantPrompt, {- newConversation: true,- });+ setDialogOpen(true);+ };++ const handleManualUpgrade = () => {+ if (!project) return;+ setDialogOpen(false);+ router.push(buildDeprecatedEvaluatorsUrl(project.id));+ };++ return (+ <>+ <V4MigrationBadgeContent+ onClick={handleClick}+ title="Action required"+ description="Choose how to upgrade"+ />+ <EvaluatorMigrationDialog+ open={dialogOpen}+ onOpenChange={setDialogOpen}+ scope={{ type: "all" }}+ assistantPrompt={upgradePlan.assistantPrompt}+ onManualUpgrade={handleManualUpgrade}+ onAssistantStarted={() => undefined}+ />+ </>+ );+}++/** Opens the evaluator migration choices from an individual evaluator peek. */+export function V4MigrationEvaluatorUpdateRequiredBadge({+ projectId,+ evaluatorId,+}: {+ projectId: string;+ evaluatorId: string;+}) {+ const router = useRouter();+ const [dialogOpen, setDialogOpen] = useState(false);+ const capture = usePostHogClientCapture();+ const canUseAssistant = useCanUseInAppAgent();+ const { organization } = useQueryProject();+ const upgradePlan = useEvalUpgradeAssistantPlan({+ projectId,+ orgId: organization?.id,+ enabled: true,+ });+ const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();++ if (!v4UpgradeUiEnabled) return null;++ const handleManualUpgrade = () => {+ setDialogOpen(false);+ router.push(buildEvaluatorUpgradeUrl(projectId, evaluatorId));+ };++ const handleClick = () => {+ capture("v4_migration:update_required_badge_clicked", {+ scope: "single",+ });+ if (!canUseAssistant) {+ handleManualUpgrade();return;}- openMigrationPanel({ id: project.id, name: project.name });+ setDialogOpen(true);};return (- <V4MigrationBadgeContent- onClick={handleClick}- title="Action required"- description="Start the upgrade now"- />+ <>+ <V4MigrationBadgeContent+ onClick={handleClick}+ title="Action required"+ description={+ canUseAssistant ? "Choose how to upgrade" : "Start upgrade now"+ }+ />+ <EvaluatorMigrationDialog+ open={dialogOpen}+ onOpenChange={setDialogOpen}+ scope={{ type: "single" }}+ assistantPrompt={upgradePlan.assistantPrompt}+ onManualUpgrade={handleManualUpgrade}+ onAssistantStarted={() => undefined}+ />+ </>);}diff --git a/web/src/features/v4-migration/V4MigrationModal.tsx b/web/src/features/v4-migration/V4MigrationModal.tsxindex 6ca929901e..bd069cda09 100644--- a/web/src/features/v4-migration/V4MigrationModal.tsx+++ b/web/src/features/v4-migration/V4MigrationModal.tsx@@ -56,7 +56,7 @@ function V4MigrationModalContent({closeOnInteractionOutside><DialogTitle className="sr-only">- {`Migrate ${project.name} to v4`}+ {`Upgrade ${project.name} to v4`}</DialogTitle><DialogBody className="gap-0 p-4"><V4MigrationHeaderContentdiff --git a/web/src/features/v4-migration/evaluatorMigrationUrls.ts b/web/src/features/v4-migration/evaluatorMigrationUrls.tsnew file mode 100644index 0000000000..a60a2ea38f--- /dev/null+++ b/web/src/features/v4-migration/evaluatorMigrationUrls.ts@@ -0,0 +1,26 @@+import { encodeFiltersGeneric, type FilterState } from "@langfuse/shared";++const DEPRECATED_EVALUATOR_FILTERS: FilterState = [+ {+ column: "target",+ type: "stringOptions",+ operator: "any of",+ value: ["trace", "dataset"],+ },+];++/** Opens the evaluator list with only the deprecated target types visible. */+export function buildDeprecatedEvaluatorsUrl(projectId: string) {+ const filter = encodeURIComponent(+ encodeFiltersGeneric(DEPRECATED_EVALUATOR_FILTERS),+ );++ return `/project/${projectId}/evals?filter=${filter}`;+}++export function buildEvaluatorUpgradeUrl(+ projectId: string,+ evaluatorId: string,+) {+ return `/project/${projectId}/evals/remap?evaluator=${encodeURIComponent(evaluatorId)}`;+}diff --git a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.clienttest.ts b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.clienttest.tsindex e9617d2e59..d6ef7a4749 100644--- a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.clienttest.ts+++ b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.clienttest.ts@@ -1,7 +1,11 @@-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import { V4_CODING_AGENT_PROMPT } from "./useV4UpgradeAssistantSupport";+vi.mock("@/src/features/in-app-agent/components/InAppAiAgentProvider", () => ({+ useCanUseInAppAgent: () => true,+}));+describe("V4_CODING_AGENT_PROMPT", () => {it("hands coding agents off to the canonical v4 migration skill", () => {expect(V4_CODING_AGENT_PROMPT).toContain(diff --git a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.tsindex bb7a079dc3..3dff5db914 100644--- a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts+++ b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts@@ -80,7 +80,7 @@ export function useEvalUpgradeAssistantPlan(params: {return {canUseAssistant,mode,- /** Show the "Migrate with assistant" CTA in the migration panel. */+ /** Whether the migration panel may show the Assistant CTA. */showAssistantButton: canUseAssistant && mode !== "outside",assistantPrompt:mode === "evals-ready"