fix(presentation): pass absolute URLs through getPreviewThumbnail - #11014
Open
clayrisser wants to merge 1 commit into
Open
fix(presentation): pass absolute URLs through getPreviewThumbnail#11014clayrisser wants to merge 1 commit into
clayrisser wants to merge 1 commit into
Conversation
getFileUrl (file.ts:55) returns absolute-URL blob refs unchanged and blobToSrcSet (preview.ts:52) recognises them too, but getPreviewThumbnail had no '://' guard and percent-encoded the whole URL into the preview service's path, producing a thumbnail URL for nothing. Add the passthrough, getFileUrl's analog, since a thumbnail needs a usable src. Tests: five cases in packages/presentation/src/___tests___/preview.test.ts, three of which fail with the guard removed. Note they do not run yet -- the package has no test phase script; see the companion build change. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Clay Risser <clayrisser@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
clayrisser
force-pushed
the
fix/preview-thumbnail-absolute-url
branch
from
August 13, 2026 06:47
d24bc40 to
c78fe58
Compare
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.
Problem
packages/presentationhas three functions that turn a blob ref into a URL, and they disagree about what to do when the ref is already an absolute URL.getFileUrl(file.ts:55) passes it through:blobToSrcSet(preview.ts:52) also recognises it, and returns''— correctly, because there is no srcset to build for an external URL.getPreviewThumbnail(preview.ts:92) has no guard at all:So an absolute URL is percent-encoded and pasted into the preview service's path, producing something like:
which is not a thumbnail of anything.
Fix
Add the passthrough, matching
getFileUrl— a thumbnail needs a usablesrc, so passthrough rather thanblobToSrcSet's empty string is the right analogue:export function getPreviewThumbnail (file: string, width: number, height: number, dpr?: number): string { + // Absolute URLs pass through unchanged, same as getFileUrl (blobToSrcSet + // guards on '://' too but returns '' — a thumbnail src wants the passthrough) + if (file.includes('://')) { + return file + } + return getImagePreviewUrl(Verification
Five cases in
packages/presentation/src/___tests___/preview.test.ts, alongside the four suites already in that directory:getPreviewThumbnailagrees withgetSrcSetabout what counts as an absolute refThe last one is the point of the change rather than a restatement of it: the three functions disagreeing is the actual defect, and that case pins them together. Three of the five fail with the guard removed.
packages/presentationhasjest.config.js, the jest devDependencies, and four existing suites, but notest/_phase:testscript — andrush's phases are declaredignoreMissingScript: true, so the whole package is skipped silently. I have opened that separately as a one-line-per-package build change. Either land that first, or fold those two lines into this PR — happy either way, just say which you prefer.Verified against
develop@1be6047c8:getFileUrl's guard atfile.ts:55andblobToSrcSet's atpreview.ts:52are both still there,getPreviewThumbnailat:92still has none.Note on scope
This was originally prepared together with three unrelated error-handling fixes on the same read path (a
TextViewerfetch with notry/catch, anImageViewer<img>with noon:error, and an embed nodeview promise with no.catch). I have split those into a separate PR, since they are a different concern and mixing them would make both harder to review.