fix: resolve false 'static page' detection and missing route discovery on CLI-proxied apps

Three related fixes for the canvas live-render panel:

1. captureExistingTree() in fiber-hook — retroactively walks the already-
   mounted React fiber tree via __reactFiber$ DOM annotations. Called
   immediately on READY (handles post-hydration race) and again at 2 s
   (handles deferred hydration / Suspense). Prevents the 'Static HTML page'
   false positive on React apps that mounted before the hook script ran.

2. Static-page timer bumped from 4 s → 8 s in LiveArtboard to give the
   2-second captureExistingTree safety-net enough headroom before the
   no-React verdict fires.

3. Route discovery same-origin fix applied to both renderer/fiber-hook.ts
   and live-sdk/hook.ts — root-relative hrefs (starting with '/') are now
   accepted regardless of origin so CLI-proxied pages (where links still
   point to the original domain) expose their navigation routes correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
SinachPat
2026-05-07 08:36:20 +01:00
co-authored by Claude Sonnet 4.6
parent 3f1fd802bf
commit 8bbee987ff
3 changed files with 84 additions and 6 deletions
@@ -124,11 +124,13 @@ export function LiveArtboard({
pendingStylesFetchRef.current = selectedComponentId;
}
onReady?.();
// Start a 4-second timer: if React never commits, this is a static page.
// Start an 8-second timer: if React never commits (including the
// 2-second retroactive captureExistingTree safety net), this is
// genuinely a static page.
if (staticTimerRef.current) clearTimeout(staticTimerRef.current);
staticTimerRef.current = setTimeout(() => {
if (!hasReactRef.current) onStaticPageDetected?.();
}, 4000);
}, 8000);
break;
case 'FIBER_TREE_UPDATE':
// Mark that this iframe contains a live React app.