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
+10 -1
View File
@@ -442,9 +442,18 @@ function installFiberHook(): void {
// Current route first
addRoute(window.location.pathname, document.title || undefined);
// Scan real <a> elements
// Scan real <a> elements — accept root-relative paths regardless of origin
// so that CLI-proxied pages (where links still point to the original domain)
// are handled correctly alongside direct same-origin connections.
document.querySelectorAll<HTMLAnchorElement>('a[href]').forEach((a) => {
try {
const rawHref = (a.getAttribute('href') ?? '').trim();
// Root-relative paths are always valid routes.
if (rawHref.startsWith('/')) {
addRoute(rawHref, a.textContent ?? undefined);
return;
}
// Absolute URLs — only add if same-origin (direct connection).
const url = new URL(a.href, window.location.href);
if (url.origin !== window.location.origin) return;
addRoute(url.pathname, a.textContent ?? undefined);