发布

  • [OPIK-6161] [FE] feat: add "New Opik experience" toggle for v1 users (#6436)

    frostbyte_neo 发布于 2026-04-22 14:10:20 +00:00

    • [OPIK-6161] [FE] feat: add "New Opik experience" toggle for v1 users

    Expose a single "New Opik experience" toggle in the Comet UserMenu for
    users in a v1 workspace. Flipping it writes a global
    opik-new-experience-opt-in localStorage flag and reloads the workspace
    home so v2 renders on next paint. The toggle is hidden on v2 workspaces
    (nothing to opt into) and when a debug version override is set (would
    be a no-op).

    WorkspaceVersionResolver mirrors the backend-reported version into a
    new store field (detectedWorkspaceVersion) so the UserMenu can gate
    visibility without standing up its own useWorkspaceVersionQuery
    subscription.

    Sync resolver priority: debug override > user opt-in > per-workspace
    cache > default. The opt-in is intentionally global — "I want the new
    Opik experience" is a user preference, not per-workspace — so opting
    in applies to every v1 workspace the user opens.

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

    • fix(workspace-version): cache backend truth, not resolved version

    The per-workspace cache (opik-workspace-versions) should mirror what
    the backend reported for that workspace. Writing resolvedVersion meant
    that an opt-in (or debug override) forcing v2 on a v1 workspace would
    pollute the cache with "v2", causing an extra reload on the next visit
    after the user opts out.

    Switch to writing apiVersion only when it's defined. Override and
    opt-in still layer on top via resolveSyncWorkspaceVersion.

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

    • fix(workspace-version): guard localStorage access + normalize redirect URL

    Two resiliency fixes from PR #6436 review:

    • getNewExperienceOptIn / setNewExperienceOptIn now wrap localStorage
      calls in try/catch, matching readVersionMap / setCachedWorkspaceVersion.
      Without the guard, SecurityError in private-browsing mode or a
      restrictive iframe would throw at module load inside
      resolveSyncWorkspaceVersion(), blocking first paint.

    • UserMenu's opt-in redirect now normalizes the trailing slash before
      appending the workspace name. VITE_BASE_URL is "/opik" (no slash) in
      the Comet build, so the previous concatenation would have produced
      "https://host/opikmyworkspace" instead of "https://host/opik/myworkspace".

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


    Co-authored-by: Jacques Verre jverre@gmail.com
    Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com

    下载附件