发布

  • [OPIK-6151] [FE] perf: skip WorkspacePreloader blocking waits on /get-started

    frostbyte_neo 发布于 2026-04-24 10:49:57 +00:00

    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 signup-landing 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
      (suspended accounts must not bypass the access check; fall back)

    When matched: setActiveWorkspaceName from the URL param and return
    children immediately — skip the /workspaces + /organizations
    blocking waits. Both queries still fire (same enabled: !!user?.loggedIn gating), so the switcher and multi-workspace UI
    populate after first paint. useUserPermissions has its own
    Boolean(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 (not
    window.location) for router-aware reactive matching.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    下载附件