Skip to content

fix(files): share one served-bytes predicate between the serve route and large downloads - #9548

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/served-bytes-predicate
Nov 1, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/served-bytes-predicate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The file-serve route and the client's large-download hand-off decided separately which files are served byte-for-byte from storage, and they disagreed on Sim pages: the route renders .html / text/x-sim-page files (buffered), while the client treated them as streamable and handed large ones to the browser's download manager after its probe
  • Add one predicate, servesStoredBytes(contentType, fileName) (not a page, not needsRenderedArtifact), and route both the serve route's servesStoredObject gate and triggerFileDownload through it, so the two can't drift — a page or generated document now always uses the in-page fetch path, where a render/compile rejection surfaces as an error
  • Move SIM_PAGE_CONTENT_TYPE into a dependency-free page-content-type module so client code can recognize a page without loading the page compiler (js-yaml, marked, schemas built at import); its importers now read it from there
  • Document the caller-admission contract on streamAuthorizedWorkspaceFile

Type of Change

  • Bug fix

Testing

  • lib/uploads/client/download.test.ts: large text/x-sim-page and .html records stay on the in-page fetch path (both red on staging before the fix)
  • Ran the download, serve route, stream helper, file-manager page and public-shares suites locally (green); check:api-validation:strict, check:comment-hygiene, check:source-conventions, check:client-boundary, check:test-patterns, check:file-names, check:boundaries, check:utils, block registry check, lint
  • Full bun run test, check:audits and type-check left to CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 1, 2026 6:18am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Shares servesStoredBytes between the serve route and large downloads so pages and generated documents stay on the in-page fetch path.

  • The route and large downloads agree on which files need rendering.
  • Page type checks no longer load the page compiler.
  • The stream helper states what callers must check first.

No new actionable issues were found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[File type and name] --> B[servesStoredBytes]
  B -->|Stored bytes| C[Route streams from storage]
  B -->|Stored bytes and large file| D[Client probes then starts browser download]
  B -->|Page or generated document| E[Route buffers and renders]
  B -->|Page or generated document| F[Client fetches and shows errors in place]
Loading

Reviews (2) · Last reviewed commit: "fix(files): judge an attachment's docume..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 20 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…tate the stream helper's caller precondition
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 21 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit ac604b7 into staging Nov 1, 2026
70 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/served-bytes-predicate branch November 1, 2026 07:14

This branch was previously deployed

1 inactive deployment
Preview — 1e349fa9 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant