发布

  • [OPIK-6373] [FE] feat: consume lite workspace endpoint with safe fallback (#6676)

    frostbyte_neo 发布于 2026-05-14 12:37:31 +00:00

    • [OPIK-6373] [FE] feat: consume lite workspace endpoint with 404 fallback

    Adds useUserWorkspacesLite probing GET /workspaces/lite and rewrites
    useAllWorkspaces as an orchestrator: lite-first, falling back to the
    union of useUserInvitedWorkspaces + useAdminOrganizationWorkspaces when
    the BE returns 404. Removes Opik from /workspaces as a load source when
    the BE supports it (1 HTTP call + 1 SQL query instead of 1 + N admin
    orgs, each amplified by ~3 queries per workspace).

    Safe to ship before BE rollout: on 404 the legacy hooks fire and
    behavior is identical to today. Selector dropdown now also shows
    admin-of-org workspaces on the lite path (intentional UX fix; access
    was already granted server-side).

    • perf(comet): virtualize workspace switcher dropdown above 50 items

    When a user has many workspaces (Binance scale: ~2,800), opening the
    workspace switcher synchronously creates one DropdownMenuItem + Radix
    TooltipWrapper portal per workspace — measurable lag (estimated
    500-2000ms) on dropdown open, plus every search keystroke re-renders
    the full list.

    Wrap the scroll container in @tanstack/react-virtual's useVirtualizer
    (already a project dep, same pattern as TraceTreeViewer and MessagesTab).
    Only kicks in above 50 items so small users keep the simpler render path
    and the behavior is bit-for-bit unchanged for them.

    Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

    • refactor(comet): broaden fallback to any error and drop discriminated union

    The orchestrator used to only fall back on 404, leaving the page stuck
    on a loader if /api/workspaces/lite returned 405 (proxy rewrite), 5xx
    (partial outage), or a network failure. In real ops these happen — make
    the fallback unconditional on any error.

    Once the fallback is "on any error", the LiteWorkspacesResult union
    becomes redundant. Replace it with React Query's native isError flag:
    useUserWorkspacesLite now returns Workspace[] directly and lets errors
    propagate; useAllWorkspaces reads lite.isError to gate the legacy hooks.
    Set retry: false so the fallback kicks in immediately instead of burning
    ~10s on exponential-backoff retries.

    Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

    • refactor(comet): narrow useAllWorkspaces options to { enabled? }

    Per PR review on #6676: the previous QueryConfig<Workspace[]> signature
    advertised a wide React Query option surface (staleTime, cacheTime,
    callbacks, etc.) but only options.enabled was actually read. Narrow the
    type to what's actually consumed so the API can't silently drop options.
    All 9 callsites already pass only { enabled } so this is a type-only
    change.

    Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com


    Co-authored-by: Claude Opus 4.7 noreply@anthropic.com

    下载附件