Skip to content

fix: set inline disposition for renderable blob elements#2950

Open
axelray-dev wants to merge 1 commit into
Chainlit:mainfrom
axelray-dev:fix-2946-inline-blob-disposition
Open

fix: set inline disposition for renderable blob elements#2950
axelray-dev wants to merge 1 commit into
Chainlit:mainfrom
axelray-dev:fix-2946-inline-blob-disposition

Conversation

@axelray-dev

@axelray-dev axelray-dev commented Jun 7, 2026

Copy link
Copy Markdown

Fixes #2946

Summary

SQLAlchemyDataLayer.create_element never passed content_disposition to storage_provider.upload_file. Azure Blob Storage defaults to Content-Disposition: attachment in this case, which causes browser-renderable elements (PDF, images, audio, video) to render blank on chat resume because iframes and media tags refuse to display content served with an attachment disposition.

This fix sets content_disposition='inline' for browser-renderable MIME types while preserving the existing behavior for non-renderable uploads.

Scope

Only browser-renderable MIME types are affected:

  • application/pdf
  • image/*
  • audio/*
  • video/*

All other element types (generic files, text/plain, application/octet-stream, etc.) keep content_disposition=None, preserving the existing download behavior.

Changes

  • backend/chainlit/data/sql_alchemy.py: determine content_disposition before upload_file call based on element.mime
  • backend/tests/data/test_sql_alchemy.py: 3 new tests verifying disposition behavior for PDF, image, and text/plain elements

Testing

Backend tests run locally:

  • tests/data/test_sql_alchemy.py: 18/18 passed (including 3 new tests)
  • tests/data/: 71/71 passed, 1 pre-existing error (test_get_data_layer fails without built frontend)
  • ruff check: all passed
  • ruff format --check: all passed
  • git diff --check: clean

Note: pre-commit hooks could not run locally (frontend build OOMs on VPS). CI will verify lint and format.

Backward Compatibility

This change is fully backward-compatible per AGENTS.md requirements:

  • Non-renderable element types are unaffected
  • The content_disposition parameter was already accepted by all storage clients but never used by SQLAlchemyDataLayer
  • The fix follows the same pattern used in chainlit_data_layer.py

Summary by cubic

Force inline Content-Disposition for renderable blob uploads so PDFs, images, audio, and video display correctly in iframes/media on chat resume. Leaves non-renderable files unchanged.

  • Bug Fixes
    • Pass content_disposition='inline' for application/pdf, image/*, audio/*, video/* in SQLAlchemyDataLayer.create_element.
    • Keep content_disposition=None for others (e.g., text/plain, application/octet-stream) to preserve download behavior.
    • Added tests for PDF inline, image inline, and text default cases.

Written for commit afe6d49. Summary will update on new commits.

Review in cubic

SQLAlchemyDataLayer.create_element never passed content_disposition to
storage_provider.upload_file, so Azure Blob Storage defaulted to
Content-Disposition: attachment. This caused PDF elements (and other
browser-renderable types) to render blank on chat resume because the
browser refused to display them in an iframe.

Set content_disposition='inline' for browser-renderable MIME types
(application/pdf, image/*, audio/*, video/*) while preserving the
existing behavior (None) for non-renderable uploads like generic files.

Fixes Chainlit#2946

Co-Authored-By: OpenAI Codex <[email protected]>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. backend Pertains to the Python backend. bug Something isn't working unit-tests Has unit tests. labels Jun 7, 2026

@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 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Pertains to the Python backend. bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cl.Pdf element blank on chat resume with Azure Blob storage — Content-Disposition: attachment

1 participant