Repository navigation
perf(artifacts): mount the shell frame with the detail route so the shell downloads once, before the row arrives - #30
Merged
Conversation
…hell downloads once, before the row arrives The artifact page used to add a prefetch hint for the shell document and then mount the frame after the row loaded, which made two downloads of the largest asset. The frame now mounts as soon as the route renders, boots while the row is fetched, and receives the source over the existing bridge. A failed row replaces the stage with the error state, so no booted frame stays behind. Adds a scenario that asserts one shell request on a cold cache, started before the row response completes. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On a cold cache the artifact page downloaded the shell document twice. The
<link rel="prefetch">added when the renderer chunk resolved was still in flight when the iframe mounted, after the artifact row arrived. Chrome does not merge an in-flight prefetch with a later iframe navigation, so the frame started its own request.In a Playwright run against a local server, a COMPLETED top-frame prefetch was reused by the iframe. The in-flight case is what doubled the request. In prod the shell is 664 KB gzip, so the prefetch is likely still running when the row arrives.
What changes
ArtifactStagemounts with the detail route, before the row resolves. The renderer takescode: string | null, wherenullmeans the row is still loading. The shell iframe starts downloading right away, and the source is delivered through the existing bridge once both the bridge is initialized and the row has arrived, exactly once per frame.ErrorState, so no booted frame is left visible. The single loading cover and therenderedsignal are unchanged.shellHtmlUrlplumbing are gone.Tests
artifact-shell-single-download: fresh browser context, the row delayed by 1.5 s, every shell request counted. It asserts one request, started before the row finishes.artifact-loading-surface,artifactsandartifact-source-roundtrippass.https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S