Skip to content

Fix UI recovery false positives on slow loads#436

Open
ymichael wants to merge 3 commits into
mainfrom
bb/investigate-blank-ui-fallback-on-slow-network-thr_4n4sm3mfxq
Open

Fix UI recovery false positives on slow loads#436
ymichael wants to merge 3 commits into
mainfrom
bb/investigate-blank-ui-fallback-on-slow-network-thr_4n4sm3mfxq

Conversation

@ymichael

@ymichael ymichael commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Root cause:
The server injected the UI-source recovery watchdog into shipped/default index.html. On slow or stalled first loads, #root could stay empty long enough for the watchdog to show the UI-source recovery bar even when UI forking was disabled and no fork existed. For active UI forks, the old watchdog also auto-reverted after a fixed timeout, which could interrupt a slow-but-eventually-successful customized UI load.

Fix:
Keep the live-reload shim on all served HTML, but enable recovery behavior only when the server is actually serving an active UI fork dist. Active-fork recovery is now manual-only: slow loads, script load failures, runtime errors, or unhandled rejections before mount show the Revert to stable banner, but no timer calls /api/v1/ui/prod. If the custom UI eventually mounts, the banner is removed. Clicking Revert to stable still posts /api/v1/ui/prod and reloads.

Regression coverage added/confirmed:

  • Shipped/default UI gets the shim for live reload, but the recovery watchdog remains disabled and does not show the banner after timeout or script-error signals.
  • Active customized UI shows the recovery banner when it fails to mount.
  • Slow customized UI can keep loading; if #root eventually mounts, the banner disappears and no revert request is sent.
  • Clicking Revert to stable calls POST /api/v1/ui/prod and reloads.
  • Live reload on system ui-reloaded still reloads for both shipped/default HTML and active UI-source HTML.
  • Static serving still marks shipped HTML recovery disabled and active fork HTML recovery enabled.

Verification:

  • pnpm exec turbo run test --filter=@bb/server -- src/services/ui-source/ui-source.test.ts test/app/static-cache.test.ts
  • pnpm exec turbo run typecheck --filter=@bb/server
  • pnpm exec turbo run build --filter=@bb/server
  • Merge-tree conflict check against latest origin/main is clean.

@ymichael ymichael changed the title Fix UI recovery on shipped app loads Fix UI recovery false positives on slow loads Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant