René's URL Explorer Experiment


Title: fix(files): reserve image layout space so images stop reflowing on load by waleedlatif1 · Pull Request #6299 · simstudioai/sim · GitHub

Open Graph Title: fix(files): reserve image layout space so images stop reflowing on load by waleedlatif1 · Pull Request #6299 · simstudioai/sim

X Title: fix(files): reserve image layout space so images stop reflowing on load by waleedlatif1 · Pull Request #6299 · simstudioai/sim

Description: Summary A markdown image with no stored dimensions reserved zero vertical space until it downloaded, then snapped to its natural height and pushed everything below it down (cumulative layout shift). This reserves the box up front from the image's intrinsic aspect ratio. Dimensions are stored as workspace_file metadata (not in the markdown — it stays clean ![](src)), read synchronously from the already-loaded file list to reserve a responsive aspect-ratio box on the first render, and lazily backfilled once per image on first view via a write-gated, idempotent PATCH. The node view falls back to on-load measurement for the very first view and for external ![](url) images. Images stay fluid (max-width:100%, height:auto). How it works DB: nullable width/height on workspace_files (migration 0282). Server: mapper carries the columns; updateWorkspaceFileDimensions is idempotent (WHERE width IS NULL) and never bumps updatedAt (so it can't cache-bust the served image); PATCH …/[fileId]/dimensions is write-gated. Client: the dimension capability lives on the FileContentSource seam (only the workspace source implements it); the adapter reads/patches the file-list cache; image.tsx reserves the box (memoized so a resize drag never re-scans the list) and measures + persists on load. Notes Only remaining reflow is an image's very first-ever view — dimensions can't be known before the first load; every later view (incl. hard refresh) is reflow-free. Markdown is never touched. Type of Change Bug fix Testing Route test (auth / permission / validation) and a pure resolver unit test (src → record). Typecheck, api-validation (+strict), react-query, client-boundary all green. Ran /simplify + /cleanup over the diff. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary A markdown image with no stored dimensions reserved zero vertical space until it downloaded, then snapped to its natural height and pushed everything below it down (cumulative layout shift...

X Description: Summary A markdown image with no stored dimensions reserved zero vertical space until it downloaded, then snapped to its natural height and pushed everything below it down (cumulative layout shift...

Opengraph URL: https://github.com/simstudioai/sim/pull/6299

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8c84d014-37f8-8eb4-afd6-91893b81a8af
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD784:243FA5:AB6FA9:EB7F09:6AFB50BC
html-safe-nonce2041644135b253412215c8135fb0713913d5e5423af8c6558a8f739fd5c20366
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzg0OjI0M0ZBNTpBQjZGQTk6RUI3RjA5OjZBRkI1MEJDIiwidmlzaXRvcl9pZCI6IjYyMTE1NDc3NDAxMTU3ODM4NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccb892c871b7b62355dfe58b1d3c6e346fef42666e04a137d8b45f142b99e6540
hovercard-subject-tagpull_request:4216510920
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6299/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary A markdown image with no stored dimensions reserved zero vertical space until it downloaded, then snapped to its natural height and pushed everything below it down (cumulative layout shift...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6299/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6299%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6299%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6299/files
Reloadhttps://github.com/simstudioai/sim/pull/6299/files
Reloadhttps://github.com/simstudioai/sim/pull/6299/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/files-image-layout-shifthttps://github.com/simstudioai/sim/tree/fix/files-image-layout-shift
Conversation 54 https://github.com/simstudioai/sim/pull/6299
Commits 10 https://github.com/simstudioai/sim/pull/6299/commits
Checks 30 https://github.com/simstudioai/sim/pull/6299/checks
Files changed https://github.com/simstudioai/sim/pull/6299/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
fix(files): reserve image layout space so images stop reflowing on load https://github.com/simstudioai/sim/pull/6299/files#top
Show all changes 10 commits https://github.com/simstudioai/sim/pull/6299/files
ba2bf7a fix(files): reserve image layout space so images stop reflowing on load waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/ba2bf7a8c1ed7780c80f74a657a608146485f244
1c026d5 fix(files): address review — reserve on stale memo, clear dims on con… waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/1c026d5ba777d297e52794ae1c03d2b36d5619d7
770c1f5 fix(files): re-derive image dimensions on content swap instead of cle… waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/770c1f56ac7bff307c2ddb1932bd498d1732c15c
17499b1 fix(files): self-heal image dimensions from the browser instead of se… waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/17499b1115e1b1b6824dcdddbbadc011fa1384b2
ba8507c fix(files): clear image dimensions on content swap (completes self-heal) waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/ba8507c5989b3d06c03b23baa674a707937d9808
cd1b2be fix(files): guard dimension writes by content key so a stale PATCH ca… waleedlatif1 Aug 5, 2026 https://github.com/simstudioai/sim/pull/6299/commits/cd1b2bec88170cc25ce6031e078e000bdb42f3d0
94348f0 chore(files): fix stale route TSDoc and hoist a regex literal (cleanu… waleedlatif1 Aug 6, 2026 https://github.com/simstudioai/sim/pull/6299/commits/94348f0d904fb032ded58cca5f8b9135cc360a9a
497b223 fix(files): reflect the content-version guard outcome in the dimensio… waleedlatif1 Aug 6, 2026 https://github.com/simstudioai/sim/pull/6299/commits/497b2237437bdc7c4962bb8dcfb837338d7c33ad
4cabb83 fix(files): reconcile the cache when a dimension write is content-ver… waleedlatif1 Aug 6, 2026 https://github.com/simstudioai/sim/pull/6299/commits/4cabb8362d102e4fa91791bc4a5ab842f79542ba
d2b1195 docs(files): align stale dimension docs with the overwrite/self-heal … waleedlatif1 Aug 6, 2026 https://github.com/simstudioai/sim/pull/6299/commits/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072
Clear filters https://github.com/simstudioai/sim/pull/6299/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
route.test.ts https://github.com/simstudioai/sim/pull/6299/files#diff-2d0534a12a94436b022f899fda284cc5653d9add6bbb13bdcc095e9af6e88bf9
route.ts https://github.com/simstudioai/sim/pull/6299/files#diff-e176c195ca70b1178e449dc27f460143e670adad1f93bd8d1fd558d3d0fb776e
file-viewer.tsx https://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
image.tsx https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
find-workspace-file-by-src.test.ts https://github.com/simstudioai/sim/pull/6299/files#diff-93afeb2ce133b2aa9764e3428cba362d96ea4b5274f4e1fcd25505da9a1fac26
find-workspace-file-by-src.ts https://github.com/simstudioai/sim/pull/6299/files#diff-016be0ac9d7a6af2ff2940d06ffe5e4cc364269299ebad89a68206c81b621563
workspace-files.ts https://github.com/simstudioai/sim/pull/6299/files#diff-29d9b6d312177176db7c67d2754eb013b3ee7dc842dbbdb481bed86f551d4f37
use-file-content-source.tsx https://github.com/simstudioai/sim/pull/6299/files#diff-90976156a39bdd21612371dd8e08cf7a466bbf188c03cc869cf3aaf9cf1ad73a
workspace-files.ts https://github.com/simstudioai/sim/pull/6299/files#diff-05f84543b5a8f478260ff33a6503250494619411c41c9f43523e352d8fe8bc37
workspace-file-manager.ts https://github.com/simstudioai/sim/pull/6299/files#diff-fcf305d0b37403347596bca42fc6889e9038c9f8e2c69ba20676c0f0d8fead34
0282_chubby_psylocke.sql https://github.com/simstudioai/sim/pull/6299/files#diff-bd8a8596b37b14f4089ad3fd93797302cd5c72afd6b097e91342e22206ee328e
0282_snapshot.json https://github.com/simstudioai/sim/pull/6299/files#diff-8e0461433e3216e843ba4e43f0ca6e316158c0b2cb72d10065dbb8096d5c25fd
_journal.json https://github.com/simstudioai/sim/pull/6299/files#diff-37150cc65ad16ee6fbc5fa318fc096be7730e16d63eaf863e3df5521b7030649
schema.ts https://github.com/simstudioai/sim/pull/6299/files#diff-9a959e2ce3cb4c86957bbae021d06eae364f7b0cb18964f5873bab53220af928
apps/sim/app/api/workspaces/[id]/files/[fileId]/dimensions/route.test.tshttps://github.com/simstudioai/sim/pull/6299/files#diff-2d0534a12a94436b022f899fda284cc5653d9add6bbb13bdcc095e9af6e88bf9
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/app/api/workspaces/%5Bid%5D/files/%5BfileId%5D/dimensions/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
apps/sim/app/api/workspaces/[id]/files/[fileId]/dimensions/route.tshttps://github.com/simstudioai/sim/pull/6299/files#diff-e176c195ca70b1178e449dc27f460143e670adad1f93bd8d1fd558d3d0fb776e
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/app/api/workspaces/%5Bid%5D/files/%5BfileId%5D/dimensions/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsxhttps://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/app/workspace/%5BworkspaceId%5D/files/components/file-viewer/file-viewer.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
https://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
https://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
https://github.com/simstudioai/sim/pull/6299/files#diff-41f31a97adfda85382418ff71f00df02005b2d85b01516c49967857a1ee0b948
...m/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image.tsxhttps://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/app/workspace/%5BworkspaceId%5D/files/components/file-viewer/rich-markdown-editor/image.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
https://github.com/simstudioai/sim/pull/6299/files#diff-9371bbb9b8daf622c8ef475c01a9b90285d3a07d6ebd0f633ff66a2c62492496
apps/sim/hooks/queries/utils/find-workspace-file-by-src.test.tshttps://github.com/simstudioai/sim/pull/6299/files#diff-93afeb2ce133b2aa9764e3428cba362d96ea4b5274f4e1fcd25505da9a1fac26
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/hooks/queries/utils/find-workspace-file-by-src.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
apps/sim/hooks/queries/utils/find-workspace-file-by-src.tshttps://github.com/simstudioai/sim/pull/6299/files#diff-016be0ac9d7a6af2ff2940d06ffe5e4cc364269299ebad89a68206c81b621563
View file https://github.com/simstudioai/sim/blob/d2b1195daedd1d6e8f1188cb46d2d2f11b1bf072/apps/sim/hooks/queries/utils/find-workspace-file-by-src.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6299/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6299/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.