Skip to content

feat: export chat conversation as Markdown or PDF #353

@Harigithub11

Description

@Harigithub11

Summary

Users should be able to export the full chat conversation as a Markdown (.md) file or a PDF directly from the chat UI — no backend changes needed.

Current Behavior

The Navbar has a Share button for sending conversations via email or public link. There is no option to download or export the conversation locally.

Expected Behavior

A dropdown export button in the Navbar (next to the Share button) with two options:

  • Export as Markdown — downloads a .md file with all messages formatted cleanly.
  • Export as PDF — triggers the browser's native print/save-as-PDF dialog with a readable layout.

Where to Look

Primary file: app/(main)/chat/[chatId]/components/Navbar.tsx

  • The Share button lives around line 334. Add the export dropdown in the same button group.
  • The conversationId is already derivable from usePathname() — same pattern used on line 69.
  • The chat title is available in the displayTitle state (line 63) — use it for the filename.

Fetching messages: services/ChatService.ts

  • ChatService.loadMessages(conversationId, start, limit) (line 569) fetches existing conversation messages. Use this to retrieve the full conversation before exporting.

UI component: components/ui/dropdown-menu.tsx is already available for the dropdown.

For Markdown — format the messages into text, create a Blob, and trigger a download via a temporary anchor element.

For PDF — no external library needed. Build a styled HTML representation of the conversation and use the browser's built-in print functionality.

Files to Change

File What changes
app/(main)/chat/[chatId]/components/Navbar.tsx Add export dropdown button and the two export handler functions

No backend changes. No new npm dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions