Skip to content

fix(chat): download generated files without stale storage URLs - #7858

Merged
icecrasher321 merged 4 commits into
stagingfrom
codex/fix-deployed-chat-downloads
Sep 15, 2026
Merged

icecrasher321 merged 4 commits into
stagingfrom
codex/fix-deployed-chat-downloads

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Download inline generated files directly from their returned bytes, avoiding CSP-blocked data URL fetches and expired storage links.
  • Reuse the execution-log serve route for stored files, preserve safe external provider URLs, and show individual or bulk download failures without opening storage error pages.

Type of Change

  • Bug fix

Testing

192 focused tests, type-check, repository lint, and all 46 audits passed. Browser verification under restrictive CSP saved inline and served files with exact byte equality and kept denied files blocked. A real generated PNG downloaded byte-for-byte after its delivered signed URL expired. Regression coverage includes revoked and cross-workspace access, unauthenticated serving, arbitrary external provider IDs, unsafe URLs, bulk failure/retry, response-body cancellation, and safe browser navigation for CORS-restricted external downloads.

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)

@vercel

vercel Bot commented Sep 15, 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 Sep 15, 2026 8:58pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

Summary

Chat file downloads now use the file's actual bytes instead of stale or blocked URLs. Stored files go through the current serve route, while external links and bulk-download failures get safer fallback behavior.

  • Inline generated files are decoded locally instead of fetched as data URLs.
  • Stored files use the authorized serve route to get current bytes.
  • External downloads and bulk failures now show safer recovery options.

Diagram

sequenceDiagram
  actor User
  participant Chat as Chat download
  participant Serve as /api/files/serve
  participant External as External host
  participant Browser

  User->>Chat: Click download
  alt Inline base64 exists
    Chat->>Chat: Decode bytes and save blob
  else Recognized storage key
    Chat->>Serve: Fetch current file with inferred context
    alt Authorized response
      Serve-->>Chat: Current bytes
      Chat->>Chat: Save blob
    else 401 and safe delivered URL
      Chat->>External: Fetch delivered URL
      External-->>Chat: File bytes or CORS error
    else Denied or missing
      Serve-->>Chat: Error
      Chat-->>User: Show download error
    end
  else Safe external URL
    Chat->>External: Fetch file
    External-->>Chat: File bytes or CORS error
  else Unsafe or missing URL
    Chat-->>User: Show download error
  end
  opt External host blocks CORS
    Chat-->>User: Show direct download link
    User->>Browser: Open safe external URL
  end
Loading

Reviews (4) · Last reviewed commit: "chore(chat): annotate binary download fe..."

Comment thread apps/sim/app/(interfaces)/chat/components/message/components/file-download.tsx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

Also addressed the bulk-download finding: failed files are counted and shown in an inline alert, successful files continue downloading, and a successful retry clears the alert. Covered partial failure and retry in the component tests and exercised the actual component under the application CSP.

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 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.

All reported issues were addressed across 4 files

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

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/app/(interfaces)/chat/components/message/components/file-download.tsx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 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 4 files

Confidence score: 5/5

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

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit 585e8f7 into staging Sep 15, 2026
33 of 34 checks passed
@icecrasher321
icecrasher321 deleted the codex/fix-deployed-chat-downloads branch September 15, 2026 22:09
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