Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(profile-ui): preserve root invite redirects
Josué426cf541329c
diff --git a/profile-ui/app/components/ProfileAppFrame/index.tsx b/profile-ui/app/components/ProfileAppFrame/index.tsxindex 3d9d14300..502d30d40 100644--- a/profile-ui/app/components/ProfileAppFrame/index.tsx+++ b/profile-ui/app/components/ProfileAppFrame/index.tsx@@ -1,16 +1,17 @@'use client'import type { ReactNode } from 'react'-import { usePathname } from 'next/navigation'+import { usePathname, useSearchParams } from 'next/navigation'import { AuthGate } from '@components/AuthGate'import { ProfileAccessProvider } from '@components/ProfileAccessContext'import { ProfileShell } from '@components/ProfileShell'-import { isPublicProfileUiPath } from '@lib/profileAppFrame'+import { isPublicProfileUiRequest } from '@lib/profileAppFrame'export function ProfileAppFrame({ children }: { children: ReactNode }) {const pathname = usePathname()+ const searchParams = useSearchParams()- if (isPublicProfileUiPath(pathname)) {+ if (isPublicProfileUiRequest(pathname, searchParams)) {return <>{children}</>}diff --git a/profile-ui/app/layout.tsx b/profile-ui/app/layout.tsxindex 964705851..4f2d6b311 100644--- a/profile-ui/app/layout.tsx+++ b/profile-ui/app/layout.tsx@@ -1,4 +1,5 @@import type { ReactNode } from 'react'+import { Suspense } from 'react'import type { Metadata } from 'next'import { AuthProvider } from '@components/AuthContext'import { ProfileAppFrame } from '@components/ProfileAppFrame'@@ -27,7 +28,9 @@ export default function RootLayout({ children }: { children: ReactNode }) {<body className="cu-body"><ToastProvider><AuthProvider>- <ProfileAppFrame>{children}</ProfileAppFrame>+ <Suspense fallback={null}>+ <ProfileAppFrame>{children}</ProfileAppFrame>+ </Suspense></AuthProvider></ToastProvider></body>diff --git a/profile-ui/lib/profileAppFrame.ts b/profile-ui/lib/profileAppFrame.tsindex 25f6ba73f..f7eb2fad1 100644--- a/profile-ui/lib/profileAppFrame.ts+++ b/profile-ui/lib/profileAppFrame.ts@@ -6,6 +6,12 @@ export function isPublicProfileUiPath(pathname: string): boolean {)}+export function isPublicProfileUiRequest(pathname: string, searchParams: URLSearchParams): boolean {+ if (isPublicProfileUiPath(pathname)) return true+ const inviteToken = searchParams.get('inviteToken')+ return pathname === '/' && inviteToken !== null && inviteToken.length > 0+}+export type ProfileRouteKey =| 'home'| 'members'diff --git a/profile-ui/test/profileAppFrame.test.ts b/profile-ui/test/profileAppFrame.test.tsindex 319e42e7d..c6727e1f7 100644--- a/profile-ui/test/profileAppFrame.test.ts+++ b/profile-ui/test/profileAppFrame.test.ts@@ -1,6 +1,10 @@import assert from 'node:assert/strict'import test from 'node:test'-import { isPublicProfileUiPath, profileRouteForPathname } from '../lib/profileAppFrame'+import {+ isPublicProfileUiPath,+ isPublicProfileUiRequest,+ profileRouteForPathname,+} from '../lib/profileAppFrame'test('public profile routes stay outside the authenticated application frame', () => {for (const pathname of ['/desktop-setup', '/forgot-password', '/invitations/token']) {@@ -14,6 +18,14 @@ test('authenticated profile routes use the persistent application frame', () =>}})+test('root inviteToken redirects stay public without making every root query public', () => {+ assert.equal(isPublicProfileUiRequest('/', new URLSearchParams('inviteToken=abc')), true)+ assert.equal(isPublicProfileUiRequest('/', new URLSearchParams('inviteToken=a%2Fb%20c')), true)+ assert.equal(isPublicProfileUiRequest('/', new URLSearchParams('inviteToken=')), false)+ assert.equal(isPublicProfileUiRequest('/', new URLSearchParams('email=a%40example.com')), false)+ assert.equal(isPublicProfileUiRequest('/members', new URLSearchParams('inviteToken=abc')), false)+})+test('profileRouteForPathname derives the active persistent sidebar route', () => {assert.equal(profileRouteForPathname('/'), 'home')assert.equal(profileRouteForPathname('/members/member-1'), 'members')