perf(anonymize): show the README preview without waiting on the branch list

The preview rendered only after repo details, the full branch list and the
README loaded one after another. The early README fetch was usually
discarded and fetched again, the README endpoint listed every branch from
GitHub first, and preview calls were slowed down after 50 API requests.

Render as soon as the README and details are in, keep a default-branch
README once that branch is selected, skip identical preview requests,
fetch the README by branch name on a cache miss, and drop the slowdown on
the CPU-only preview endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Thomas DurieuxandClaude Opus 5.5 committed 2026-11-29 14:31:37 +00:00
1 parent 31a4eb015f
commit d161d89cee
5 files changed
+136 -100

No files matched your search

+4 -1
View File
@@ -270,7 +270,10 @@ export default async function start() {
apiRouter.use("/pr", speedLimiter, router.pullRequestPrivate);
apiRouter.use("/gist", speedLimiter, router.gistPublic);
apiRouter.use("/gist", speedLimiter, router.gistPrivate);
apiRouter.use("/anonymize-preview", speedLimiter, router.anonymizePreview);
// The form previews on every edit, and slowing it down after 50 calls made
// typing feel broken. It only runs the anonymizer on posted text, never
// GitHub, so the shared API rate limit is enough.
apiRouter.use("/anonymize-preview", router.anonymizePreview);
// Cache message.txt presence so /api/message doesn't hit the filesystem
// synchronously on every request. Re-checked on a 60s interval — the file