Skip to content

feat(ui): Add download transcript feature for chat sessions#511

Merged
param20h merged 1 commit into
param20h:devfrom
nancysangani:feat/chat-transcript-download
Jun 7, 2026
Merged

feat(ui): Add download transcript feature for chat sessions#511
param20h merged 1 commit into
param20h:devfrom
nancysangani:feat/chat-transcript-download

Conversation

@nancysangani
Copy link
Copy Markdown
Contributor

🔗 Related Issue

Closes #426


📝 What does this PR do?

Creates backend/app/routes/chat_export.py — the missing module already
imported by the /chat/export/{document_id}?format=pdf route in chat.py.

The frontend export UI (Download button, MD/TXT/PDF dropdown in ChatPanel.tsx)
and the backend export endpoint (GET /chat/export/{document_id}) were already
fully implemented. The only missing piece was format_pdf() which the endpoint
imports from app.routes.chat_export.

backend/app/routes/chat_export.py (new):

  • format_pdf(doc, messages) — renders chat history as a clean A4 PDF using
    ReportLab (already in requirements.txt).
  • Cover block: document name, export timestamp, message count, indigo rule.
  • Per-message blocks: colour-coded role label (indigo = user, emerald =
    assistant), timestamp, body text with XML escaping and soft line-wrapping,
    source citations with filename / page / confidence / 120-char preview.
  • Horizontal dividers between messages for readability.
  • _safe_text() escapes &, <, >, " so ReportLab Paragraph never
    crashes on user-generated content.
  • _wrap_body() soft-wraps long lines at 100 chars and converts \n to
    <br/> so multi-paragraph answers render correctly.

No changes to chat.py, ChatPanel.tsx, or any other existing file.


🗂️ Type of Change

  • ✨ New feature

🧪 How was this tested?

  • Ran the backend locally (uvicorn app.main:app --reload)
  • Uploaded a document, had a multi-turn conversation, clicked Export → PDF
    — file downloaded and opened correctly in a PDF viewer
  • Verified cover block shows correct document name, timestamp, and message
    count
  • Verified user and assistant turns are colour-coded correctly
  • Verified source citations render with filename, page, confidence, and
    preview text
  • Verified messages containing &, <, > and multi-line content render
    without crashing
  • Confirmed MD and TXT export paths are unaffected (no regression)

✅ Self-Review Checklist

  • My branch is based on dev, not main
  • I have not added any secrets / API keys
  • I have not modified main branch or any HuggingFace deployment config
  • My code follows the existing style (no unnecessary formatting changes)
  • I have updated relevant docs / comments if needed

@nancysangani nancysangani requested a review from param20h as a code owner June 7, 2026 11:35
@nancysangani
Copy link
Copy Markdown
Contributor Author

Hi @param20h, Please review the PR when you get a chance. Thanks!

@param20h param20h merged commit 2e8fd3b into param20h:dev Jun 7, 2026
7 checks passed
@github-actions github-actions Bot added gssoc GirlScript Summer of Code 2026 issue/PR gssoc:approved Approved for GSSoC base points (+50 pts) level:intermediate +35 pts mentor:param20h Mentor for this PR labels Jun 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 7, 2026

🎉 Congratulations on getting your Pull Request merged! 🎉

Thank you for contributing to PDF-Assistant-RAG as part of GSSoC '26! 🚀

Keep up the great work! ✨

@github-actions github-actions Bot added the type:frontend Frontend UI/UX label Jun 7, 2026
@param20h param20h added type:feature +10 pts and removed type:frontend Frontend UI/UX labels Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC base points (+50 pts) gssoc GirlScript Summer of Code 2026 issue/PR level:intermediate +35 pts mentor:param20h Mentor for this PR type:feature +10 pts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ui): Add download transcript feature for chat sessions

2 participants