-
[OPIK-6150] [FE] perf: don't block app render on workspace version verify (#6452)
发布于
2026-04-23 11:35:05 +00:00 - [OPIK-6150] [FE] perf: don't block app render on workspace version verify
WorkspaceVersionResolver wrapped its children in a Loader until the
/workspaces/versions API call resolved. Measured cost: 600-2000ms per
load, sitting on the LCP critical path right after the gate mounts
V1App or V2App.The infrastructure for "render optimistically, reconcile async, reload
on mismatch" already exists: the Gate's resolveSyncWorkspaceVersion()
picks a version (override > opt-in > per-workspace cache > default v2)
before React mounts, and the Resolver's useEffect reloads on mismatch
(bounded by MAX_RELOADS). Drop the blocking Loader branch.Mismatch is rare — cache is correct for ~95% of returning users, and
new signups get v2 which is the only version new workspaces use. On
the rare mismatch path, the user sees the same 600-2000ms of
potentially-wrong UI before the reload kicks in; today they stare at
a Loader for the same window.Added a docstring on the component explaining the "render first, verify
async" contract so future readers don't reintroduce the Loader as a
defensive instinct.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- [OPIK-6150] [FE] fix: navigate to workspace root on version mismatch
The non-blocking change in the previous commit let V2App's TanStack
Router mount before the Resolver could detect a v1-workspace mismatch.
The router may rewrite the URL during that brief window (normalizing,
stripping unknown query params, or redirecting unmatched routes). By
the time the Resolver reloads to V1App, the URL is already corrupted
and v1 can't match it to a route.Fix: on version mismatch, navigate to the workspace root URL
(/opik/) instead of reloading the current URL. The correct
version's router then routes to home from that entrypoint. This is
the same pattern already used by UserMenu's new-experience toggle.Extracted the URL construction into a shared helper
navigateToWorkspaceRootin workspaceVersion.ts so both call sites
use the same code and intent.Tradeoff: users hitting a version mismatch lose their original deep
link (land on workspace home). Mismatch is rare (~5% of loads per
OPIK-6066 cache-hit measurements) and users with wrong cache almost
never have deep links worth preserving.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- [OPIK-6150] [FE] fix: block render on pair routes to preserve URL state
Pair routes carry critical state in search/hash (e.g.
/pair/v1?workspace=X#payload). Previously PairRouteVersionGuard
delegated to WorkspaceVersionResolver, which renders optimistically —
on a version mismatch, navigateToWorkspaceRoot would drop the query
and hash, breaking the pairing flow.Give the pair guard its own blocking version check instead. It waits
for /workspaces/versions before mounting children, so no router ever
touches the URL on the wrong version. On mismatch we can use a plain
window.location.reload() which preserves the full URL for the correct
App's router to pick up.Same reload-count safety pattern as WorkspaceVersionResolver
(VERSION_RELOAD_PREFIX + MAX_RELOADS = 2) to bound reload attempts
if cache writes are failing silently.Addresses baz-reviewer feedback on PR #6452.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- [OPIK-6150] [FE] fix: escape Loader when max reloads reached on pair guard
If reload count hit MAX_RELOADS while version mismatch was still
truthy, the guard would stay on indefinitely. On the
terminal path, align gateVersion with apiVersion somismatch
clears and children render.Addresses baz-reviewer feedback on PR #6452.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com
下载附件