🪢 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): wait for migration status before rendering (#16134)
Max Deichmannd41d6e7b9c06
diff --git a/web/src/features/v4-migration/V4MigrationLoadingState.stories.tsx b/web/src/features/v4-migration/V4MigrationLoadingState.stories.tsxnew file mode 100644index 0000000000..d1e6a49914--- /dev/null+++ b/web/src/features/v4-migration/V4MigrationLoadingState.stories.tsx@@ -0,0 +1,8 @@+import preview from "../../../.storybook/preview";+import { V4MigrationLoadingState } from "./V4MigrationLoadingState";++const meta = preview.meta({+ component: V4MigrationLoadingState,+});++export const Loading = meta.story({});diff --git a/web/src/features/v4-migration/V4MigrationLoadingState.tsx b/web/src/features/v4-migration/V4MigrationLoadingState.tsxnew file mode 100644index 0000000000..16a99e6ca1--- /dev/null+++ b/web/src/features/v4-migration/V4MigrationLoadingState.tsx@@ -0,0 +1,9 @@+export function V4MigrationLoadingState() {+ return (+ <div className="flex min-h-full flex-1 items-center justify-center px-6 py-12">+ <p className="text-primary text-center text-base leading-6" role="status">+ Checking project status ...+ </p>+ </div>+ );+}diff --git a/web/src/features/v4-migration/V4MigrationStatusPage.clienttest.tsx b/web/src/features/v4-migration/V4MigrationStatusPage.clienttest.tsxindex 3949ce6d9c..cb148346e2 100644--- a/web/src/features/v4-migration/V4MigrationStatusPage.clienttest.tsx+++ b/web/src/features/v4-migration/V4MigrationStatusPage.clienttest.tsx@@ -22,6 +22,7 @@ const mocks = vi.hoisted(() => ({// Evals are the simplest way to keep the single test project on the table:// ready projects are hidden, so most cases need one open action item.evalCount: 1,+ lastTracePending: false,}));vi.mock("next/router", () => ({@@ -113,10 +114,21 @@ vi.mock("@/src/features/v4-migration/hooks/useV4MigrationData", () => ({vi.mock("@/src/utils/api", () => ({api: {- organizations: {- lastTraceByProject: {- useQuery: () => ({ data: [] }),- },+ useQueries: (+ buildQueries: (router: {+ organizations: { lastTraceByProject: () => unknown };+ }) => unknown,+ ) => {+ buildQueries({+ organizations: {+ lastTraceByProject: vi.fn(),+ },+ });+ return [+ mocks.lastTracePending+ ? { data: undefined, isError: false }+ : { data: [], isError: false },+ ];},},}));@@ -133,6 +145,7 @@ describe("V4MigrationStatusPage", () => {delayedOtelIngestionCount: 0,};mocks.evalCount = 1;+ mocks.lastTracePending = false;});it("keeps the project table readable through horizontal scrolling", () => {@@ -163,7 +176,7 @@ describe("V4MigrationStatusPage", () => {).toBeInTheDocument();});- it("keeps projects whose checks are still running or failed", () => {+ it("hides project content until every migration check has finished", () => {mocks.evalCount = 0;mocks.sdk = {status: "checking",@@ -174,12 +187,28 @@ describe("V4MigrationStatusPage", () => {render(<V4MigrationStatusPage />);- expect(screen.getByText("Test project")).toBeInTheDocument();+ expect(screen.queryByText("Test project")).not.toBeInTheDocument();+ expect(screen.queryByRole("table")).not.toBeInTheDocument();+ expect(screen.queryByText("What's new in v4")).not.toBeInTheDocument();+ expect(screen.getByText(/Checking project status/)).toBeInTheDocument();+ expect(screen.getByRole("status")).toHaveClass("text-base", "leading-6");+ expect(screen.getByRole("status")).not.toHaveClass("text-2xl", "font-bold");expect(- screen.queryByText("All projects are up to date. Nothing to do here."),+ screen.queryByRole("img", { name: "Langfuse Icon" }),).not.toBeInTheDocument();});+ it("hides project content until last-trace data has finished loading", () => {+ mocks.lastTracePending = true;++ render(<V4MigrationStatusPage />);++ expect(screen.queryByText("Test project")).not.toBeInTheDocument();+ expect(screen.queryByRole("table")).not.toBeInTheDocument();+ expect(screen.queryByText("What's new in v4")).not.toBeInTheDocument();+ expect(screen.getByText(/Checking project status/)).toBeInTheDocument();+ });+it("opens the summary card with a link to the v4 docs", () => {render(<V4MigrationStatusPage />);diff --git a/web/src/features/v4-migration/V4MigrationStatusPage.tsx b/web/src/features/v4-migration/V4MigrationStatusPage.tsxindex 6b88e654cb..f4bf891ab7 100644--- a/web/src/features/v4-migration/V4MigrationStatusPage.tsx+++ b/web/src/features/v4-migration/V4MigrationStatusPage.tsx@@ -37,6 +37,7 @@ import {type ProjectMigrationStatus,} from "@/src/features/v4-migration/migrationData";import { PARTNER_INTEGRATION_FAQ_URL } from "@/src/features/v4-migration/partnerIntegrationDocs";+import { V4MigrationLoadingState } from "@/src/features/v4-migration/V4MigrationLoadingState";const V4_DOCS_URL = "https://langfuse.com/docs/v4";const SDK_UPGRADE_URL =@@ -161,18 +162,15 @@ function SortableHead({function OrgStatusSection({org,statusByProjectId,+ lastTraceTimes,}: {org: V4MigrationOrganization;statusByProjectId: Map<string, ProjectMigrationStatus>;+ lastTraceTimes: { projectId: string; lastTraceAt: Date }[];}) {const router = useRouter();const capture = usePostHogClientCapture();const openMigrationPanel = useOpenV4MigrationPanel();- const { data: lastTraceTimes } =- api.organizations.lastTraceByProject.useQuery(- { orgId: org.id },- { enabled: org.projects.length > 0 },- );const openProjectMigration = (row: { id: string; name: string },@@ -487,6 +485,18 @@ function V4MigrationStatusPageContent() {organizations: orgs,enabled: true,});+ // Start the table's remaining data alongside the migration checks. Keeping+ // these queries in the page lets one loading boundary wait for the complete+ // snapshot instead of mounting each organization table with placeholder+ // values that update after its rows become visible.+ const lastTraceQueries = api.useQueries((t) =>+ orgs.map((org) =>+ t.organizations.lastTraceByProject(+ { orgId: org.id },+ { enabled: org.projects.length > 0 },+ ),+ ),+ );const faqItems: { q: string; a: ReactNode }[] = [{@@ -578,9 +588,23 @@ function V4MigrationStatusPageContent() {// Ready projects are hidden from the org tables, so the page needs its own// "nothing left to do" state once every project drops out.const listedProjects = readiness.filter((state) => state !== "ready").length;- const isChecking =+ const isLoading =session.status === "loading" ||- readiness.some((state) => state === "checking");+ readiness.some((state) => state === "checking") ||+ orgs.some(+ (org, index) =>+ org.projects.length > 0 &&+ lastTraceQueries[index]?.data === undefined &&+ !lastTraceQueries[index]?.isError,+ );++ if (isLoading) {+ return (+ <ContainerPage headerProps={{ title: "Migration status" }}>+ <V4MigrationLoadingState />+ </ContainerPage>+ );+ }return (<ContainerPage@@ -601,11 +625,7 @@ function V4MigrationStatusPageContent() {{actionNeededProjects > 0 && <V4MigrationDeadlineNote />}</div><div className="flex flex-wrap items-baseline gap-x-2 gap-y-1">- {isChecking ? (- <span className="text-muted-foreground text-sm">- Checking project status…- </span>- ) : totalProjects === 0 ? (+ {totalProjects === 0 ? (<span className="text-muted-foreground text-sm">No active projects</span>@@ -625,15 +645,16 @@ function V4MigrationStatusPageContent() {</div></Card>- {orgs.map((org) => (+ {orgs.map((org, index) => (<OrgStatusSectionkey={org.id}org={org}statusByProjectId={statusByProjectId}+ lastTraceTimes={lastTraceQueries[index]?.data ?? []}/>))}- {!isChecking && totalProjects > 0 && listedProjects === 0 && (+ {totalProjects > 0 && listedProjects === 0 && (<p className="text-muted-foreground flex items-center gap-2.5 text-sm"><V4MigrationStatusDot variant="done" />All projects are up to date. Nothing to do here.