From 27be332e4b1c133b25b0325171c470d960ccac78 Mon Sep 17 00:00:00 2001 From: ashrafchowdury Date: Tue, 26 Nov 2024 15:21:18 +0600 Subject: [PATCH 1/4] fix(frontend): wait until project-id gets loaded --- agenta-web/src/components/Layout/Layout.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agenta-web/src/components/Layout/Layout.tsx b/agenta-web/src/components/Layout/Layout.tsx index 29691ee915..1bfa808ba1 100644 --- a/agenta-web/src/components/Layout/Layout.tsx +++ b/agenta-web/src/components/Layout/Layout.tsx @@ -17,6 +17,7 @@ import {ThemeProvider} from "react-jss" import {JSSTheme, StyleProps as MainStyleProps} from "@/lib/Types" import {Lightning} from "@phosphor-icons/react" import packageJsonData from "../../../package.json" +import {useProjectData} from "@/contexts/project.context" const {Content, Footer} = Layout const {Text} = Typography @@ -85,6 +86,7 @@ const App: React.FC = ({children}) => { const {appTheme} = useAppTheme() const {currentApp} = useAppsData() const [footerRef, {height: footerHeight}] = useElementSize() + const {isProjectId} = useProjectData() const classes = useStyles({themeMode: appTheme, footerHeight} as StyleProps) const router = useRouter() const appId = router.query.app_id as string @@ -158,6 +160,8 @@ const App: React.FC = ({children}) => { } }, [appTheme]) + if (!isProjectId) return null + // wait unitl we have the app id, if its an app route if (isAppRoute && (!appId || !currentApp)) return null From 94a578827d27e5d2ef932cffc71417d7ac83fbb2 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Tue, 26 Nov 2024 12:19:58 +0100 Subject: [PATCH 2/4] fix project provider/context --- agenta-web/src/components/Layout/Layout.tsx | 10 +++++----- agenta-web/src/contexts/project.context.tsx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/agenta-web/src/components/Layout/Layout.tsx b/agenta-web/src/components/Layout/Layout.tsx index 1bfa808ba1..e6d84b2ae7 100644 --- a/agenta-web/src/components/Layout/Layout.tsx +++ b/agenta-web/src/components/Layout/Layout.tsx @@ -160,24 +160,24 @@ const App: React.FC = ({children}) => { } }, [appTheme]) - if (!isProjectId) return null - // wait unitl we have the app id, if its an app route if (isAppRoute && (!appId || !currentApp)) return null + const isAuthRoute = + router.pathname.includes("/auth") || router.pathname.includes("/post-signup") + return ( {typeof window === "undefined" ? null : ( - {router.pathname.includes("/auth") || - router.pathname.includes("/post-signup") ? ( + {isAuthRoute || !isProjectId ? ( {children} {contextHolder} - ) : ( + ) : ( // !isAuthRoute && isProjectId diff --git a/agenta-web/src/contexts/project.context.tsx b/agenta-web/src/contexts/project.context.tsx index c3278fae18..a527320d20 100644 --- a/agenta-web/src/contexts/project.context.tsx +++ b/agenta-web/src/contexts/project.context.tsx @@ -44,7 +44,7 @@ export const getCurrentProject = () => projectContextValues const ProjectContextProvider: React.FC = ({children}) => { const [project, setProject] = useStateCallback(null) const [useOrgData, setUseOrgData] = useState(() => () => "") - const [isLoading, setIsLoading] = useState(false) + const [isLoading, setIsLoading] = useState(true) const {doesSessionExist} = useSession() useEffect(() => { @@ -57,7 +57,7 @@ const ProjectContextProvider: React.FC = ({children}) => { const workspaceId: string = selectedOrg?.default_workspace.id || DEFAULT_UUID - const isProjectId = !isLoading && Boolean(project?.project_id) + const isProjectId = !isLoading && !!project?.project_id const projectId = (project?.project_id as string) || DEFAULT_UUID const fetcher = async (onSuccess?: () => void) => { @@ -103,7 +103,7 @@ const ProjectContextProvider: React.FC = ({children}) => { refetch: fetcher, }} > - {children} + {isProjectId ? children : null} ) } From 038f99c3751af33e8a4eaafa663675f1e100d1b2 Mon Sep 17 00:00:00 2001 From: ashrafchowdury Date: Tue, 26 Nov 2024 17:43:19 +0600 Subject: [PATCH 3/4] fix(prettire): format --- agenta-web/src/components/Layout/Layout.tsx | 3 ++- agenta-web/src/components/Playground/Views/TestView.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/agenta-web/src/components/Layout/Layout.tsx b/agenta-web/src/components/Layout/Layout.tsx index e6d84b2ae7..ac8c491e42 100644 --- a/agenta-web/src/components/Layout/Layout.tsx +++ b/agenta-web/src/components/Layout/Layout.tsx @@ -177,7 +177,8 @@ const App: React.FC = ({children}) => { {contextHolder} - ) : ( // !isAuthRoute && isProjectId + ) : ( + // !isAuthRoute && isProjectId diff --git a/agenta-web/src/components/Playground/Views/TestView.tsx b/agenta-web/src/components/Playground/Views/TestView.tsx index 2da370ae79..5a3e1e8b60 100644 --- a/agenta-web/src/components/Playground/Views/TestView.tsx +++ b/agenta-web/src/components/Playground/Views/TestView.tsx @@ -219,7 +219,7 @@ const BoxComponent: React.FC = ({ } }, [traceSpans]) - const activeTrace = useMemo(() => (traces ? traces[0] ?? null : null), [traces]) + const activeTrace = useMemo(() => (traces ? (traces[0] ?? null) : null), [traces]) const [selected, setSelected] = useState("") useEffect(() => { From 6f4ede86c792b64f21943432f659b60a505cbb24 Mon Sep 17 00:00:00 2001 From: ashrafchowdury Date: Tue, 26 Nov 2024 17:58:31 +0600 Subject: [PATCH 4/4] fix format --- agenta-web/src/components/Playground/Views/TestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agenta-web/src/components/Playground/Views/TestView.tsx b/agenta-web/src/components/Playground/Views/TestView.tsx index 5a3e1e8b60..2da370ae79 100644 --- a/agenta-web/src/components/Playground/Views/TestView.tsx +++ b/agenta-web/src/components/Playground/Views/TestView.tsx @@ -219,7 +219,7 @@ const BoxComponent: React.FC = ({ } }, [traceSpans]) - const activeTrace = useMemo(() => (traces ? (traces[0] ?? null) : null), [traces]) + const activeTrace = useMemo(() => (traces ? traces[0] ?? null : null), [traces]) const [selected, setSelected] = useState("") useEffect(() => {