Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest NextJS + switch to turbopack #3027

Merged
merged 10 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { withSentryConfig } = require("@sentry/nextjs");
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
swcMinify: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not recognized anymore

publicRuntimeConfig: {
version,
},
Expand Down
288 changes: 208 additions & 80 deletions web/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.2-dev",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand All @@ -13,6 +13,7 @@
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@headlessui/tailwindcss": "^0.2.1",
"@headlessui/react": "^2.2.0",
"@phosphor-icons/react": "^2.0.8",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-popover": "^1.1.2",
Expand All @@ -39,7 +40,7 @@
"lodash": "^4.17.21",
"lucide-react": "^0.454.0",
"mdast-util-find-and-replace": "^3.0.1",
"next": "^14.2.3",
"next": "^15.0.2",
"npm": "^10.8.0",
"postcss": "^8.4.31",
"posthog-js": "^1.176.0",
Expand Down
536 changes: 535 additions & 1 deletion web/public/Wikipedia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion web/src/app/admin/assistants/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { AdminPageTitle } from "@/components/admin/Title";
import CardSection from "@/components/admin/CardSection";
import Title from "@/components/ui/title";

export default async function Page({ params }: { params: { id: string } }) {
export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const [values, error] = await fetchAssistantEditorInfoSS(params.id);

let body;
Expand Down
3 changes: 2 additions & 1 deletion web/src/app/admin/bot/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
} from "@/lib/assistants/fetchAssistantsSS";
import { getStandardAnswerCategoriesIfEE } from "@/components/standardAnswers/getStandardAnswerCategoriesIfEE";

async function Page({ params }: { params: { id: string } }) {
async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const tasks = [
fetchSS("/manage/admin/slack-bot/config"),
fetchSS("/manage/document-set"),
Expand Down
5 changes: 3 additions & 2 deletions web/src/app/admin/connector/[ccPairId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Button } from "@/components/ui/button";
import Title from "@/components/ui/title";
import { Separator } from "@/components/ui/separator";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState, use } from "react";
import useSWR, { mutate } from "swr";
import { AdvancedConfigDisplay, ConfigDisplay } from "./ConfigDisplay";
import { DeletionButton } from "./DeletionButton";
Expand Down Expand Up @@ -278,7 +278,8 @@ function Main({ ccPairId }: { ccPairId: number }) {
);
}

export default function Page({ params }: { params: { ccPairId: string } }) {
export default function Page(props: { params: Promise<{ ccPairId: string }> }) {
const params = use(props.params);
const ccPairId = parseInt(params.ccPairId);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {
import { processCookies } from "@/lib/userSS";

export const GET = async (request: NextRequest) => {
const requestCookies = await cookies();
const connector = request.url.includes("gmail") ? "gmail" : "google-drive";
const callbackEndpoint = `/manage/connector/${connector}/callback`;
const url = new URL(buildUrl(callbackEndpoint));
url.search = request.nextUrl.search;

const response = await fetch(url.toString(), {
headers: {
cookie: processCookies(cookies()),
cookie: processCookies(requestCookies),
},
});

Expand All @@ -33,7 +34,7 @@ export const GET = async (request: NextRequest) => {
? GMAIL_AUTH_IS_ADMIN_COOKIE_NAME
: GOOGLE_DRIVE_AUTH_IS_ADMIN_COOKIE_NAME;

if (cookies().get(authCookieName)?.value?.toLowerCase() === "true") {
if (requestCookies.get(authCookieName)?.value?.toLowerCase() === "true") {
return NextResponse.redirect(
new URL(`/admin/connectors/${connector}`, getDomain(request))
);
Expand Down
7 changes: 3 additions & 4 deletions web/src/app/admin/connectors/[connector]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ConfigurableSources } from "@/lib/types";
import ConnectorWrapper from "./ConnectorWrapper";

export default async function Page({
params,
}: {
params: { connector: string };
export default async function Page(props: {
params: Promise<{ connector: string }>;
}) {
const params = await props.params;
return (
<ConnectorWrapper
connector={params.connector.replace("-", "_") as ConfigurableSources}
Expand Down
7 changes: 3 additions & 4 deletions web/src/app/admin/documents/explorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { ZoomInIcon } from "@/components/icons/icons";
import { Explorer } from "./Explorer";
import { fetchValidFilterInfo } from "@/lib/search/utilsSS";

const Page = async ({
searchParams,
}: {
searchParams: { [key: string]: string };
const Page = async (props: {
searchParams: Promise<{ [key: string]: string }>;
}) => {
const searchParams = await props.searchParams;
const { connectors, documentSets } = await fetchValidFilterInfo();

return (
Expand Down
8 changes: 4 additions & 4 deletions web/src/app/admin/documents/sets/[documentSetId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { use } from "react";

import { ErrorCallout } from "@/components/ErrorCallout";
import { refreshDocumentSets, useDocumentSets } from "../hooks";
Expand Down Expand Up @@ -93,11 +94,10 @@ function Main({ documentSetId }: { documentSetId: number }) {
);
}

export default function Page({
params,
}: {
params: { documentSetId: string };
export default function Page(props: {
params: Promise<{ documentSetId: string }>;
}) {
const params = use(props.params);
const documentSetId = parseInt(params.documentSetId);

return (
Expand Down
4 changes: 3 additions & 1 deletion web/src/app/admin/indexing/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { use } from "react";

import { BackButton } from "@/components/BackButton";
import { ErrorCallout } from "@/components/ErrorCallout";
Expand Down Expand Up @@ -46,7 +47,8 @@ function Main({ id }: { id: number }) {
);
}

export default function Page({ params }: { params: { id: string } }) {
export default function Page(props: { params: Promise<{ id: string }> }) {
const params = use(props.params);
const id = parseInt(params.id);

return (
Expand Down
91 changes: 47 additions & 44 deletions web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TableHead,
TableBody,
TableCell,
TableHeader,
} from "@/components/ui/table";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -363,52 +364,54 @@ export function CCPairIndexingStatusTable({

return (
<Table>
<ConnectorRow
invisible
ccPairsIndexingStatus={{
cc_pair_id: 1,
name: "Sample File Connector",
cc_pair_status: ConnectorCredentialPairStatus.ACTIVE,
last_status: "success",
connector: {
<TableHeader>
<ConnectorRow
invisible
ccPairsIndexingStatus={{
cc_pair_id: 1,
name: "Sample File Connector",
source: "file",
input_type: "poll",
connector_specific_config: {
file_locations: ["/path/to/sample/file.txt"],
cc_pair_status: ConnectorCredentialPairStatus.ACTIVE,
last_status: "success",
connector: {
name: "Sample File Connector",
source: "file",
input_type: "poll",
connector_specific_config: {
file_locations: ["/path/to/sample/file.txt"],
},
refresh_freq: 86400,
prune_freq: null,
indexing_start: new Date("2023-07-01T12:00:00Z"),
id: 1,
credential_ids: [],
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
},
refresh_freq: 86400,
prune_freq: null,
indexing_start: new Date("2023-07-01T12:00:00Z"),
id: 1,
credential_ids: [],
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
},
credential: {
id: 1,
name: "Sample Credential",
source: "file",
user_id: "1",
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
credential_json: {},
admin_public: false,
},
access_type: "public",
docs_indexed: 1000,
last_success: "2023-07-01T12:00:00Z",
last_finished_status: "success",
latest_index_attempt: null,
owner: "1",
error_msg: "",
deletion_attempt: null,
is_deletable: true,
in_progress: false,
groups: [], // Add this line
}}
isEditable={false}
/>
credential: {
id: 1,
name: "Sample Credential",
source: "file",
user_id: "1",
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
credential_json: {},
admin_public: false,
},
access_type: "public",
docs_indexed: 1000,
last_success: "2023-07-01T12:00:00Z",
last_finished_status: "success",
latest_index_attempt: null,
owner: "1",
error_msg: "",
deletion_attempt: null,
is_deletable: true,
in_progress: false,
groups: [], // Add this line
}}
isEditable={false}
/>
</TableHeader>
<div className="flex -mt-12 items-center w-0 m4 gap-x-2">
<input
type="text"
Expand Down
5 changes: 4 additions & 1 deletion web/src/app/admin/tools/edit/[toolId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { AdminPageTitle } from "@/components/admin/Title";
import { BackButton } from "@/components/BackButton";
import { ToolIcon } from "@/components/icons/icons";

export default async function Page({ params }: { params: { toolId: string } }) {
export default async function Page(props: {
params: Promise<{ toolId: string }>;
}) {
const params = await props.params;
const tool = await fetchToolByIdSS(params.toolId);

let body;
Expand Down
21 changes: 14 additions & 7 deletions web/src/app/api/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,57 @@ each request type >:( */

export async function GET(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function POST(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function PUT(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function PATCH(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function DELETE(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function HEAD(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function OPTIONS(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

Expand Down
3 changes: 2 additions & 1 deletion web/src/app/assistants/edit/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { DeletePersonaButton } from "@/app/admin/assistants/[id]/DeletePersonaBu
import { LargeBackButton } from "../../LargeBackButton";
import Title from "@/components/ui/title";

export default async function Page({ params }: { params: { id: string } }) {
export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const [values, error] = await fetchAssistantEditorInfoSS(params.id);

let body;
Expand Down
13 changes: 8 additions & 5 deletions web/src/app/assistants/gallery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { unstable_noStore as noStore } from "next/cache";
import { redirect } from "next/navigation";
import WrappedAssistantsGallery from "./WrappedAssistantsGallery";
import { AssistantsProvider } from "@/components/context/AssistantsContext";
import { cookies } from "next/headers";

export default async function GalleryPage({
searchParams,
}: {
searchParams: { [key: string]: string };
export default async function GalleryPage(props: {
searchParams: Promise<{ [key: string]: string }>;
}) {
noStore();

const searchParams = await props.searchParams;
const requestCookies = await cookies();
const data = await fetchChatData(searchParams);

if ("redirect" in data) {
Expand All @@ -30,7 +31,9 @@ export default async function GalleryPage({

return (
<>
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
{shouldShowWelcomeModal && (
<WelcomeModal user={user} requestCookies={requestCookies} />
)}

<InstantSSRAutoRefresh />

Expand Down
Loading
Loading