Skip to content

feat: add file preview for images and PDF#26

Merged
Zhang-Henry merged 2 commits intomainfrom
feat/chat-file-preview
Mar 13, 2026
Merged

feat: add file preview for images and PDF#26
Zhang-Henry merged 2 commits intomainfrom
feat/chat-file-preview

Conversation

@MarkSiqiZhang
Copy link
Copy Markdown
Collaborator

Summary

  • Extend CodeEditor to preview images (png, jpg, gif, webp, svg, bmp, ico) and PDF files using browser-native <img> and <iframe>
    elements
  • Show a fallback "cannot preview" message for unsupported binary formats (zip, docx, exe, pptx, pkl, etc.)
  • Fix relative path resolution in the /api/projects/:projectName/files/content endpoint so both absolute and relative file paths resolve
    correctly
  • Update all 3 i18n locales (en, zh-CN, ko) with new preview strings

Test plan

  • Open a .pdf file from chat → iframe preview
  • Open a .png / .jpg / .gif image → centered image preview
  • Open a .zip / .docx / .exe → "cannot preview" message (no download button)
  • Open a .js / .txt / .md file → code editor works as before
  • Verify settings, save, markdown preview buttons are hidden for binary/unsupported files
  • Download button in header still works for text and binary files

… beyond text-only viewing to support binary file

  preview using browser-native elements (img for images, iframe for
  PDF).
@Zhang-Henry Zhang-Henry merged commit 978b6e4 into main Mar 13, 2026
1 check passed
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.

2 participants