🪢 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
refactor(web): Migrate dialogs to `ConfirmationDialogController` (#17541)
Ben Bachem05e1ad162ff8
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsxindex 10e3c76d8e..eb652f77e2 100644--- a/web/src/components/table/use-cases/traces.tsx+++ b/web/src/components/table/use-cases/traces.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-abstracted-overlay-trigger */import { DataTable } from "@/src/components/table/data-table";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import {@@ -106,10 +107,9 @@ import { usePeekTableState } from "@/src/components/table/peek/contexts/PeekTablimport { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController";-import { DialogController } from "@/src/components/ui/dialog";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { DeleteTraceDialogContent } from "@/src/features/traces/components/DeleteTraceDialogContent";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";export type TracesTableRow = {// Shown by default@@ -1621,20 +1621,34 @@ const TracesDynamicCell = ({export default function TracesTable(props: TracesTableProps) {const [traceIdToDelete, setTraceIdToDelete] = useState<string | null>(null);const capture = usePostHogClientCapture();+ const utils = api.useUtils();+ const traceMutation = api.traces.deleteMany.useMutation({+ onSuccess: () => {+ capture("trace:delete", { source: "table-single-row" });+ showSuccessToast({+ title: "Trace deleted",+ description:+ "Selected trace will be deleted. Traces are removed asynchronously and may continue to be visible for up to 24 hours.",+ });+ utils.traces.all.invalidate();+ },+ });return (- <DialogController- closeOnInteractionOutside- size="default"- renderContent={({ closeDialog }) =>- traceIdToDelete ? (- <DeleteTraceDialogContent- closeDialog={closeDialog}- projectId={props.projectId}- traceId={traceIdToDelete}- />- ) : null- }+ <ConfirmationDialogController+ title="Please confirm"+ text="This action cannot be undone. It removes all the data associated with this trace."+ confirmLabel="Delete trace"+ variant="destructive"+ loading={traceMutation.isPending}+ onConfirm={async () => {+ if (!traceIdToDelete) return;++ await traceMutation.mutateAsync({+ traceIds: [traceIdToDelete],+ projectId: props.projectId,+ });+ }}>{({ openDialog }) => (<TracesTableInternal@@ -1648,6 +1662,6 @@ export default function TracesTable(props: TracesTableProps) {}}/>)}- </DialogController>+ </ConfirmationDialogController>);}diff --git a/web/src/ee/features/sso-settings/components/SSOSettings.tsx b/web/src/ee/features/sso-settings/components/SSOSettings.tsxindex 274515e709..65f9e73e3d 100644--- a/web/src/ee/features/sso-settings/components/SSOSettings.tsx+++ b/web/src/ee/features/sso-settings/components/SSOSettings.tsx@@ -1,17 +1,7 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */import { showErrorToast, showSuccessToast } from "@/src/features/notifications";import { Alert } from "@/src/components/design-system/Alert/Alert";-import {- AlertDialog,- AlertDialogAction,- AlertDialogCancel,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,- AlertDialogTrigger,-} from "@/src/components/ui/alert-dialog";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { Badge } from "@/src/components/ui/badge";import { Button } from "@/src/components/ui/button";import { Card } from "@/src/components/ui/card";@@ -288,7 +278,6 @@ function SsoConfigDialog({existing: SsoConfigRow | null;}) {const [dialogOpen, setDialogOpen] = useState(false);- const [confirmOpen, setConfirmOpen] = useState(false);const [pendingValues, setPendingValues] = useState<FormValues | null>(null);const utils = api.useUtils();@@ -340,7 +329,6 @@ function SsoConfigDialog({description: `Active for @${domain} within 1 hour.`,});setDialogOpen(false);- setConfirmOpen(false);setPendingValues(null);form.reset();},@@ -352,12 +340,7 @@ function SsoConfigDialog({},});- function onSubmit(values: FormValues) {- setPendingValues(values);- setConfirmOpen(true);- }-- function handleConfirm() {+ async function handleConfirm() {if (!pendingValues) return;const payload = buildSsoPayload(domain, pendingValues);const parsed = SsoProviderSchema.safeParse(payload);@@ -395,132 +378,93 @@ function SsoConfigDialog({firstIssue.message,);}- setConfirmOpen(false);return;}- saveMutation.mutate({ orgId, payload: parsed.data });+ await saveMutation.mutateAsync({ orgId, payload: parsed.data });}return (- <>- <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>- <DialogTrigger asChild>- <Button size="sm" variant={existing ? "outline" : "default"}>- {existing ? "Update" : "Configure SSO"}- </Button>- </DialogTrigger>- <DialogContent className="sm:max-w-xl">- <DialogHeader>- <DialogTitle>- {existing- ? `Update SSO for ${domain}`- : `Configure SSO for ${domain}`}- </DialogTitle>- </DialogHeader>- <Form {...form}>- <form onSubmit={form.handleSubmit(onSubmit)}>- <DialogBody className="space-y-4">- <FormField- control={form.control}- name="authProvider"- render={({ field }) => (- <FormItem>- <FormLabel>Provider</FormLabel>- <FormControl>- <SelectInput- value={field.value}- onValueChange={field.onChange}- placeholder="Select an SSO provider"- options={SSO_PROVIDERS.map((provider) => ({- value: provider.id,- label: provider.label,- }))}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- <CallbackUrlPanel callbackUrl={callbackUrl} />-- {providerSpec.fields.includes("name") ? (- <FormField- control={form.control}- name="authConfig.name"- render={({ field }) => (- <FormItem>- <FormLabel>Display Name</FormLabel>- <FormControl>- <Input placeholder="Acme SSO" {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- ) : null}-- <FormField- control={form.control}- name="authConfig.clientId"- render={({ field }) => (- <FormItem>- <FormLabel>Client ID</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- <FormField- control={form.control}- name="authConfig.clientSecret"- render={({ field }) => (- <FormItem>- <FormLabel>Client Secret</FormLabel>- <FormControl>- <Input- type="password"- autoComplete="off"- placeholder={- existing ? "Re-enter to update" : undefined- }- {...field}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- {providerSpec.fields.includes("issuer") ? (+ <ConfirmationDialogController+ title={+ existing+ ? `Replace SSO for @${domain}?`+ : `Activate SSO for @${domain}?`+ }+ text={`Saving will activate SSO for @${domain} within 1 hour. Every user at that domain will be redirected to your identity provider on sign-in - they will not be able to use Google, GitHub, password, or any other method until SSO is deleted.${existing ? " The new credentials will replace the active configuration." : ""} Tip: sign in via the new SSO in a second browser to confirm it works before closing this tab.`}+ confirmLabel={existing ? "Replace" : "Activate SSO"}+ variant="default"+ loading={saveMutation.isPending}+ onConfirm={handleConfirm}+ >+ {({ openDialog }) => (+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>+ <DialogTrigger asChild>+ <Button size="sm" variant={existing ? "outline" : "default"}>+ {existing ? "Update" : "Configure SSO"}+ </Button>+ </DialogTrigger>+ <DialogContent className="sm:max-w-xl">+ <DialogHeader>+ <DialogTitle>+ {existing+ ? `Update SSO for ${domain}`+ : `Configure SSO for ${domain}`}+ </DialogTitle>+ </DialogHeader>+ <Form {...form}>+ <form+ onSubmit={form.handleSubmit((values) => {+ setPendingValues(values);+ openDialog();+ })}+ >+ <DialogBody className="space-y-4"><FormFieldcontrol={form.control}- name="authConfig.issuer"+ name="authProvider"render={({ field }) => (<FormItem>- <FormLabel>Issuer URL</FormLabel>+ <FormLabel>Provider</FormLabel><FormControl>- <Input- placeholder="https://example.okta.com"- {...field}+ <SelectInput+ value={field.value}+ onValueChange={field.onChange}+ placeholder="Select an SSO provider"+ options={SSO_PROVIDERS.map((provider) => ({+ value: provider.id,+ label: provider.label,+ }))}/></FormControl><FormMessage /></FormItem>)}/>- ) : null}- {providerSpec.fields.includes("tenantId") ? (+ <CallbackUrlPanel callbackUrl={callbackUrl} />++ {providerSpec.fields.includes("name") ? (+ <FormField+ control={form.control}+ name="authConfig.name"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Display Name</FormLabel>+ <FormControl>+ <Input placeholder="Acme SSO" {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ ) : null}+<FormFieldcontrol={form.control}- name="authConfig.tenantId"+ name="authConfig.clientId"render={({ field }) => (<FormItem>- <FormLabel>Tenant ID</FormLabel>+ <FormLabel>Client ID</FormLabel><FormControl><Input {...field} /></FormControl>@@ -528,18 +472,20 @@ function SsoConfigDialog({</FormItem>)}/>- ) : null}- {providerSpec.fields.includes("baseUrl") ? (<FormFieldcontrol={form.control}- name="authConfig.baseUrl"+ name="authConfig.clientSecret"render={({ field }) => (<FormItem>- <FormLabel>Base URL</FormLabel>+ <FormLabel>Client Secret</FormLabel><FormControl><Input- placeholder="https://github.acme.com"+ type="password"+ autoComplete="off"+ placeholder={+ existing ? "Re-enter to update" : undefined+ }{...field}/></FormControl>@@ -547,94 +493,109 @@ function SsoConfigDialog({</FormItem>)}/>- ) : null}- {selectedProvider === "custom" ? (- <>+ {providerSpec.fields.includes("issuer") ? (<FormFieldcontrol={form.control}- name="authConfig.idToken"+ name="authConfig.issuer"render={({ field }) => (- <FormItem className="flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4">+ <FormItem>+ <FormLabel>Issuer URL</FormLabel><FormControl>- <Checkbox- checked={field.value ?? false}- onCheckedChange={(checked) =>- field.onChange(checked === true)- }+ <Input+ placeholder="https://example.okta.com"+ {...field}/></FormControl>- <div className="space-y-1 leading-none">- <FormLabel>- Use id_token claims only (skip userinfo)- </FormLabel>- <FormDescription>- Leave off for IdPs that release email only via the- userinfo endpoint.- </FormDescription>- </div>+ <FormMessage /></FormItem>)}/>- </>- ) : null}- </DialogBody>- <DialogFooter>- <Button- type="button"- variant="ghost"- onClick={() => setDialogOpen(false)}- >- Cancel- </Button>- <Button type="submit" loading={saveMutation.isPending}>- Save- </Button>- </DialogFooter>- </form>- </Form>- </DialogContent>- </Dialog>-- <AlertDialog open={confirmOpen} onOpenChange={setConfirmOpen}>- <AlertDialogContent>- <AlertDialogHeader>- <AlertDialogTitle>- {existing- ? `Replace SSO for @${domain}?`- : `Activate SSO for @${domain}?`}- </AlertDialogTitle>- <AlertDialogDescription>- <span className="block">- Saving will activate SSO for{" "}- <span className="font-bold">@{domain}</span> within 1 hour.- Every user at that domain will be redirected to your identity- provider on sign-in — they will not be able to use Google,- GitHub, password, or any other method until SSO is deleted.- </span>- {existing ? (- <span className="mt-2 block">- The new credentials will replace the active configuration.- </span>- ) : null}- <span className="mt-2 block">- Tip: sign in via the new SSO in a second browser to confirm it- works before closing this tab.- </span>- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogCancel>Cancel</AlertDialogCancel>- <AlertDialogAction- onClick={handleConfirm}- disabled={saveMutation.isPending}- >- {existing ? "Replace" : "Activate SSO"}- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>- </>+ ) : null}++ {providerSpec.fields.includes("tenantId") ? (+ <FormField+ control={form.control}+ name="authConfig.tenantId"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Tenant ID</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ ) : null}++ {providerSpec.fields.includes("baseUrl") ? (+ <FormField+ control={form.control}+ name="authConfig.baseUrl"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Base URL</FormLabel>+ <FormControl>+ <Input+ placeholder="https://github.acme.com"+ {...field}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ ) : null}++ {selectedProvider === "custom" ? (+ <>+ <FormField+ control={form.control}+ name="authConfig.idToken"+ render={({ field }) => (+ <FormItem className="flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4">+ <FormControl>+ <Checkbox+ checked={field.value ?? false}+ onCheckedChange={(checked) =>+ field.onChange(checked === true)+ }+ />+ </FormControl>+ <div className="space-y-1 leading-none">+ <FormLabel>+ Use id_token claims only (skip userinfo)+ </FormLabel>+ <FormDescription>+ Leave off for IdPs that release email only via+ the userinfo endpoint.+ </FormDescription>+ </div>+ </FormItem>+ )}+ />+ </>+ ) : null}+ </DialogBody>+ <DialogFooter>+ <Button+ type="button"+ variant="ghost"+ onClick={() => setDialogOpen(false)}+ >+ Cancel+ </Button>+ <Button type="submit" loading={saveMutation.isPending}>+ Save+ </Button>+ </DialogFooter>+ </form>+ </Form>+ </DialogContent>+ </Dialog>+ )}+ </ConfirmationDialogController>);}@@ -719,35 +680,27 @@ function DeleteSsoConfigButton({});return (- <AlertDialog>- <AlertDialogTrigger asChild>+ <ConfirmationDialogController+ title={`Remove SSO for @${domain}?`}+ text="Users at this domain will be able to sign in with any enabled method again. Active sessions are not invalidated."+ confirmLabel="Remove"+ variant="destructive"+ loading={deleteMutation.isPending}+ onConfirm={async () => {+ await deleteMutation.mutateAsync({ orgId, domain });+ }}+ >+ {({ openDialog }) => (<Buttonvariant="ghost"size="icon-xs"aria-label={`Delete SSO for ${domain}`}+ onClick={openDialog}><TrashIcon className="h-4 w-4" /></Button>- </AlertDialogTrigger>- <AlertDialogContent>- <AlertDialogHeader>- <AlertDialogTitle>Remove SSO for @{domain}?</AlertDialogTitle>- <AlertDialogDescription>- Users at this domain will be able to sign in with any enabled method- again. Active sessions are not invalidated.- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogCancel>Cancel</AlertDialogCancel>- <AlertDialogAction- onClick={() => deleteMutation.mutate({ orgId, domain })}- disabled={deleteMutation.isPending}- >- Remove- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>+ )}+ </ConfirmationDialogController>);}diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsxindex e2ab775357..d5c218b69a 100644--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx@@ -1,17 +1,7 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */import { showErrorToast, showSuccessToast } from "@/src/features/notifications";import { Alert } from "@/src/components/design-system/Alert/Alert";-import {- AlertDialog,- AlertDialogAction,- AlertDialogCancel,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,- AlertDialogTrigger,-} from "@/src/components/ui/alert-dialog";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { Badge } from "@/src/components/ui/badge";import { Button } from "@/src/components/ui/button";import { Card } from "@/src/components/ui/card";@@ -461,31 +451,30 @@ function DeleteDomainButton({});return (- <AlertDialog>- <AlertDialogTrigger asChild>- <Button variant="ghost" size="icon-xs" aria-label={`Delete ${domain}`}>+ <ConfirmationDialogController+ title={`Remove ${domain}?`}+ text={+ verified+ ? "If an SSO configuration exists for this domain, you must remove it first. The domain can be re-verified later."+ : "This removes the pending claim. The domain can be re-added and verified later."+ }+ confirmLabel="Remove"+ variant="destructive"+ loading={deleteMutation.isPending}+ onConfirm={async () => {+ await deleteMutation.mutateAsync({ orgId, id });+ }}+ >+ {({ openDialog }) => (+ <Button+ variant="ghost"+ size="icon-xs"+ aria-label={`Delete ${domain}`}+ onClick={openDialog}+ ><TrashIcon className="h-4 w-4" /></Button>- </AlertDialogTrigger>- <AlertDialogContent>- <AlertDialogHeader>- <AlertDialogTitle>Remove {domain}?</AlertDialogTitle>- <AlertDialogDescription>- {verified- ? "If an SSO configuration exists for this domain, you must remove it first. The domain can be re-verified later."- : "This removes the pending claim. The domain can be re-added and verified later."}- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogCancel>Cancel</AlertDialogCancel>- <AlertDialogAction- onClick={() => deleteMutation.mutate({ orgId, id })}- disabled={deleteMutation.isPending}- >- Remove- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>+ )}+ </ConfirmationDialogController>);}diff --git a/web/src/features/dashboard/components/DashboardTable.tsx b/web/src/features/dashboard/components/DashboardTable.tsxindex f3f1ac011b..ce55041c4c 100644--- a/web/src/features/dashboard/components/DashboardTable.tsx+++ b/web/src/features/dashboard/components/DashboardTable.tsx@@ -17,11 +17,11 @@ import { useDetailPageLists } from "@/src/features/navigate-detail-pages/contextimport { Copy, Edit, Trash2, User as UserIcon } from "lucide-react";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";-import { DeleteDialogDashboardContent } from "@/src/features/dashboard/components/DeleteDialogDashboardContent";import { EditDialogDashboardContent } from "@/src/features/dashboard/components/EditDialogDashboardContent";import { CloneFirstDialogController } from "@/src/features/dashboard/components/CloneFirstDialogController";import { useRouter } from "next/router";import { DialogController } from "@/src/components/ui/dialog";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";type DashboardTableRow = {id: string;@@ -53,6 +53,19 @@ export function DashboardTable() {showErrorToast("Failed to clone dashboard", error.message);},});+ const deleteDashboard = api.dashboard.delete.useMutation({+ onSuccess: () => {+ capture("dashboard:delete_dashboard_button_click");+ showSuccessToast({+ title: "Dashboard deleted",+ description: "The dashboard has been deleted successfully",+ });+ utils.dashboard.invalidate();+ },+ onError: (error) => {+ showErrorToast("Failed to delete dashboard", error.message);+ },+ });const [orderByState, setOrderByState] = useOrderByState({column: "updatedAt",@@ -172,18 +185,20 @@ export function DashboardTable() {}>{({ openDialog: openEditDialog }) => (- <DialogController- closeOnInteractionOutside={false}- size="default"- renderContent={({ closeDialog }) =>- selectedDashboard ? (- <DeleteDialogDashboardContent- closeDialog={closeDialog}- projectId={projectId}- dashboardId={selectedDashboard.id}- />- ) : null- }+ <ConfirmationDialogController+ title="Delete dashboard"+ text="This action cannot be undone. It permanently deletes this dashboard."+ confirmLabel="Delete dashboard"+ variant="destructive"+ loading={deleteDashboard.isPending}+ onConfirm={async () => {+ if (!selectedDashboard) return;++ await deleteDashboard.mutateAsync({+ projectId,+ dashboardId: selectedDashboard.id,+ });+ }}>{({ openDialog: openDeleteDialog }) => (<DataTable@@ -299,7 +314,7 @@ export function DashboardTable() {cellPadding="comfortable"/>)}- </DialogController>+ </ConfirmationDialogController>)}</DialogController>)}diff --git a/web/src/features/dashboard/components/DeleteDialogDashboardContent.tsx b/web/src/features/dashboard/components/DeleteDialogDashboardContent.tsxdeleted file mode 100644index 00c827e71d..0000000000--- a/web/src/features/dashboard/components/DeleteDialogDashboardContent.tsx+++ /dev/null@@ -1,64 +0,0 @@-import { Button } from "@/src/components/ui/button";-import {- DialogBody,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/src/components/ui/dialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { api } from "@/src/utils/api";--export function DeleteDialogDashboardContent({- closeDialog,- projectId,- dashboardId,-}: {- closeDialog: () => void;- projectId: string;- dashboardId: string;-}) {- const capture = usePostHogClientCapture();- const utils = api.useUtils();- const deleteDashboard = api.dashboard.delete.useMutation({- onSuccess: () => {- capture("dashboard:delete_dashboard_button_click");- showSuccessToast({- title: "Dashboard deleted",- description: "The dashboard has been deleted successfully",- });- utils.dashboard.invalidate();- closeDialog();- },- onError: (error) => {- showErrorToast("Failed to delete dashboard", error.message);- },- });-- return (- <>- <DialogHeader>- <DialogTitle>Delete dashboard</DialogTitle>- </DialogHeader>- <DialogBody>- <p className="text-muted-foreground py-4 text-sm">- This action cannot be undone. It permanently deletes this dashboard.- </p>- </DialogBody>- <DialogFooter>- <div className="flex gap-2">- <Button variant="outline" onClick={closeDialog}>- Cancel- </Button>- <Button- variant="destructive"- loading={deleteDashboard.isPending}- onClick={() => deleteDashboard.mutate({ projectId, dashboardId })}- >- Delete dashboard- </Button>- </div>- </DialogFooter>- </>- );-}diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsxindex a065a56848..cbd0c700a9 100644--- a/web/src/features/datasets/components/DatasetRunsTable.tsx+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-abstracted-overlay-trigger */import { DataTable } from "@/src/components/table/data-table";import { type LangfuseColumnDef } from "@/src/components/table/types";import { createDropdownTableColumn } from "@/src/components/design-system/table/columns/createDropdownTableColumn";@@ -58,15 +59,6 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";-import {- Dialog,- DialogContent,- DialogController,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/src/components/ui/dialog";import {ResizablePanelGroup,ResizablePanel,@@ -75,7 +67,7 @@ import {import useSessionStorage from "@/src/components/useSessionStorage";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { DeleteDatasetRunDialogContent } from "@/src/features/datasets/components/DeleteDatasetRunDialogContent";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";type DatasetRunRowData = {id: string;@@ -103,7 +95,6 @@ const DatasetRunTableMultiSelectAction = ({datasetId: string;setRowSelection: (value: Record<string, boolean>) => void;}) => {- const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);const capture = usePostHogClientCapture();const utils = api.useUtils();const mutDelete = api.datasets.deleteDatasetRuns.useMutation({@@ -114,80 +105,53 @@ const DatasetRunTableMultiSelectAction = ({});return (- <>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- disabled={selectedRunIds.length < 1}- onClick={() => capture("dataset_run:compare_view_click")}- >- Actions ({selectedRunIds.length} selected)- <ChevronDown className="h-5 w-5" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent key="dropdown-menu-content">- <Link- key="compare"- href={{- pathname: `/project/${projectId}/datasets/${datasetId}/compare`,- query: { runs: selectedRunIds },- }}- >- <DropdownMenuItem>- <Columns3 className="mr-2 h-4 w-4" />- <span>Compare</span>- </DropdownMenuItem>- </Link>- <DropdownMenuItem- key="delete"- onClick={() => setIsDeleteDialogOpen(true)}- >- <Trash className="mr-2 h-4 w-4" />- <span>Delete</span>- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>-- <Dialog- key="delete-dialog"- open={isDeleteDialogOpen}- onOpenChange={(isOpen) => {- if (!mutDelete.isPending) {- setIsDeleteDialogOpen(isOpen);- }- }}- >- <DialogContent className="sm:max-w-xl">- <DialogHeader>- <DialogTitle className="mb-4">Please confirm</DialogTitle>- <DialogDescription className="p-0">- This action cannot be undone and removes all the data associated- with {selectedRunIds.length} dataset run- {selectedRunIds.length > 1 ? "s" : ""}.- </DialogDescription>- </DialogHeader>- <DialogFooter>+ <ConfirmationDialogController+ title="Please confirm"+ text={`This action cannot be undone and removes all the data associated with ${selectedRunIds.length} dataset run${selectedRunIds.length > 1 ? "s" : ""}.`}+ confirmLabel="Delete Experiments"+ variant="destructive"+ loading={mutDelete.isPending}+ onConfirm={async () => {+ capture("dataset_run:delete_form_submit");+ await mutDelete.mutateAsync({+ projectId,+ datasetId,+ datasetRunIds: selectedRunIds,+ });+ }}+ >+ {({ openDialog }) => (+ <DropdownMenu>+ <DropdownMenuTrigger asChild><Button- variant="destructive"- loading={mutDelete.isPending}- disabled={mutDelete.isPending}- onClick={async (event) => {- event.preventDefault();- capture("dataset_run:delete_form_submit");- await mutDelete.mutateAsync({- projectId,- datasetId,- datasetRunIds: selectedRunIds,- });- setIsDeleteDialogOpen(false);- }}+ disabled={selectedRunIds.length < 1}+ onClick={() => capture("dataset_run:compare_view_click")}>- Delete Experiments+ Actions ({selectedRunIds.length} selected)+ <ChevronDown className="h-5 w-5" /></Button>- </DialogFooter>- </DialogContent>- </Dialog>- </>+ </DropdownMenuTrigger>+ <DropdownMenuContent key="dropdown-menu-content">+ <Link+ key="compare"+ href={{+ pathname: `/project/${projectId}/datasets/${datasetId}/compare`,+ query: { runs: selectedRunIds },+ }}+ >+ <DropdownMenuItem>+ <Columns3 className="mr-2 h-4 w-4" />+ <span>Compare</span>+ </DropdownMenuItem>+ </Link>+ <DropdownMenuItem key="delete" onClick={openDialog}>+ <Trash className="mr-2 h-4 w-4" />+ <span>Delete</span>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </ConfirmationDialogController>);};@@ -825,21 +789,28 @@ export function DatasetRunsTable(props: DatasetRunsTableProps) {string | null>(null);const capture = usePostHogClientCapture();+ const utils = api.useUtils();+ const deleteDatasetRun = api.datasets.deleteDatasetRuns.useMutation({+ onSuccess: () => utils.datasets.invalidate(),+ });return (- <DialogController- closeOnInteractionOutside- size="default"- renderContent={({ closeDialog }) =>- datasetRunIdToDelete ? (- <DeleteDatasetRunDialogContent- closeDialog={closeDialog}- projectId={props.projectId}- datasetId={props.datasetId}- datasetRunId={datasetRunIdToDelete}- />- ) : null- }+ <ConfirmationDialogController+ title="Please confirm"+ text="This action cannot be undone. Traces linked to this run must be deleted manually."+ confirmLabel="Delete Dataset Run"+ variant="destructive"+ loading={deleteDatasetRun.isPending}+ onConfirm={async () => {+ if (!datasetRunIdToDelete) return;++ capture("dataset_run:delete_form_submit");+ await deleteDatasetRun.mutateAsync({+ projectId: props.projectId,+ datasetId: props.datasetId,+ datasetRunIds: [datasetRunIdToDelete],+ });+ }}>{({ openDialog }) => (<DatasetRunsTableInternal@@ -851,6 +822,6 @@ export function DatasetRunsTable(props: DatasetRunsTableProps) {}}/>)}- </DialogController>+ </ConfirmationDialogController>);}diff --git a/web/src/features/datasets/components/DeleteDatasetRunDialogContent.tsx b/web/src/features/datasets/components/DeleteDatasetRunDialogContent.tsxdeleted file mode 100644index b6d790cd41..0000000000--- a/web/src/features/datasets/components/DeleteDatasetRunDialogContent.tsx+++ /dev/null@@ -1,65 +0,0 @@-import { Button } from "@/src/components/ui/button";-import {- DialogBody,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/src/components/ui/dialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { api } from "@/src/utils/api";--export function DeleteDatasetRunDialogContent({- closeDialog,- projectId,- datasetId,- datasetRunId,-}: {- closeDialog: () => void;- projectId: string;- datasetId: string;- datasetRunId: string;-}) {- const capture = usePostHogClientCapture();- const utils = api.useUtils();- const deleteDatasetRun = api.datasets.deleteDatasetRuns.useMutation({- onSuccess: () => {- utils.datasets.invalidate();- closeDialog();- },- });-- return (- <>- <DialogHeader>- <DialogTitle>Please confirm</DialogTitle>- </DialogHeader>- <DialogBody>- <p className="text-muted-foreground py-4 text-sm">- This action cannot be undone. Traces linked to this run must be- deleted manually.- </p>- </DialogBody>- <DialogFooter>- <div className="flex gap-2">- <Button variant="outline" onClick={closeDialog}>- Cancel- </Button>- <Button- variant="destructive"- loading={deleteDatasetRun.isPending}- onClick={() => {- capture("dataset_run:delete_form_submit");- deleteDatasetRun.mutate({- projectId,- datasetId,- datasetRunIds: [datasetRunId],- });- }}- >- Delete Dataset Run- </Button>- </div>- </DialogFooter>- </>- );-}diff --git a/web/src/features/datasets/components/DeleteDatasetRunButton.tsx b/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsxsimilarity index 55%rename from web/src/features/datasets/components/DeleteDatasetRunButton.tsxrename to web/src/features/datasets/components/DeleteDatasetRunDialogController.tsxindex ac066f0eae..7e655a46dd 100644--- a/web/src/features/datasets/components/DeleteDatasetRunButton.tsx+++ b/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsx@@ -1,24 +1,26 @@import { useHasProjectAccess } from "@/src/features/rbac";-import { Trash } from "lucide-react";-import { Button } from "@/src/components/ui/button";-import { ConfirmDialog } from "@/src/components/ui/confirm-dialog";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { api } from "@/src/utils/api";-import React, { useState } from "react";import { useRouter } from "next/router";+import type * as React from "react";-export const DeleteDatasetRunButton = ({+export const DeleteDatasetRunDialogController = ({projectId,datasetRunId,redirectUrl,datasetId,+ children,}: {projectId: string;datasetRunId: string;redirectUrl?: string;datasetId: string;+ children: (control: {+ disabled: boolean;+ openDialog: () => void;+ }) => React.ReactNode;}) => {- const [isDialogOpen, setIsDialogOpen] = useState(false);const capture = usePostHogClientCapture();const hasAccess = useHasProjectAccess({projectId: projectId,@@ -32,28 +34,13 @@ export const DeleteDatasetRunButton = ({},});- const button = (- <Button- variant="ghost"- className="w-full"- disabled={!hasAccess}- onClick={() => capture("dataset_run:delete_form_open")}- >- <div className="flex w-full flex-row items-center gap-1">- <Trash className="h-4 w-4" />- <span className="text-sm font-normal">Delete</span>- </div>- </Button>- );-- return hasAccess ? (- <ConfirmDialog- open={isDialogOpen}- onOpenChange={setIsDialogOpen}- trigger={button}+ return (+ <ConfirmationDialogControllertitle="Please confirm"- description="This action cannot be undone. Traces linked to this run must be deleted manually."+ text="This action cannot be undone. Traces linked to this run must be deleted manually."confirmLabel="Delete Dataset Run"+ variant="destructive"+ disabled={!hasAccess}loading={mutDelete.isPending}onConfirm={async () => {capture("dataset_run:delete_form_submit");@@ -62,10 +49,18 @@ export const DeleteDatasetRunButton = ({datasetId: datasetId,datasetRunIds: [datasetRunId],});- setIsDialogOpen(false);}}- />- ) : (- button+ >+ {({ openDialog }) =>+ children({+ disabled: !hasAccess,+ openDialog: () => {+ if (!hasAccess) return;+ capture("dataset_run:delete_form_open");+ openDialog();+ },+ })+ }+ </ConfirmationDialogController>);};diff --git a/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx b/web/src/features/datasets/components/DuplicateDatasetDialogController.tsxindex 615dfbd94e..cb6f8bb1ec 100644--- a/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx+++ b/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx@@ -1,8 +1,7 @@import { useRouter } from "next/router";import { type ReactNode } from "react";-import { ConfirmDialog } from "@/src/components/ui/confirm-dialog";-import { DialogController } from "@/src/features/in-app-agent/components/dialog-controller";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { useHasProjectAccess } from "@/src/features/rbac";import { api } from "@/src/utils/api";@@ -30,39 +29,29 @@ export function DuplicateDatasetDialogController({: { reason: "You don't have permission to duplicate this dataset." };return (- <DialogController<true>- dialog={(close, value) => (- <ConfirmDialog- open={hasAccess && value !== null}- onOpenChange={(open) => {- if (!open) close();- }}- title="Duplicate dataset?"- description="This creates a copy of the dataset and all of its items."- confirmLabel="Duplicate dataset"- loading={duplicateDataset.isPending}- onConfirm={() =>- duplicateDataset.mutate(- { projectId, datasetId },- {- onSuccess: ({ id }) => {- close();- router.push(`/project/${projectId}/datasets/${id}/items`);- },- },- )- }- />- )}+ <ConfirmationDialogController+ title="Duplicate dataset?"+ text="This creates a copy of the dataset and all of its items."+ confirmLabel="Duplicate dataset"+ variant="default"+ disabled={!hasAccess}+ loading={duplicateDataset.isPending}+ onConfirm={async () => {+ const { id } = await duplicateDataset.mutateAsync({+ projectId,+ datasetId,+ });+ router.push(`/project/${projectId}/datasets/${id}/items`);+ }}>- {({ open }) =>+ {({ openDialog }) =>children({disabled,openDialog: () => {- if (hasAccess) open(true);+ if (hasAccess) openDialog();},})}- </DialogController>+ </ConfirmationDialogController>);}diff --git a/web/src/features/support-chat/SupportForm.tsx b/web/src/features/support-chat/SupportForm.tsxindex f423f1b706..4f0591330d 100644--- a/web/src/features/support-chat/SupportForm.tsx+++ b/web/src/features/support-chat/SupportForm.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-abstracted-overlay-trigger */"use client";import { zodResolver } from "@hookform/resolvers/zod";@@ -18,6 +19,7 @@ import {import { reportNonTrpcError } from "@/src/utils/api";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { Button } from "@/src/components/ui/button";import {Form,@@ -28,16 +30,6 @@ import {FormLabel,FormMessage,} from "@/src/components/ui/form";-import {- AlertDialog,- AlertDialogAction,- AlertDialogCancel,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogHeader,- AlertDialogTitle,-} from "@/src/components/ui/alert-dialog";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";import { Textarea } from "@/src/components/ui/textarea";import { useEffect, useState } from "react";@@ -198,10 +190,6 @@ export function SupportForm({// Local submit guard to avoid flicker across multiple mutationsconst [isSubmittingLocal, setIsSubmittingLocal] = useState(false);- // Sev-1 pages the on-call team, so submission requires an explicit- // confirmation step.- const [sev1ConfirmOpen, setSev1ConfirmOpen] = useState(false);-const productFeatureTopics = TopicGroups["Product Features"].filter((topic) => topic !== "V4 Migration" || showV4MigrationTopic,);@@ -237,7 +225,10 @@ export function SupportForm({}}, [selectedSeverity, canSelectHighSeverity, form]);- const handleFormSubmit = async (values: SupportFormInput) => {+ const handleFormSubmit = async (+ values: SupportFormInput,+ openConfirmationDialog: () => void,+ ) => {const parsed: SupportFormValues = SupportFormSchema.parse(values);const msgLen = (parsed.message ?? "").trim().length;@@ -249,7 +240,7 @@ export function SupportForm({// Sev-1 pages the on-call team — require explicit confirmation before// submitting. The dialog's confirm action calls `submitForm` directly.if (parsed.severity === SEVERITY_1) {- setSev1ConfirmOpen(true);+ openConfirmationDialog();return;}@@ -303,302 +294,294 @@ export function SupportForm({warnedShortOnce && (form.getValues("message") ?? "").trim().length < 50;return (- <>- <Form {...form}>- <form- onSubmit={form.handleSubmit(handleFormSubmit)}- className="flex flex-col gap-4"- >- {/* Message Type */}- <FormField- control={form.control}- name="messageType"- render={({ field }) => (- <FormItem>- <FormLabel>Message Type</FormLabel>- <FormControl>- <div className="grid grid-cols-3 gap-2">- {MESSAGE_TYPES.map((v) => (- <Button- key={v}- variant={field.value === v ? "default" : "outline"}- className="flex w-full items-center gap-2 text-sm font-normal"- size="default"- onClick={() => field.onChange(v)}- >- <span className="truncate" title={v}>- {v}- </span>- </Button>- ))}- </div>- </FormControl>- <FormDescription className="sr-only">- Choose the type of your message.- </FormDescription>- <FormMessage />- </FormItem>+ <ConfirmationDialogController+ title="Confirm Severity 1 (Critical Business Impact)"+ text="Please confirm that your issue has critical business impact. This means it severely impacts your use of Langfuse in production, such as loss of production data, ingestion issues, or prompt fetching issues."+ confirmLabel="Confirm & Submit"+ variant="default"+ loading={isSubmittingLocal}+ onConfirm={async () => {+ await submitForm(form.getValues());+ }}+ >+ {({ openDialog }) => (+ <Form {...form}>+ <form+ onSubmit={form.handleSubmit((values) =>+ handleFormSubmit(values, openDialog),)}- />+ className="flex flex-col gap-4"+ >+ {/* Message Type */}+ <FormField+ control={form.control}+ name="messageType"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Message Type</FormLabel>+ <FormControl>+ <div className="grid grid-cols-3 gap-2">+ {MESSAGE_TYPES.map((v) => (+ <Button+ key={v}+ variant={field.value === v ? "default" : "outline"}+ className="flex w-full items-center gap-2 text-sm font-normal"+ size="default"+ onClick={() => field.onChange(v)}+ >+ <span className="truncate" title={v}>+ {v}+ </span>+ </Button>+ ))}+ </div>+ </FormControl>+ <FormDescription className="sr-only">+ Choose the type of your message.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />- {/* Priority (maps to Pylon case_severity). Severity 1 and 2 are+ {/* Priority (maps to Pylon case_severity). Severity 1 and 2 aregated to Enterprise plans. */}- <FormField- control={form.control}- name="severity"- render={({ field }) => (- <FormItem>- <FormLabel>Priority</FormLabel>- <FormControl>- <SelectInput- value={field.value}- onValueChange={field.onChange}- placeholder="Select a priority"- options={SEVERITIES.map((severity) => {- if (- isSeveritySelectable(severity, canSelectHighSeverity)- ) {- return { value: severity, label: severity };- }-- return {- value: severity,- label: severity,- disabled: true as const,- disabledReason:- severity === SEVERITY_1- ? "Severity 1 is available on the Enterprise plan."- : "Severity 2 is available on the Enterprise plan.",- };- })}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- {/* Topic */}- <FormField- control={form.control}- name="topic"- render={({ field }) => (- <FormItem>- <FormLabel>Topic</FormLabel>- <FormControl>- <SelectInput- value={field.value ?? undefined}- onValueChange={field.onChange}- placeholder="Select a topic"- options={[- {- type: "group",- id: "product-features",- label: "Product Features",- options: productFeatureTopics.map((t) => ({- value: t,- label: t,- })),- },- {- type: "group",- id: "operations",- label: "Operations",- options: TopicGroups.Operations.map((t) => ({- value: t,- label: t,- })),- },- ]}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />+ <FormField+ control={form.control}+ name="severity"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Priority</FormLabel>+ <FormControl>+ <SelectInput+ value={field.value}+ onValueChange={field.onChange}+ placeholder="Select a priority"+ options={SEVERITIES.map((severity) => {+ if (+ isSeveritySelectable(severity, canSelectHighSeverity)+ ) {+ return { value: severity, label: severity };+ }++ return {+ value: severity,+ label: severity,+ disabled: true as const,+ disabledReason:+ severity === SEVERITY_1+ ? "Severity 1 is available on the Enterprise plan."+ : "Severity 2 is available on the Enterprise plan.",+ };+ })}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />- {/* Integration Type */}- {isProductFeatureTopic && (+ {/* Topic */}<FormFieldcontrol={form.control}- name="integrationType"+ name="topic"render={({ field }) => (<FormItem>- <FormLabel>Integration Type (optional)</FormLabel>+ <FormLabel>Topic</FormLabel><FormControl><SelectInput- value={field.value ?? ""}+ value={field.value ?? undefined}onValueChange={field.onChange}- placeholder="Select integration type"- options={INTEGRATION_TYPES.map((integrationType) => ({- value: integrationType,- label: integrationType,- }))}+ placeholder="Select a topic"+ options={[+ {+ type: "group",+ id: "product-features",+ label: "Product Features",+ options: productFeatureTopics.map((t) => ({+ value: t,+ label: t,+ })),+ },+ {+ type: "group",+ id: "operations",+ label: "Operations",+ options: TopicGroups.Operations.map((t) => ({+ value: t,+ label: t,+ })),+ },+ ]}/></FormControl><FormMessage /></FormItem>)}/>- )}-- {/* Message */}- <FormField- control={form.control}- name="message"- render={({ field }) => (- <FormItem>- <FormLabel>Message</FormLabel>- <div className="text-muted-foreground text-xs">- We will email you at your account address. Replies may take up- to one business day.- </div>- <FormControl>- <div className="relative w-full">- <Textarea- {...field}- rows={8}- placeholder={- isProductFeatureTopic- ? "Please explain as fully as possible what you're aiming to do, and what you'd like help with.\n\nIf your question involves a specific trace, prompt, score, etc. please include a link to it."- : "Please explain as fully as possible what you're aiming to do, and what you'd like help with."++ {/* Integration Type */}+ {isProductFeatureTopic && (+ <FormField+ control={form.control}+ name="integrationType"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Integration Type (optional)</FormLabel>+ <FormControl>+ <SelectInput+ value={field.value ?? ""}+ onValueChange={field.onChange}+ placeholder="Select integration type"+ options={INTEGRATION_TYPES.map((integrationType) => ({+ value: integrationType,+ label: integrationType,+ }))}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ )}++ {/* Message */}+ <FormField+ control={form.control}+ name="message"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Message</FormLabel>+ <div className="text-muted-foreground text-xs">+ We will email you at your account address. Replies may take+ up to one business day.+ </div>+ <FormControl>+ <div className="relative w-full">+ <Textarea+ {...field}+ rows={8}+ placeholder={+ isProductFeatureTopic+ ? "Please explain as fully as possible what you're aiming to do, and what you'd like help with.\n\nIf your question involves a specific trace, prompt, score, etc. please include a link to it."+ : "Please explain as fully as possible what you're aiming to do, and what you'd like help with."+ }+ />+ </div>+ </FormControl>++ {messageIsShortAfterWarning && (+ <p+ className="mt-2 text-sm text-red-500"+ role="status"+ aria-live="polite"+ >+ The message seems short — adding a bit more context can+ help us get you a quicker, smarter answer. You can submit+ again as is, or add more details.+ </p>+ )}++ <FormMessage />++ <div className="mt-1">+ <Dropzone+ accept={undefined}+ isDisabled={false}+ maxFiles={FILE_UPLOAD_CONSTRAINTS.maxFiles}+ maxSize={FILE_UPLOAD_CONSTRAINTS.maxFileSizeBytes}+ minSize={undefined}+ onDrop={(accepted) =>+ setFiles((prev) => {+ const existing = prev ?? [];+ const merged = [...existing, ...accepted];+ const maxFiles = FILE_UPLOAD_CONSTRAINTS.maxFiles;+ return merged.slice(0, maxFiles);+ })}+ onError={(error) => {+ onFileError(formatFileError(error));+ }}+ src={files}+ variant="compact"/></div>- </FormControl>-- {messageIsShortAfterWarning && (- <p- className="mt-2 text-sm text-red-500"- role="status"- aria-live="polite"- >- The message seems short — adding a bit more context can help- us get you a quicker, smarter answer. You can submit again- as is, or add more details.- </p>- )}- <FormMessage />-- <div className="mt-1">- <Dropzone- accept={undefined}- isDisabled={false}- maxFiles={FILE_UPLOAD_CONSTRAINTS.maxFiles}- maxSize={FILE_UPLOAD_CONSTRAINTS.maxFileSizeBytes}- minSize={undefined}- onDrop={(accepted) =>- setFiles((prev) => {- const existing = prev ?? [];- const merged = [...existing, ...accepted];- const maxFiles = FILE_UPLOAD_CONSTRAINTS.maxFiles;- return merged.slice(0, maxFiles);- })- }- onError={(error) => {- onFileError(formatFileError(error));- }}- src={files}- variant="compact"- />- </div>-- {files && files.length > 0 && (- <div className="p-0 text-left text-sm font-bold">- <div className="text-muted-foreground mb-2 text-xs font-bold">- Attached files- </div>- {files?.map((file) => (- <div- key={file.name}- className="flex flex-row items-center justify-start gap-2 text-xs"- >- <Button- type="button"- variant="ghost"- size="icon-xs"- onClick={() =>- setFiles(files.filter((f) => f.name !== file.name))- }- className="p-0"- >- <span className="sr-only">Remove file</span>- <Trash2 className="h-3.5 w-3.5" />- </Button>- {file.name}+ {files && files.length > 0 && (+ <div className="p-0 text-left text-sm font-bold">+ <div className="text-muted-foreground mb-2 text-xs font-bold">+ Attached files</div>- ))}- </div>- )}- </FormItem>- )}- />-- {/* Actions */}- <div className="flex flex-row gap-2">- <Button- type="button"- variant="outline"- onClick={() => {- setWarnedShortOnce(false);- setFiles(undefined);- onCancel();- }}- className="w-full"- >- Cancel- </Button>-- <Button- type="submit"- disabled={isSubmittingLocal}- className="w-full"- >- {isSubmittingLocal ? (- <span className="inline-flex items-center gap-2">- <Spinner size="sm" />- Submitting…- </span>- ) : messageIsShortAfterWarning ? (- "Submit Anyways"- ) : (- "Submit"+ {files?.map((file) => (+ <div+ key={file.name}+ className="flex flex-row items-center justify-start gap-2 text-xs"+ >+ <Button+ type="button"+ variant="ghost"+ size="icon-xs"+ onClick={() =>+ setFiles(+ files.filter((f) => f.name !== file.name),+ )+ }+ className="p-0"+ >+ <span className="sr-only">Remove file</span>+ <Trash2 className="h-3.5 w-3.5" />+ </Button>+ {file.name}+ </div>+ ))}+ </div>+ )}+ </FormItem>)}- </Button>- </div>+ />- {isSubmittingLocal && (- <div className="text-muted-foreground text-xs">- This can take a few seconds — hang tight while we submit your- request.+ {/* Actions */}+ <div className="flex flex-row gap-2">+ <Button+ type="button"+ variant="outline"+ onClick={() => {+ setWarnedShortOnce(false);+ setFiles(undefined);+ onCancel();+ }}+ className="w-full"+ >+ Cancel+ </Button>++ <Button+ type="submit"+ disabled={isSubmittingLocal}+ className="w-full"+ >+ {isSubmittingLocal ? (+ <span className="inline-flex items-center gap-2">+ <Spinner size="sm" />+ Submitting…+ </span>+ ) : messageIsShortAfterWarning ? (+ "Submit Anyways"+ ) : (+ "Submit"+ )}+ </Button></div>- )}- </form>- </Form>-- {/* Confirmation gate before a Sev-1 request pages the on-call team. */}- <AlertDialog open={sev1ConfirmOpen} onOpenChange={setSev1ConfirmOpen}>- <AlertDialogContent>- <AlertDialogHeader>- <AlertDialogTitle>- Confirm Severity 1 (Critical Business Impact)- </AlertDialogTitle>- <AlertDialogDescription>- Please confirm that your issue has critical business impact. This- means it severely impacts your use of Langfuse in production, such- as loss of production data, ingestion issues, or prompt fetching- issues.- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogFooter>- <AlertDialogCancel>Cancel</AlertDialogCancel>- <AlertDialogAction onClick={() => submitForm(form.getValues())}>- Confirm & Submit- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>- </>++ {isSubmittingLocal && (+ <div className="text-muted-foreground text-xs">+ This can take a few seconds — hang tight while we submit your+ request.+ </div>+ )}+ </form>+ </Form>+ )}+ </ConfirmationDialogController>);}diff --git a/web/src/features/traces/components/DeleteTraceDialogContent.tsx b/web/src/features/traces/components/DeleteTraceDialogContent.tsxdeleted file mode 100644index 1716a5169c..0000000000--- a/web/src/features/traces/components/DeleteTraceDialogContent.tsx+++ /dev/null@@ -1,65 +0,0 @@-import { Button } from "@/src/components/ui/button";-import {- DialogBody,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/src/components/ui/dialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showSuccessToast } from "@/src/features/notifications";-import { api } from "@/src/utils/api";--export function DeleteTraceDialogContent({- closeDialog,- projectId,- traceId,-}: {- closeDialog: () => void;- projectId: string;- traceId: string;-}) {- const capture = usePostHogClientCapture();- const utils = api.useUtils();- const traceMutation = api.traces.deleteMany.useMutation({- onSuccess: () => {- capture("trace:delete", { source: "table-single-row" });- showSuccessToast({- title: "Trace deleted",- description:- "Selected trace will be deleted. Traces are removed asynchronously and may continue to be visible for up to 24 hours.",- });- utils.traces.all.invalidate();- closeDialog();- },- });-- return (- <>- <DialogHeader>- <DialogTitle>Please confirm</DialogTitle>- </DialogHeader>- <DialogBody>- <p className="text-muted-foreground py-4 text-sm">- This action cannot be undone. It removes all the data associated with- this trace.- </p>- </DialogBody>- <DialogFooter>- <div className="flex gap-2">- <Button variant="outline" onClick={closeDialog}>- Cancel- </Button>- <Button- variant="destructive"- loading={traceMutation.isPending}- onClick={() =>- traceMutation.mutate({ traceIds: [traceId], projectId })- }- >- Delete trace- </Button>- </div>- </DialogFooter>- </>- );-}diff --git a/web/src/features/widgets/components/WidgetTable.tsx b/web/src/features/widgets/components/WidgetTable.tsxindex 69ab267e4e..c0c373a5d2 100644--- a/web/src/features/widgets/components/WidgetTable.tsx+++ b/web/src/features/widgets/components/WidgetTable.tsx@@ -1,5 +1,5 @@import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { useEffect, useState } from "react";+import { useEffect, type ReactNode } from "react";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { NumberParam, useQueryParams, withDefault } from "use-query-params";@@ -28,7 +28,7 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from "@/src/components/ui/dropdown-menu";-import { ConfirmDialog } from "@/src/components/ui/confirm-dialog";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { copyTextToClipboard } from "@/src/utils/clipboard";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { useRouter } from "next/router";@@ -48,24 +48,23 @@ type WidgetTableRow = {owner: "PROJECT" | "LANGFUSE";};-function WidgetActionsCell({+function DeleteWidgetDialogController({+ children,+ hasDeleteAccess,+ projectId,widgetId,- owner,}: {+ children: (control: {+ disabled: boolean;+ openDialog: () => void;+ }) => ReactNode;+ hasDeleteAccess: boolean;+ projectId: string | undefined;widgetId: string;- owner: "PROJECT" | "LANGFUSE";}) {- const projectId = useProjectIdFromURL();const utils = api.useUtils();const capture = usePostHogClientCapture();- const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);- const hasCUDAccess = useHasProjectAccess({- projectId,- scope: "dashboards:CUD",- });- const hasDeleteAccess = hasCUDAccess && owner !== "LANGFUSE";-- const mutDeleteWidget = api.dashboardWidgets.delete.useMutation({+ const deleteWidget = api.dashboardWidgets.delete.useMutation({onSuccess: () => {utils.dashboardWidgets.invalidate();capture("dashboard:delete_widget_form_open");@@ -76,11 +75,49 @@ function WidgetActionsCell({"Widget in use","Widget is still in use. Please remove it from all dashboards before deleting it.",);- } else {- showErrorToast("Failed to delete widget", error.message);+ return;}++ showErrorToast("Failed to delete widget", error.message);},});++ return (+ <ConfirmationDialogController+ title="Delete widget"+ text="This action permanently deletes this widget. If the widget is currently used in any dashboard, you will need to remove it from those dashboards first."+ confirmLabel="Delete Widget"+ variant="destructive"+ disabled={!hasDeleteAccess}+ loading={deleteWidget.isPending}+ onConfirm={async () => {+ if (!projectId) {+ console.error("Project ID is missing");+ return;+ }+ await deleteWidget.mutateAsync({ projectId, widgetId });+ }}+ >+ {({ openDialog }) => children({ disabled: !hasDeleteAccess, openDialog })}+ </ConfirmationDialogController>+ );+}++function WidgetActionsCell({+ widgetId,+ owner,+}: {+ widgetId: string;+ owner: "PROJECT" | "LANGFUSE";+}) {+ const projectId = useProjectIdFromURL();+ const utils = api.useUtils();+ const capture = usePostHogClientCapture();+ const hasCUDAccess = useHasProjectAccess({+ projectId,+ scope: "dashboards:CUD",+ });+ const hasDeleteAccess = hasCUDAccess && owner !== "LANGFUSE";const { mutateAsync: createWidgetAsync } =api.dashboardWidgets.create.useMutation();@@ -183,54 +220,47 @@ function WidgetActionsCell({};return (- <>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="ghost" size="xs" aria-label="Widget actions">- <MoreVertical className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem onClick={handleCopyToClipboard}>- <Copy className="mr-2 h-4 w-4" />- Copy widget- </DropdownMenuItem>- <DropdownMenuItem disabled={!hasCUDAccess} onClick={handleDuplicate}>- <CopyPlus className="mr-2 h-4 w-4" />- Clone- </DropdownMenuItem>- <DropdownMenuItem onClick={handleDownloadJson}>- <FileJson className="mr-2 h-4 w-4" />- Download as JSON- </DropdownMenuItem>- <DropdownMenuSeparator />- <DropdownMenuItem- disabled={!hasDeleteAccess}- onClick={() => setIsDeleteDialogOpen(true)}- className="text-destructive focus:text-destructive"- >- <Trash className="mr-2 h-4 w-4" />- Delete- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- <ConfirmDialog- open={isDeleteDialogOpen}- onOpenChange={setIsDeleteDialogOpen}- title="Delete widget"- description="This action permanently deletes this widget. If the widget is currently used in any dashboard, you will need to remove it from those dashboards first."- confirmLabel="Delete Widget"- loading={mutDeleteWidget.isPending}- onConfirm={() => {- if (!projectId) {- console.error("Project ID is missing");- return;- }- mutDeleteWidget.mutate({ projectId, widgetId });- setIsDeleteDialogOpen(false);- }}- />- </>+ <DeleteWidgetDialogController+ hasDeleteAccess={hasDeleteAccess}+ projectId={projectId}+ widgetId={widgetId}+ >+ {({ disabled, openDialog }) => (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" size="xs" aria-label="Widget actions">+ <MoreVertical className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem onClick={handleCopyToClipboard}>+ <Copy className="mr-2 h-4 w-4" />+ Copy widget+ </DropdownMenuItem>+ <DropdownMenuItem+ disabled={!hasCUDAccess}+ onClick={handleDuplicate}+ >+ <CopyPlus className="mr-2 h-4 w-4" />+ Clone+ </DropdownMenuItem>+ <DropdownMenuItem onClick={handleDownloadJson}>+ <FileJson className="mr-2 h-4 w-4" />+ Download as JSON+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ disabled={disabled}+ onClick={openDialog}+ className="text-destructive focus:text-destructive"+ >+ <Trash className="mr-2 h-4 w-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </DeleteWidgetDialogController>);}diff --git a/web/src/pages/account/settings/index.tsx b/web/src/pages/account/settings/index.tsxindex 7ddf6b415a..8fb5e72873 100644--- a/web/src/pages/account/settings/index.tsx+++ b/web/src/pages/account/settings/index.tsx@@ -35,6 +35,7 @@ import Link from "next/link";import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";const displayNameSchema = z.object({name: StringNoHTML.min(1, "Name cannot be empty").max(@@ -256,7 +257,7 @@ function SignOutAllSessionsButton() {"Failed to Sign Out of All Sessions",error instanceof Error ? error.message : "An unexpected error occurred",);- return;+ throw error;}// Sessions are already revoked server-side at this point, so a failure to@@ -269,35 +270,20 @@ function SignOutAllSessionsButton() {};return (- <Dialog>- <DialogTrigger asChild>- <Button variant="destructive-secondary">+ <ConfirmationDialogController+ title="Sign Out of All Sessions"+ text="This will sign you out on this device and every other device where you are currently signed in. You will need to sign in again."+ confirmLabel="Sign Out of All Sessions"+ variant="destructive"+ loading={signOutAllSessions.isPending}+ onConfirm={onConfirm}+ >+ {({ openDialog }) => (+ <Button variant="destructive-secondary" onClick={openDialog}>Sign Out of All Sessions</Button>- </DialogTrigger>- <DialogContent className="sm:max-w-[425px]">- <DialogHeader>- <DialogTitle className="text-lg font-bold">- Sign Out of All Sessions- </DialogTitle>- <DialogDescription>- This will sign you out on this device and every other device where- you are currently signed in. You will need to sign in again.- </DialogDescription>- </DialogHeader>- <DialogFooter>- <Button- type="button"- variant="destructive"- loading={signOutAllSessions.isPending}- onClick={onConfirm}- className="w-full"- >- Sign Out of All Sessions- </Button>- </DialogFooter>- </DialogContent>- </Dialog>+ )}+ </ConfirmationDialogController>);}diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsxindex 560532d5c8..68d1ec6cf2 100644--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx@@ -1,10 +1,10 @@import { Button } from "@/src/components/ui/button";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { DatasetRunItemsByRunTable } from "@/src/features/datasets/components/DatasetRunItemsByRunTable";-import { DeleteDatasetRunButton } from "@/src/features/datasets/components/DeleteDatasetRunButton";+import { DeleteDatasetRunDialogController } from "@/src/features/datasets/components/DeleteDatasetRunDialogController";import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { api } from "@/src/utils/api";-import { Columns3, MoreVertical } from "lucide-react";+import { Columns3, MoreVertical, Trash } from "lucide-react";import Link from "next/link";import { useRouter } from "next/router";import { useEffect } from "react";@@ -84,23 +84,28 @@ function DatasetRunLegacy() {}listKey="datasetRuns"/>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="icon">- <MoreVertical className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent>- <DropdownMenuItem asChild>- <DeleteDatasetRunButton- projectId={projectId}- datasetRunId={runId}- datasetId={datasetId}- redirectUrl={`/project/${projectId}/datasets/${datasetId}/experiments`}- />- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ <DeleteDatasetRunDialogController+ projectId={projectId}+ datasetRunId={runId}+ datasetId={datasetId}+ redirectUrl={`/project/${projectId}/datasets/${datasetId}/experiments`}+ >+ {({ disabled, openDialog }) => (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="outline" size="icon">+ <MoreVertical className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent>+ <DropdownMenuItem disabled={disabled} onSelect={openDialog}>+ <Trash className="h-4 w-4" />+ <span>Delete</span>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </DeleteDatasetRunDialogController></>),}}