Files
sim/apps
Waleed 8a224be397 fix(files): read the Files prefetch from the data layer and bound invitation previews (#6415)
Two unrelated load-time fixes.

On a hard refresh of /files 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 shipped a page with that list
missing, and the files read is the heavier of the two. Those two reads now call
the data layer. Note the staging logs show no errors from that route, so this
removes the failure mode without proving it was the one firing — the request it
drops from the render path, and the shape fix below, stand on their own.

listWorkspaceFilesWithShares is shared by the route and the prefetch and shapes
its result through the route contract's response schema. listWorkspaceFiles
returns contentUpdatedAt, which the schema neither declares nor passes through,
so the prefetch was caching a field a client fetch never has and that vanished
on the next refetch.

The reads carry no authorization of their own now that they bypass the route,
so the prefetch proves the viewer first. It reuses the layout's cached
host-context lookup rather than re-deriving the permission, so the gate costs no
extra queries.

Separately, GET /api/invitations computed join previews in a serial loop and
each preview issues up to three queries of its own, putting all of them on the
critical path of the workspace switcher opening. Bounded with
mapWithConcurrency; the mapper was already total, which is what that helper
requires.
2026-08-08 11:10:49 -07:00
..