🪢 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
feat(web): link personal feature previews from organization settings (#18887)
Nimarefe076597b0c
diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex e6faefd5c0..346dab1621 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -40,6 +40,7 @@ import type { Session } from "next-auth";import type { NavigationItem } from "@/src/components/layouts/utilities/routes";import type { RouteGroup } from "@/src/components/layouts/routes";import dynamic from "next/dynamic";+import { canOpenPersonalFeaturePreviews } from "@/src/features/feature-previews/canOpenPersonalFeaturePreviews";import { ControlledFeaturePreviewModal } from "@/src/features/feature-previews/components/ControlledFeaturePreviewModal";import { InAppAgentWindowHost } from "@/src/features/in-app-agent/components/InAppAgentWindowHost";import {@@ -172,8 +173,11 @@ export function AuthenticatedLayout({},}));- const hasFeaturePreviews =- isLangfuseCloud || user.v4BetaEnabled === true || user.admin === true;+ const hasFeaturePreviews = canOpenPersonalFeaturePreviews({+ isLangfuseCloud,+ v4BetaEnabled: user.v4BetaEnabled === true,+ isAdmin: user.admin === true,+ });// User navigation items for sidebar dropdownconst sidebarUser = {diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.stories.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.stories.tsxnew file mode 100644index 0000000000..8ec51f0759--- /dev/null+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.stories.tsx@@ -0,0 +1,24 @@+import { fn } from "storybook/test";++import preview from "../../../../.storybook/preview";+import { OrganizationFeaturePreviewIntro } from "./OrganizationFeaturePreviewIntro";++const meta = preview.meta({+ component: OrganizationFeaturePreviewIntro,+});++export default meta;++export const WithPersonalLink = meta.story({+ args: {+ canOpenPersonalPreviews: true,+ onOpenPersonalPreviews: fn(),+ },+});++export const PersonalPreviewsUnavailable = meta.story({+ args: {+ canOpenPersonalPreviews: false,+ onOpenPersonalPreviews: fn(),+ },+});diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.tsxnew file mode 100644index 0000000000..3a48d80d0a--- /dev/null+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewIntro.tsx@@ -0,0 +1,33 @@+import { Button } from "@/src/components/design-system/Button/Button";++type OrganizationFeaturePreviewIntroProps = {+ canOpenPersonalPreviews: boolean;+ onOpenPersonalPreviews: () => void;+};++export function OrganizationFeaturePreviewIntro({+ canOpenPersonalPreviews,+ onOpenPersonalPreviews,+}: OrganizationFeaturePreviewIntroProps) {+ return (+ <div className="flex flex-col gap-1">+ {canOpenPersonalPreviews ? (+ <p className="text-muted-foreground text-sm">+ {[+ <Button+ key="personal-previews"+ variant="text"+ text="Enable feature previews for only you here"+ onClick={onOpenPersonalPreviews}+ />,+ ", the table below toggles it for the entire organization.",+ ]}+ </p>+ ) : null}+ <p className="text-muted-foreground text-sm">+ Enable previews for everyone while they are using this organization. New+ members inherit these defaults automatically.+ </p>+ </div>+ );+}diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.clienttest.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.clienttest.tsxindex 829a1a9403..f70f771dc9 100644--- a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.clienttest.tsx+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.clienttest.tsx@@ -39,7 +39,11 @@ vi.mock("next-auth/react", () => ({environment: {enableExperimentalFeatures: mocks.experimentalFeaturesEnabled,},- user: { featureFlags: mocks.userFeatureFlags },+ user: {+ admin: false,+ featureFlags: mocks.userFeatureFlags,+ v4BetaEnabled: false,+ },},update: mocks.updateSession,}),@@ -49,6 +53,19 @@ vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));+vi.mock("@/src/features/organizations/hooks", () => ({+ useLangfuseCloudRegion: () => ({+ isLangfuseCloud: true,+ }),+}));++vi.mock(+ "@/src/features/feature-previews/components/ControlledFeaturePreviewModal",+ () => ({+ ControlledFeaturePreviewModal: () => null,+ }),+);+vi.mock("@/src/features/notifications/showErrorToast", () => ({showErrorToast: vi.fn(),}));diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsxindex 19affe586a..df30a1d463 100644--- a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx@@ -23,6 +23,11 @@ import {isOrganizationOnlyFeaturePreviewFlag,type FeaturePreviewFlag,} from "@/src/features/feature-flags/available-flags";+import { OrganizationFeaturePreviewIntro } from "./OrganizationFeaturePreviewIntro";+import { PersonalEnablementWarning } from "./PersonalEnablementWarning";+import { canOpenPersonalFeaturePreviews } from "@/src/features/feature-previews/canOpenPersonalFeaturePreviews";+import { ControlledFeaturePreviewModal } from "@/src/features/feature-previews/components/ControlledFeaturePreviewModal";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";@@ -40,8 +45,27 @@ export function OrganizationFeaturePreviewsSettings({const [proposedChange, setProposedChange] = useState<ProposedChange | null>(null,);+ const [personalPreviewsOpen, setPersonalPreviewsOpen] = useState(false);const session = useSession();+ const { isLangfuseCloud } = useLangfuseCloudRegion();const capture = usePostHogClientCapture();+ const canOpenPersonalPreviews = canOpenPersonalFeaturePreviews({+ isLangfuseCloud,+ v4BetaEnabled: session.data?.user?.v4BetaEnabled === true,+ isAdmin: session.data?.user?.admin === true,+ });+ const openPersonalPreviews = (source: "description" | "preview_row") => {+ capture("organization_settings:personal_feature_previews_opened", {+ source,+ });+ setPersonalPreviewsOpen(true);+ };+ const handleOpenFromDescription = () => {+ openPersonalPreviews("description");+ };+ const handleOpenFromPreviewRow = () => {+ openPersonalPreviews("preview_row");+ };const utils = api.useUtils();const defaultsQuery = api.organizations.getFeatureFlagOrgDefaults.useQuery({orgId,@@ -94,10 +118,10 @@ export function OrganizationFeaturePreviewsSettings({<div className="flex flex-col gap-4"><div><Header title="Feature Previews" />- <p className="text-muted-foreground text-sm">- Enable previews for everyone while they are using this organization.- New members inherit these defaults automatically.- </p>+ <OrganizationFeaturePreviewIntro+ canOpenPersonalPreviews={canOpenPersonalPreviews}+ onOpenPersonalPreviews={handleOpenFromDescription}+ /></div>{experimentalFeaturesEnabled ? (@@ -138,10 +162,10 @@ export function OrganizationFeaturePreviewsSettings({</p>) : null}{requiresPersonalEnablement ? (- <p className="text-destructive text-xs">- Enable this preview in your personal Feature Preview- settings before enabling it for the organization.- </p>+ <PersonalEnablementWarning+ canOpenPersonalPreviews={canOpenPersonalPreviews}+ onOpenPersonalPreviews={handleOpenFromPreviewRow}+ />) : null}</div><Switch@@ -215,6 +239,13 @@ export function OrganizationFeaturePreviewsSettings({</AlertDialogFooter></AlertDialogContent></AlertDialog>++ {canOpenPersonalPreviews ? (+ <ControlledFeaturePreviewModal+ open={personalPreviewsOpen}+ onOpenChange={setPersonalPreviewsOpen}+ />+ ) : null}</div>);}diff --git a/web/src/features/feature-flags/components/PersonalEnablementWarning.stories.tsx b/web/src/features/feature-flags/components/PersonalEnablementWarning.stories.tsxnew file mode 100644index 0000000000..93915c31dd--- /dev/null+++ b/web/src/features/feature-flags/components/PersonalEnablementWarning.stories.tsx@@ -0,0 +1,24 @@+import { fn } from "storybook/test";++import preview from "../../../../.storybook/preview";+import { PersonalEnablementWarning } from "./PersonalEnablementWarning";++const meta = preview.meta({+ component: PersonalEnablementWarning,+});++export default meta;++export const WithPersonalLink = meta.story({+ args: {+ canOpenPersonalPreviews: true,+ onOpenPersonalPreviews: fn(),+ },+});++export const PersonalPreviewsUnavailable = meta.story({+ args: {+ canOpenPersonalPreviews: false,+ onOpenPersonalPreviews: fn(),+ },+});diff --git a/web/src/features/feature-flags/components/PersonalEnablementWarning.tsx b/web/src/features/feature-flags/components/PersonalEnablementWarning.tsxnew file mode 100644index 0000000000..1bcaf4f258--- /dev/null+++ b/web/src/features/feature-flags/components/PersonalEnablementWarning.tsx@@ -0,0 +1,33 @@+import { Button } from "@/src/components/design-system/Button/Button";++type PersonalEnablementWarningProps = {+ canOpenPersonalPreviews: boolean;+ onOpenPersonalPreviews: () => void;+};++export function PersonalEnablementWarning({+ canOpenPersonalPreviews,+ onOpenPersonalPreviews,+}: PersonalEnablementWarningProps) {+ if (!canOpenPersonalPreviews) {+ return (+ <p className="text-destructive text-xs">+ Enable this preview in your personal Feature Preview settings before+ enabling it for the organization.+ </p>+ );+ }++ return (+ <p className="text-destructive text-xs">+ Enable this preview in your{" "}+ <Button+ variant="text"+ size="sm"+ text="personal Feature Preview settings"+ onClick={onOpenPersonalPreviews}+ />{" "}+ before enabling it for the organization.+ </p>+ );+}diff --git a/web/src/features/feature-previews/canOpenPersonalFeaturePreviews.ts b/web/src/features/feature-previews/canOpenPersonalFeaturePreviews.tsnew file mode 100644index 0000000000..123decf59a--- /dev/null+++ b/web/src/features/feature-previews/canOpenPersonalFeaturePreviews.ts@@ -0,0 +1,12 @@+/** Account menu and organization settings share this gate for the personal preview modal. */+export function canOpenPersonalFeaturePreviews({+ isLangfuseCloud,+ v4BetaEnabled,+ isAdmin,+}: {+ isLangfuseCloud: boolean;+ v4BetaEnabled: boolean;+ isAdmin: boolean;+}): boolean {+ return isLangfuseCloud || v4BetaEnabled || isAdmin;+}diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex 0b7f35c53c..0decc233ba 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -430,6 +430,7 @@ const events = {"ai_features_toggle","ai_telemetry_toggle","feature_flag_default_toggled",+ "personal_feature_previews_opened","user_feature_flag_toggled",],help_popup: ["opened", "href_clicked"],