Skip to content

Draw the first preview on a first visit: wait for the worker - #229

Merged
afflom merged 1 commit into
mainfrom
claude/project-thread-d27980
Nov 16, 2026
Merged

afflom merged 1 commit into
mainfrom
claude/project-thread-d27980

Conversation

@afflom

@afflom afflom commented Nov 16, 2026

Copy link
Copy Markdown
Member

What

After #228, the live site turns an idea into an app with no dialog and no server. On a first visit, though, the preview often stayed blank until the person pressed refresh. The preview frame loaded before the service worker was running. Only the worker serves /p/<kappa>/, so the frame got a 404.

  • The worker's registration is now kept in workerActive. liveFrame() waits for it, until the worker runs or its install fails.
  • When service workers are blocked, as in the suites that block them, register rejects and nothing waits.

Evidence

  • Live site before this change: the preview was blank on about half of the first visits. The frame read <html><head></head><body></body></html> and the page had no worker in control.
  • Local, with network latency added: without the change the preview was blank on 3 of 3 runs. With it, the app was drawn on 3 of 3 runs.
  • Browser suites: these pass: read_only, preview_permissions, preview_auto_start, live_main, stateful_application_journeys, durable_chat_queue, plain_chat_layout, instant_user_message, sidebar_tool_access, chat_model_picker_scope and covers.
  • Prism-only ratchet: non-Prism code lines are unchanged (+3/−3), and the comments added are free.

Generated by Claude Code

On a first visit the preview frame could load before the service worker
was running. The frame's address is served only by the worker, so it got
a 404 and stayed blank until the person pressed refresh. This was seen on
the live site about half the time, and it was reproduced locally with
network latency.

The worker's registration is now kept, and the live frame waits until the
worker runs or its install fails. When service workers are blocked, the
register call rejects and nothing waits. Under latency the preview drew
the app 3 times out of 3, where before it stayed blank 3 times out of 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3LdusN9UGDiUFDM7bZ
@afflom
afflom merged commit ab93f14 into main Nov 16, 2026
4 checks passed
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.

2 participants