-
[OPIK-6153] [OPIK-6151] [FE] perf: landing-route fast path for PermissionsGuard and WorkspacePreloader (#6477)
发布于
2026-04-24 13:34:44 +00:00 - [OPIK-6153] [FE] perf: skip PermissionsGuard loader on v2 /get-started
PermissionsGuard blocks render with a until
/permissions/organization/.../user/... returns. Post-OPIK-6066
measurements showed this added ~500 ms to first paint on every load,
including landing pages that have no permission-gated UI.Introduces a shared isLandingRoute() helper
(src/lib/landingRoutes.ts) that whitelists only /get-started — both
on cloud (/opik//get-started) and OSS (//get-started) base
paths. /home keeps the full guarded path.v2 PermissionsGuard consults the helper via
useLocation().pathname from @tanstack/react-router. On /get-started,
render children immediately; the permissions query still runs in the
background and checkNullablePermission defaults can* flags totrue
while pending. Admin users never waited today
(useUserPermissions hasenabled: !isAdmin). v1 not touched.Shared helper is also used by the OPIK-6151 WorkspacePreloader
fast-path (next commit on this branch).Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- [OPIK-6151] [FE] perf: skip WorkspacePreloader blocking waits on /get-started
After OPIK-6066 shipped, the post-signup bootstrap still ran a serial
chain before any UI painted:
/auth/test -> /organizations + /workspaces -> /workspaces?orgId=
adding ~2.8 s to LCP on every cold boot.Investigation documented on OPIK-6151 (comment 90326): the /auth/test
response already carries everything /get-started needs to paint —
defaultWorkspace (non-optional), loggedIn, suspended. /workspaces and
/organizations only feed the workspace switcher and access-gated UI
that lives off /get-started.Uses the shared isLandingRoute() helper from the previous commit.
On /get-started, after /auth/test returns and the logged-in redirect
check passes, apply the fast path when ALL hold:- user.defaultWorkspace === workspaceNameFromURL
(signup always redirects to /opik//get-started —
mismatch means returning user; fall back to full waterfall so the
access check runs) - !user.suspended
When matched: setActiveWorkspaceName from the URL param and return
children immediately — skip the /workspaces + /organizations
blocking waits. Both queries still fire (same
enabled: !!user?.loggedIngating), so the switcher and
multi-workspace UI populate after first paint. useUserPermissions has
its ownBoolean(organizationId && userName)guard, so no
empty-string API call fires while currentOrganization is undefined
during the brief post-paint window. Off landing routes, today's full
waterfall behavior is unchanged.Uses useLocation().pathname from @tanstack/react-router for
router-aware reactive matching.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com
下载附件