feat(slice-machine): resize screenshot previews via Imgix params (display only) - #1776
Closed
claude[bot] wants to merge 1 commit into
Closed
feat(slice-machine): resize screenshot previews via Imgix params (display only)#1776claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Author
|
Closing as superseded. This change was implemented in the wrong repository — the Type Builder editor screenshot rendering lives in Generated by Claude Code |
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.
Requested via Slack thread
Before / After
Slice screenshots are uploaded at full resolution and served through Imgix. Until now the editor loaded those full-resolution images everywhere they were displayed — a slice library with ~60 slices pulled roughly 77MB of images.
After this change, the editor requests Imgix-resized, format-optimized (WebP/AVIF) variants for display only:
w=600w=1200This cuts editor bandwidth substantially, and Imgix caches the generated variants.
What stays the same
The stored screenshot URL and the model's
variation.imageUrl(built inScreenshotsManager.uploadScreenshotand set inSlicesManager) are untouched and remain full-resolution, so the CLI and Type Builder still receive the maximum-resolution image. This change only affects the URL as rendered in the editor, never what is persisted.How
New display-only helper
addImgixDisplayParams(rawUrl, { width })inpackages/slice-machine/src/domain/imgix.ts:auto=format,compress,fit=max, andw=<width>on the URL.fit=maxpreserves aspect ratio and never upscales, so screenshots smaller than the target width are served untouched and larger ones are downscaled. Nohis set.URLSearchParams.setcleanly overrides any pre-existingautoparam.imgixEndpoint, so no fixed host can be pinned). The helper only rewrites URLs that parse ashttp(s)and whose hostname containsimgix. Everything else —blob:object URLs used for locally-read screenshots,data:URLs, relative paths, unparseable strings, and non-Imgix hosts — is returned unchanged. This keeps local previews working exactly as before.Applied at the four editor render sites that display a screenshot:
features/slices/sliceCards/SharedSliceCard.tsx— slice library / slice-zone card thumbnail (w=600)legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx(getFirstVariationScreenshot) — import-from-library thumbnail (w=600)legacy/components/Simulator/index.tsx— large screenshot preview modal (w=1200)legacy/components/ScreenshotChangesModal/VariationDropZone.tsx— screenshot preview (w=1200)The generic accessor
getScreenshotUrlis left as a pure accessor; the display helper is applied per render site so comparison/model logic is unaffected.Tests:
packages/slice-machine/src/domain/__tests__/imgix.test.tscovers param application,autooverride, and the pass-through cases (blob:,data:, relative/garbage, non-Imgix host,undefined).Ref: Linear DT-3473.