improvement(files): cache stream binding meta, tighten file cache-control, prune dead persist path - #6149
Conversation
…trol, prune dead persist path - Cache the agent-stream ProseMirror↔Yjs binding metadata per session and reuse it across streamed frames instead of rebuilding it (O(doc)) every frame; matches how y-tiptap's own binding maintains the mapping in place. Safe because the shadow doc only ever sees the agent's own reconciles. - Default createFileResponse to a private, no-cache policy so auth-gated bytes are never stored in a shared cache; genuinely-public serve routes opt into public caching explicitly. - Serve content-addressed (key=) embedded images with an immutable private cache to avoid re-downloading them on every doc re-open; fileId= embeds and public shares keep revalidating (the underlying key can change / a share can be revoked). - Drop the dead conflict.version field from the collab-doc persist result and remove the wasted getWorkspaceFile re-read on the conflict path (the relay treats missing and conflict identically and never read version). - Decorate-sort the files/folders lists (compute each sort key once) and index the move-menu subtree build (O(N) vs O(N^2)); ordering is preserved exactly.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Speeds agent markdown streaming by caching ProseMirror↔Yjs Aligns collab-doc persist on conflict: the UI list performance in Reviewed by Cursor Bugbot for commit 04e8424. Configure here. |
Greptile SummaryThis PR improves file-serving safety and performance while simplifying collaborative persistence.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the inline-image cache bypass is fixed, and the removed conflict metadata was not consumed by the relay.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/files/serve-inline-image.ts | Applies a single private, revalidating policy to authenticated inline images, fully addressing the prior stale-cache bypass. |
| apps/sim/app/api/files/utils.ts | Changes the generic file-response default from public caching to private revalidation while retaining explicit overrides. |
| apps/sim/app/api/files/serve/[...path]/route.ts | Explicitly opts genuinely public assets into shared caching after the generic response default became private. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/collaboration/apply-streamed-markdown.ts | Caches binding metadata within each isolated agent stream session and reuses it across frames. |
| apps/sim/app/workspace/[workspaceId]/files/files.tsx | Precomputes sort keys and indexes folder children without changing established ordering behavior. |
| apps/sim/lib/collab-doc/persist.ts | Removes an unconsumed conflict-version reread while preserving the relay’s existing conflict behavior. |
| apps/sim/lib/api/contracts/file-doc.ts | Aligns the persistence response contract with the status-only conflict result consumed by realtime. |
| apps/realtime/src/handlers/file-doc-app.ts | Aligns the realtime client type and documentation with the status-only conflict response. |
Reviews (3): Last reviewed commit: "fix(files): serve inline images with no-..." | Re-trigger Greptile
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit dde9ff5. Configure here.
…on is enforced per request Embedded images are authenticated content whose backing file can be deleted or have its access revoked at any time. Both key= and fileId= embeds serve private, no-cache, must-revalidate, so every request re-runs the server-side deletion/authorization check instead of serving a possibly-stale image from cache.
dde9ff5 to
04e8424
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 04e8424. Configure here.
Summary
createFileResponsetoprivate, no-cacheso auth-gated bytes are never stored in a shared cache; genuinely-public serve routes opt into public caching explicitly.key=) embedded images with an immutable private cache to avoid re-downloading them on every doc re-open;fileId=embeds and public shares keep revalidating (the key can change / a share can be revoked).conflict.versionfield from the collab-doc persist result and remove the wastedgetWorkspaceFilere-read on the conflict path (the relay treatsmissingandconflictidentically and never readversion).Type of Change
Testing
key=→immutable vsfileId=→revalidate inline headers, and cross-frame meta reuse with no paragraph duplication.Checklist