René's URL Explorer Experiment


Title: fix(files): read the Files prefetch from the data layer and bound invitation previews by waleedlatif1 · Pull Request #6415 · simstudioai/sim · GitHub

Open Graph Title: fix(files): read the Files prefetch from the data layer and bound invitation previews by waleedlatif1 · Pull Request #6415 · simstudioai/sim

X Title: fix(files): read the Files prefetch from the data layer and bound invitation previews by waleedlatif1 · Pull Request #6415 · simstudioai/sim

Description: Summary Two unrelated load-time fixes, 8 files. Files page (/workspace/[id]/files). On a hard refresh the folders painted first and the files a beat later. Both are prefetched and hydrated together, so the files entry was not reaching the client. Each read went to its own route over an internal HTTP request — prefetchQuery swallows a rejection and shouldDehydrateQuery drops the errored entry, so a failure there silently ships a page with that list missing, and the files read is the heavier of the two (it joins share rows on top of the file rows). Those two reads now call the data layer, which also removes a server→server request and its duplicate auth from the render path. Root cause is not confirmed. Staging logs show zero errors from WorkspaceFilesAPI over three days, so this removes the failure mode without proving it was the one firing. What the logs do show on the reported workspace is duplicate requests 13–42ms apart, consistent with the hydrated entry not being used — but those logs don't distinguish server-originated from browser-originated requests. The request dropped from the render path and the shape fix below stand on their own. Shape fix (real bug). listWorkspaceFilesWithShares is shared by the route and the prefetch and shapes its result through the route contract's response schema — the technique prefetchWorkspaceSidebar already documents. listWorkspaceFiles returns contentUpdatedAt, which workspaceFileRecordSchema neither declares nor passes through, so the prefetch was caching a field a client fetch never has and that vanished on the next refetch. Authorization. The reads carry none of their own now that they bypass the route, so the prefetch proves the viewer first. It reuses the layout's cache()d getWorkspaceHostContextForViewer rather than re-deriving the permission, so the gate costs no additional queries. No access → nothing cached → the client fetch reaches the route for the real 403. Invitations. GET /api/invitations computed join previews in a serial loop, and each preview issues up to three queries of its own — all on the critical path of the workspace switcher opening. Bounded with mapWithConcurrency. Same fetch, same trigger, same payload; the mapper was already total, which is what that helper requires. Deliberately not included: no conversion of the home/tables/knowledge/chrome prefetches, no lib/table refactor, no invitation prefetching. Those were explored and dropped — the tables conversion is blocked by check:tool-registry-boundary (lib/table/service transitively imports the executor), and prefetching invitations would have put these queries back on every workspace page render. Type of Change Bug fix Testing Tested manually. Three new tests, each verified to fail without its fix: the concurrency bound (set limit to 1 → red), the contract strip (remove the parse → red), and the prefetch auth gate (remove the guard → red). Deleted a test I had written that couldn't fail — it pinned prefetchQuery's swallow behaviour rather than anything in this diff, and passed against origin/staging unchanged. Updated the existing prefetch.test.ts rather than letting it rot, including its graceful-failure case, which was asserting against a fetcher the Files prefetch no longer uses and would have passed vacuously. bun run check:audits, type-check, lint all pass. Pre-existing and unrelated: check:realtime-prune, check:native-typecheck and check:desktop-bridge fail in a worktree with no local node_modules — verified identical on clean origin/staging. Not browser-verified. Worth one hard refresh of /files with the network tab open before merge: if /api/workspaces//files still fires as an XHR after load, the hydration issue is something other than what this fixes. 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 Two unrelated load-time fixes, 8 files. Files page (/workspace/[id]/files). On a hard refresh the folders painted first and the files a beat later. Both are prefetched and hydrated together...

X Description: Summary Two unrelated load-time fixes, 8 files. Files page (/workspace/[id]/files). On a hard refresh the folders painted first and the files a beat later. Both are prefetched and hydrated together...

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

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:e8802300-45af-e67d-fff0-cf5c4fb68f8e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA924:11E6AB:250522:34C10A:6AFB5284
html-safe-nonce551ba5a8b795c32dd632c0b8a70164f1d7f302723dd487b293a691a83e1e497c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTI0OjExRTZBQjoyNTA1MjI6MzRDMTBBOjZBRkI1Mjg0IiwidmlzaXRvcl9pZCI6IjMwODA4NDA5NTQ0NDE4NDc0MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac04cc5e1a7f386ee71cd47a23ea9c0b405d073bcffe95801a60e2caffc29eaf33
hovercard-subject-tagpull_request:4235491202
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/6415/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 Two unrelated load-time fixes, 8 files. Files page (/workspace/[id]/files). On a hard refresh the folders painted first and the files a beat later. Both are prefetched and hydrated together...
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/6415/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6415%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%2F6415%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/6415/files
Reloadhttps://github.com/simstudioai/sim/pull/6415/files
Reloadhttps://github.com/simstudioai/sim/pull/6415/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-prefetch-and-invitation-previewshttps://github.com/simstudioai/sim/tree/fix/files-prefetch-and-invitation-previews
Conversation 3 https://github.com/simstudioai/sim/pull/6415
Commits 1 https://github.com/simstudioai/sim/pull/6415/commits
Checks 30 https://github.com/simstudioai/sim/pull/6415/checks
Files changed https://github.com/simstudioai/sim/pull/6415/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6415/files
fix(files): read the Files prefetch from the data layer and bound invitation previews https://github.com/simstudioai/sim/pull/6415/files#top
Show all changes 1 commit https://github.com/simstudioai/sim/pull/6415/files
c6b1ba3 fix(files): read the Files prefetch from the data layer and bound inv… waleedlatif1 Aug 8, 2026 https://github.com/simstudioai/sim/pull/6415/commits/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e
Clear filters https://github.com/simstudioai/sim/pull/6415/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6415/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6415/files
route.test.ts https://github.com/simstudioai/sim/pull/6415/files#diff-c23c58bfc98069fa9de211de0adc3712e6f8f6e68862d8a7964d43a93d9835c5
route.ts https://github.com/simstudioai/sim/pull/6415/files#diff-addcd5d9655163f3e15e1a9d8e9f92f10d49f2eb63c503b6daef575c7eefc9ad
route.ts https://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
page.tsx https://github.com/simstudioai/sim/pull/6415/files#diff-97c3b677845a0ad20c4f5dde16df3dfc37fa7f2ea75305b700721ee6a3e6f5f1
prefetch.ts https://github.com/simstudioai/sim/pull/6415/files#diff-f595ec6ab8c5f6f515485fd5eae3af465efa5a440d278114109318a589a90346
prefetch-internal-fetch.ts https://github.com/simstudioai/sim/pull/6415/files#diff-0ce6bb08c1bf44ebffd54119f9121c2b7f1b2a92a18bc85de566f7205b9c1ea8
prefetch.test.ts https://github.com/simstudioai/sim/pull/6415/files#diff-0f96fdbc0043b9049bd7b95533743eec99f8fae0184fd3464b17ed4f5c19e1d5
queries.test.ts https://github.com/simstudioai/sim/pull/6415/files#diff-cc2e30cc112ef68af10ae8919b83f2ceeab92c62f831c017dd1af1572087f57d
queries.ts https://github.com/simstudioai/sim/pull/6415/files#diff-b9449dedfdaeab35cba403bbbffde318c75822f166d7ce8f60a68c0183443582
apps/sim/app/api/invitations/route.test.tshttps://github.com/simstudioai/sim/pull/6415/files#diff-c23c58bfc98069fa9de211de0adc3712e6f8f6e68862d8a7964d43a93d9835c5
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/api/invitations/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
apps/sim/app/api/invitations/route.tshttps://github.com/simstudioai/sim/pull/6415/files#diff-addcd5d9655163f3e15e1a9d8e9f92f10d49f2eb63c503b6daef575c7eefc9ad
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/api/invitations/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6415/files#diff-addcd5d9655163f3e15e1a9d8e9f92f10d49f2eb63c503b6daef575c7eefc9ad
https://github.com/simstudioai/sim/pull/6415/files#diff-addcd5d9655163f3e15e1a9d8e9f92f10d49f2eb63c503b6daef575c7eefc9ad
https://github.com/simstudioai/sim/pull/6415/files#diff-addcd5d9655163f3e15e1a9d8e9f92f10d49f2eb63c503b6daef575c7eefc9ad
apps/sim/app/api/workspaces/[id]/files/route.tshttps://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/api/workspaces/%5Bid%5D/files/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
https://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
https://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
https://github.com/simstudioai/sim/pull/6415/files#diff-ffd1644c9109b4913147a4bd6d6c620ed49c7c38cb0c8cfddf4c9f2c5fe55867
apps/sim/app/workspace/[workspaceId]/files/page.tsxhttps://github.com/simstudioai/sim/pull/6415/files#diff-97c3b677845a0ad20c4f5dde16df3dfc37fa7f2ea75305b700721ee6a3e6f5f1
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/workspace/%5BworkspaceId%5D/files/page.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6415/files#diff-97c3b677845a0ad20c4f5dde16df3dfc37fa7f2ea75305b700721ee6a3e6f5f1
https://github.com/simstudioai/sim/pull/6415/files#diff-97c3b677845a0ad20c4f5dde16df3dfc37fa7f2ea75305b700721ee6a3e6f5f1
apps/sim/app/workspace/[workspaceId]/files/prefetch.tshttps://github.com/simstudioai/sim/pull/6415/files#diff-f595ec6ab8c5f6f515485fd5eae3af465efa5a440d278114109318a589a90346
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/workspace/%5BworkspaceId%5D/files/prefetch.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6415/files#diff-f595ec6ab8c5f6f515485fd5eae3af465efa5a440d278114109318a589a90346
https://github.com/simstudioai/sim/pull/6415/files#diff-f595ec6ab8c5f6f515485fd5eae3af465efa5a440d278114109318a589a90346
apps/sim/app/workspace/[workspaceId]/lib/prefetch-internal-fetch.tshttps://github.com/simstudioai/sim/pull/6415/files#diff-0ce6bb08c1bf44ebffd54119f9121c2b7f1b2a92a18bc85de566f7205b9c1ea8
View file https://github.com/simstudioai/sim/blob/c6b1ba35ba91b8fd8e5ada3f7fdc996e6471602e/apps/sim/app/workspace/%5BworkspaceId%5D/lib/prefetch-internal-fetch.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6415/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6415/files#diff-0ce6bb08c1bf44ebffd54119f9121c2b7f1b2a92a18bc85de566f7205b9c1ea8
https://github.com/simstudioai/sim/pull/6415/files#diff-0ce6bb08c1bf44ebffd54119f9121c2b7f1b2a92a18bc85de566f7205b9c1ea8
Please reload this pagehttps://github.com/simstudioai/sim/pull/6415/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6415/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.