Skip to content

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

refactor(web): thin remaining fat pages into feature Page components (#17728)

Nikita Kabardin4d9a3ba4e551
diff --git a/web/src/__tests__/auth-error-page.clienttest.tsx b/web/src/__tests__/auth-error-page.clienttest.tsx
index 04261eeb49..4141341275 100644
--- a/web/src/__tests__/auth-error-page.clienttest.tsx
+++ b/web/src/__tests__/auth-error-page.clienttest.tsx
@@ -1,6 +1,6 @@
import { render } from "@testing-library/react";
-import AuthError from "@/src/pages/auth/error";
+import AuthError from "@/src/features/auth/AuthErrorPage";
import { MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE } from "@/src/features/auth/constants";
const { captureExceptionMock, addBreadcrumbMock, routerState } = vi.hoisted(
diff --git a/web/src/__tests__/detail-page-route-params.clienttest.tsx b/web/src/__tests__/detail-page-route-params.clienttest.tsx
index ac78a39655..fe2ff9b678 100644
--- a/web/src/__tests__/detail-page-route-params.clienttest.tsx
+++ b/web/src/__tests__/detail-page-route-params.clienttest.tsx
@@ -63,7 +63,7 @@ vi.mock("@/src/features/experiments/components/table", () => ({
}));
import TracePageRoute from "@/src/pages/project/[projectId]/traces/[traceId]";
-import SessionPageRoute from "@/src/pages/project/[projectId]/sessions/[sessionId]";
+import SessionPageRoute from "@/src/features/sessions/SessionDetailPage";
import AnnotationQueueItemRoute from "@/src/pages/project/[projectId]/annotation-queues/[queueId]/items/[itemId]";
import AnnotationQueueItemsIndexRoute from "@/src/pages/project/[projectId]/annotation-queues/[queueId]/index";
import DatasetExperimentsRoute from "@/src/pages/project/[projectId]/datasets/[datasetId]/experiments/index";
diff --git a/web/src/features/auth-credentials/ResetPasswordAuthPage.tsx b/web/src/features/auth-credentials/ResetPasswordAuthPage.tsx
new file mode 100644
index 0000000000..be55d23cd2
--- /dev/null
+++ b/web/src/features/auth-credentials/ResetPasswordAuthPage.tsx
@@ -0,0 +1,11 @@
+import { ResetPasswordPage } from "@/src/features/auth-credentials/components/ResetPasswordPage";
+
+type PageProps = {
+ passwordResetAvailable: boolean;
+};
+
+export default function ResetPasswordAuthPage({
+ passwordResetAvailable,
+}: PageProps) {
+ return <ResetPasswordPage passwordResetAvailable={passwordResetAvailable} />;
+}
diff --git a/web/src/features/auth-credentials/SetupPasswordPage.tsx b/web/src/features/auth-credentials/SetupPasswordPage.tsx
new file mode 100644
index 0000000000..b8c537e7d1
--- /dev/null
+++ b/web/src/features/auth-credentials/SetupPasswordPage.tsx
@@ -0,0 +1,16 @@
+import { ResetPasswordPage } from "@/src/features/auth-credentials/components/ResetPasswordPage";
+
+type PageProps = {
+ passwordResetAvailable: boolean;
+};
+
+export default function SetupPasswordPage({
+ passwordResetAvailable,
+}: PageProps) {
+ return (
+ <ResetPasswordPage
+ passwordResetAvailable={passwordResetAvailable}
+ intent="setup"
+ />
+ );
+}
diff --git a/web/src/features/auth-credentials/server/getPasswordResetAvailableServerSideProps.ts b/web/src/features/auth-credentials/server/getPasswordResetAvailableServerSideProps.ts
new file mode 100644
index 0000000000..4c7d5507d9
--- /dev/null
+++ b/web/src/features/auth-credentials/server/getPasswordResetAvailableServerSideProps.ts
@@ -0,0 +1,14 @@
+import { env } from "@/src/env.mjs";
+import { type GetServerSideProps } from "next";
+
+export const getServerSideProps: GetServerSideProps<{
+ passwordResetAvailable: boolean;
+}> = async () => {
+ return {
+ props: {
+ passwordResetAvailable:
+ env.SMTP_CONNECTION_URL !== undefined &&
+ env.EMAIL_FROM_ADDRESS !== undefined,
+ },
+ };
+};
diff --git a/web/src/features/auth/AuthErrorPage.tsx b/web/src/features/auth/AuthErrorPage.tsx
new file mode 100644
index 0000000000..2e452c0171
--- /dev/null
+++ b/web/src/features/auth/AuthErrorPage.tsx
@@ -0,0 +1,23 @@
+import { ErrorPageWithSentry } from "@/src/components/error-page";
+import { isExpectedAuthErrorPageMessage } from "@/src/features/auth/lib/expectedAuthErrors";
+import { useRouter } from "next/router";
+
+export default function AuthErrorPage() {
+ const router = useRouter();
+ const { error } = router.query;
+ const errorMessage = error
+ ? decodeURIComponent(String(error))
+ : "An authentication error occurred. Please reach out to support.";
+
+ return (
+ <ErrorPageWithSentry
+ title="Authentication Error"
+ message={errorMessage}
+ // Expired magic links and deliberate SSO-domain rejections are expected
+ // outcomes (see expectedAuthErrors.ts); unknown values still capture.
+ expected={
+ error !== undefined && isExpectedAuthErrorPageMessage(errorMessage)
+ }
+ />
+ );
+}
diff --git a/web/src/features/datasets/DatasetRedirectPage.tsx b/web/src/features/datasets/DatasetRedirectPage.tsx
new file mode 100644
index 0000000000..46f5713c97
--- /dev/null
+++ b/web/src/features/datasets/DatasetRedirectPage.tsx
@@ -0,0 +1,24 @@
+import { type GetServerSideProps } from "next";
+
+// Keep the bare dataset URL as an alias only; tab content lives on explicit routes.
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ notFound: true,
+ };
+ }
+
+ const projectId = context.params.projectId as string;
+ const datasetId = context.params.datasetId as string;
+
+ return {
+ redirect: {
+ destination: `/project/${projectId}/datasets/${datasetId}/items`,
+ permanent: false,
+ },
+ };
+};
+
+export default function DatasetRedirectPage() {
+ return <div>Redirecting...</div>;
+}
diff --git a/web/src/features/evals/EvalConfigsConfigRedirectPage.tsx b/web/src/features/evals/EvalConfigsConfigRedirectPage.tsx
new file mode 100644
index 0000000000..79d78e2341
--- /dev/null
+++ b/web/src/features/evals/EvalConfigsConfigRedirectPage.tsx
@@ -0,0 +1,11 @@
+import { useRouter } from "next/router";
+
+// This url is deprecated, we keep this redirect page for backward compatibility
+export default function EvalConfigsConfigRedirectPage() {
+ const router = useRouter();
+ if (router.isFallback) {
+ return <div className="p-3">Loading...</div>;
+ }
+
+ return <div>Redirecting...</div>;
+}
diff --git a/web/src/features/evals/server/getEvalConfigsConfigRedirectPageServerSideProps.ts b/web/src/features/evals/server/getEvalConfigsConfigRedirectPageServerSideProps.ts
new file mode 100644
index 0000000000..ee873dca95
--- /dev/null
+++ b/web/src/features/evals/server/getEvalConfigsConfigRedirectPageServerSideProps.ts
@@ -0,0 +1,40 @@
+import { prisma } from "@langfuse/shared/src/db";
+import { type GetServerSideProps } from "next";
+
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ notFound: true,
+ };
+ }
+
+ const projectId = context.params.projectId as string;
+ const evaluatorId = context.params.configId as string;
+
+ const evaluator = await prisma.evaluationRule.findUnique({
+ where: {
+ id: evaluatorId,
+ projectId,
+ },
+ select: {
+ project: {
+ select: {
+ id: true,
+ },
+ },
+ },
+ });
+
+ if (!evaluator) {
+ return {
+ notFound: true,
+ };
+ }
+
+ return {
+ redirect: {
+ destination: `/project/${projectId}/evals/legacy/${evaluatorId}`,
+ permanent: false,
+ },
+ };
+};
diff --git a/web/src/features/sessions/SessionDetailPage.tsx b/web/src/features/sessions/SessionDetailPage.tsx
new file mode 100644
index 0000000000..20e70c0969
--- /dev/null
+++ b/web/src/features/sessions/SessionDetailPage.tsx
@@ -0,0 +1,24 @@
+import {
+ SessionEventsPage,
+ SessionPage,
+} from "@/src/features/sessions/SessionPages";
+import { useReadPath } from "@/src/features/events/hooks/useReadPath";
+import {
+ RouteParamsPendingFallback,
+ useReadyRouteParams,
+} from "@/src/hooks/useReadyRouteParams";
+
+export default function SessionDetailPage() {
+ const route = useReadyRouteParams(["projectId", "sessionId"]);
+ const { isV4 } = useReadPath();
+
+ if (!route.ready) return <RouteParamsPendingFallback />;
+
+ const { projectId, sessionId } = route.params;
+
+ return isV4 ? (
+ <SessionEventsPage sessionId={sessionId} projectId={projectId} />
+ ) : (
+ <SessionPage sessionId={sessionId} projectId={projectId} />
+ );
+}
diff --git a/web/src/features/web-callouts/WebCalloutsPage.tsx b/web/src/features/web-callouts/WebCalloutsPage.tsx
new file mode 100644
index 0000000000..0c8b9479d5
--- /dev/null
+++ b/web/src/features/web-callouts/WebCalloutsPage.tsx
@@ -0,0 +1,26 @@
+import ContainerPage from "@/src/components/layouts/container-page";
+import { WebCalloutSettingsPage } from "@/src/features/web-callouts/components/WebCalloutSettingsPage";
+import { RouteParamsPendingFallback } from "@/src/hooks/useReadyRouteParams";
+import { useRouter } from "next/router";
+
+export default function WebCalloutsPage() {
+ const router = useRouter();
+ const projectId = router.query.projectId as string | undefined;
+
+ if (!projectId) {
+ return <RouteParamsPendingFallback />;
+ }
+
+ return (
+ <ContainerPage
+ headerProps={{
+ title: "Web Callouts",
+ breadcrumb: [
+ { name: "Settings", href: `/project/${projectId}/settings` },
+ ],
+ }}
+ >
+ <WebCalloutSettingsPage projectId={projectId} />
+ </ContainerPage>
+ );
+}
diff --git a/web/src/pages/auth/error.tsx b/web/src/pages/auth/error.tsx
index e02fcf48eb..004b7c7396 100644
--- a/web/src/pages/auth/error.tsx
+++ b/web/src/pages/auth/error.tsx
@@ -1,23 +1 @@
-import { ErrorPageWithSentry } from "@/src/components/error-page";
-import { isExpectedAuthErrorPageMessage } from "@/src/features/auth/lib/expectedAuthErrors";
-import { useRouter } from "next/router";
-
-export default function AuthError() {
- const router = useRouter();
- const { error } = router.query;
- const errorMessage = error
- ? decodeURIComponent(String(error))
- : "An authentication error occurred. Please reach out to support.";
-
- return (
- <ErrorPageWithSentry
- title="Authentication Error"
- message={errorMessage}
- // Expired magic links and deliberate SSO-domain rejections are expected
- // outcomes (see expectedAuthErrors.ts); unknown values still capture.
- expected={
- error !== undefined && isExpectedAuthErrorPageMessage(errorMessage)
- }
- />
- );
-}
+export { default } from "@/src/features/auth/AuthErrorPage";
diff --git a/web/src/pages/auth/reset-password.tsx b/web/src/pages/auth/reset-password.tsx
index e265c5e985..e339b95cbe 100644
--- a/web/src/pages/auth/reset-password.tsx
+++ b/web/src/pages/auth/reset-password.tsx
@@ -1,23 +1,2 @@
-import { env } from "@/src/env.mjs";
-import { ResetPasswordPage } from "@/src/features/auth-credentials/components/ResetPasswordPage";
-import { type GetServerSideProps } from "next";
-
-type PageProps = {
- passwordResetAvailable: boolean;
-};
-
-export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
- return {
- props: {
- passwordResetAvailable:
- env.SMTP_CONNECTION_URL !== undefined &&
- env.EMAIL_FROM_ADDRESS !== undefined,
- },
- };
-};
-
-const Page = ({ passwordResetAvailable }: PageProps) => {
- return <ResetPasswordPage passwordResetAvailable={passwordResetAvailable} />;
-};
-
-export default Page;
+export { default } from "@/src/features/auth-credentials/ResetPasswordAuthPage";
+export { getServerSideProps } from "@/src/features/auth-credentials/server/getPasswordResetAvailableServerSideProps";
diff --git a/web/src/pages/auth/setup-password.tsx b/web/src/pages/auth/setup-password.tsx
index 0b998585f4..9c13406e9a 100644
--- a/web/src/pages/auth/setup-password.tsx
+++ b/web/src/pages/auth/setup-password.tsx
@@ -1,28 +1,2 @@
-import { env } from "@/src/env.mjs";
-import { ResetPasswordPage } from "@/src/features/auth-credentials/components/ResetPasswordPage";
-import { type GetServerSideProps } from "next";
-
-type PageProps = {
- passwordResetAvailable: boolean;
-};
-
-export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
- return {
- props: {
- passwordResetAvailable:
- env.SMTP_CONNECTION_URL !== undefined &&
- env.EMAIL_FROM_ADDRESS !== undefined,
- },
- };
-};
-
-const Page = ({ passwordResetAvailable }: PageProps) => {
- return (
- <ResetPasswordPage
- passwordResetAvailable={passwordResetAvailable}
- intent="setup"
- />
- );
-};
-
-export default Page;
+export { default } from "@/src/features/auth-credentials/SetupPasswordPage";
+export { getServerSideProps } from "@/src/features/auth-credentials/server/getPasswordResetAvailableServerSideProps";
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
index 8a046a37f8..7a3020c187 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
@@ -1,24 +1,4 @@
-import { type GetServerSideProps } from "next";
-
-// Keep the bare dataset URL as an alias only; tab content lives on explicit routes.
-export const getServerSideProps: GetServerSideProps = async (context) => {
- if (!context.params) {
- return {
- notFound: true,
- };
- }
-
- const projectId = context.params.projectId as string;
- const datasetId = context.params.datasetId as string;
-
- return {
- redirect: {
- destination: `/project/${projectId}/datasets/${datasetId}/items`,
- permanent: false,
- },
- };
-};
-
-export default function RedirectPage() {
- return <div>Redirecting...</div>;
-}
+export {
+ default,
+ getServerSideProps,
+} from "@/src/features/datasets/DatasetRedirectPage";
diff --git a/web/src/pages/project/[projectId]/evals/configs/[configId].tsx b/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
index 25a4b9ed6c..ac262d493f 100644
--- a/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
+++ b/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
@@ -1,51 +1,2 @@
-import { prisma } from "@langfuse/shared/src/db";
-import { type GetServerSideProps } from "next";
-import { useRouter } from "next/router";
-
-// This url is deprecated, we keep this redirect page for backward compatibility
-export const getServerSideProps: GetServerSideProps = async (context) => {
- if (!context.params) {
- return {
- notFound: true,
- };
- }
-
- const projectId = context.params.projectId as string;
- const evaluatorId = context.params.configId as string;
-
- const evaluator = await prisma.evaluationRule.findUnique({
- where: {
- id: evaluatorId,
- projectId,
- },
- select: {
- project: {
- select: {
- id: true,
- },
- },
- },
- });
-
- if (!evaluator) {
- return {
- notFound: true,
- };
- }
-
- return {
- redirect: {
- destination: `/project/${projectId}/evals/legacy/${evaluatorId}`,
- permanent: false,
- },
- };
-};
-
-export default function RedirectPage() {
- const router = useRouter();
- if (router.isFallback) {
- return <div className="p-3">Loading...</div>;
- }
-
- return <div>Redirecting...</div>;
-}
+export { default } from "@/src/features/evals/EvalConfigsConfigRedirectPage";
+export { getServerSideProps } from "@/src/features/evals/server/getEvalConfigsConfigRedirectPageServerSideProps";
diff --git a/web/src/pages/project/[projectId]/sessions/[sessionId].tsx b/web/src/pages/project/[projectId]/sessions/[sessionId].tsx
index be3b3ca3c2..085016f7f8 100644
--- a/web/src/pages/project/[projectId]/sessions/[sessionId].tsx
+++ b/web/src/pages/project/[projectId]/sessions/[sessionId].tsx
@@ -1,24 +1 @@
-import {
- SessionEventsPage,
- SessionPage,
-} from "@/src/features/sessions/SessionPages";
-import { useReadPath } from "@/src/features/events/hooks/useReadPath";
-import {
- RouteParamsPendingFallback,
- useReadyRouteParams,
-} from "@/src/hooks/useReadyRouteParams";
-
-export default function Session() {
- const route = useReadyRouteParams(["projectId", "sessionId"]);
- const { isV4 } = useReadPath();
-
- if (!route.ready) return <RouteParamsPendingFallback />;
-
- const { projectId, sessionId } = route.params;
-
- return isV4 ? (
- <SessionEventsPage sessionId={sessionId} projectId={projectId} />
- ) : (
- <SessionPage sessionId={sessionId} projectId={projectId} />
- );
-}
+export { default } from "@/src/features/sessions/SessionDetailPage";
diff --git a/web/src/pages/project/[projectId]/settings/integrations/web-callouts.tsx b/web/src/pages/project/[projectId]/settings/integrations/web-callouts.tsx
index e317da3bf4..eddfd3f908 100644
--- a/web/src/pages/project/[projectId]/settings/integrations/web-callouts.tsx
+++ b/web/src/pages/project/[projectId]/settings/integrations/web-callouts.tsx
@@ -1,25 +1 @@
-import ContainerPage from "@/src/components/layouts/container-page";
-import { WebCalloutSettingsPage } from "@/src/features/web-callouts/components/WebCalloutSettingsPage";
-import { useRouter } from "next/router";
-
-export default function WebCalloutsSettings() {
- const router = useRouter();
- const projectId = router.query.projectId as string | undefined;
-
- if (!projectId) {
- return null;
- }
-
- return (
- <ContainerPage
- headerProps={{
- title: "Web Callouts",
- breadcrumb: [
- { name: "Settings", href: `/project/${projectId}/settings` },
- ],
- }}
- >
- <WebCalloutSettingsPage projectId={projectId} />
- </ContainerPage>
- );
-}
+export { default } from "@/src/features/web-callouts/WebCalloutsPage";