Skip to content

FEAT: Add conversation export button to the GUI chat view - #2259

Merged
varunj-msft merged 3 commits into
microsoft:mainfrom
varunj-msft:varunj-msft/10738-GUI-Export-Conversation
Jul 30, 2026
Merged

FEAT: Add conversation export button to the GUI chat view#2259
varunj-msft merged 3 commits into
microsoft:mainfrom
varunj-msft:varunj-msft/10738-GUI-Export-Conversation

Conversation

@varunj-msft

Copy link
Copy Markdown
Contributor

Description

Adds an Export control to the CoPyRIT chat ribbon that downloads the currently
displayed conversation as Markdown or JSON. Serialization is fully
client-side (from the in-view messages) — no backend changes and no
conversation data leaves the browser.

  • conversationExport.ts (new): pure Markdown/JSON serializers, timestamped
    filename builder, and a Blob-based download helper. Hardened for safety —
    dynamically-sized code fences, sanitized filenames, strips non-serializable
    File handles and in-flight loading placeholders, and revokes the object URL.
  • ChatWindow.tsx: Export menu button (Markdown / JSON) enabled only when a
    viewable, settled conversation is shown; exports the displayed branch. Uses a
    Fluent Tooltip label to match the sibling ribbon buttons.

Frontend-only; no Python/API changes.

Tests and Documentation

Tests

  • 35 unit tests for the serializers, filename builder, and download helper
    (conversationExport.test.ts).
  • 10 unit tests for the ChatWindow export menu (gating, format selection,
    Markdown/JSON output).
  • 2 real-browser Playwright E2E tests that trigger the download and assert the
    actual downloaded Markdown/JSON bytes (chat.spec.ts).

Documentation

  • Updated doc/gui/0_gui.md to document the export button and its
    behavior (including the system prompt shown in the banner).
  • No notebooks / JupyText-paired docs changed, so no JupyText execution was
    needed.

Copilot AI review requested due to automatic review settings July 22, 2026 21:26

Copilot AI 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.

Pull request overview

Adds a frontend-only “Export conversation” control to the CoPyRIT chat ribbon, enabling users to download the currently displayed conversation as Markdown (readable transcript) or JSON (structured data) entirely client-side.

Changes:

  • Added a new conversationExport.ts utility to serialize conversations (Markdown/JSON), build safe filenames, and trigger Blob-based downloads.
  • Integrated an Export menu into ChatWindow with gating logic so export is only enabled for a stable, viewable conversation.
  • Added unit tests (serializer + UI) and Playwright E2E coverage for real downloads; updated GUI documentation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/utils/conversationExport.ts New export/serialization and download helper utilities for Markdown/JSON exports.
frontend/src/utils/conversationExport.test.ts Unit tests covering serialization, filename building, and download helper behavior.
frontend/src/components/Chat/ChatWindow.tsx Adds export menu button to the ribbon and enables/disables it based on conversation state.
frontend/src/components/Chat/ChatWindow.test.tsx Integration tests for export gating and menu-driven export behavior.
frontend/e2e/chat.spec.ts Playwright tests validating actual downloaded bytes for Markdown and JSON exports.
doc/gui/0_gui.md Documents the new Export button and its behavior/security note.

Comment thread frontend/src/utils/conversationExport.ts
Comment thread frontend/src/utils/conversationExport.ts
@jsong468

Copy link
Copy Markdown
Contributor

Could you provide some screenshots / video of what the user experience looks like here? :)

Comment thread frontend/src/components/Chat/ChatWindow.tsx Outdated
Comment thread frontend/src/utils/conversationExport.ts
Comment thread frontend/src/components/Chat/ChatWindow.tsx
@jsong468 jsong468 self-assigned this Jul 25, 2026
@varunj-msft

Copy link
Copy Markdown
Contributor Author

Could you provide some screenshots / video of what the user experience looks like here? :)

Ah you're right, forgot to upload these! Here's some images with the export button shown. I can also provide the example md and json output if needed

01-chat-with-export-button 02-export-menu-open

@varunj-msft

Copy link
Copy Markdown
Contributor Author

@jsong468 Added screenshots! 🙂 One shows the Export button in the ribbon, the other the Markdown/JSON menu. Also pushed fixes for your other notes: the gate now ignores a lone system prompt (+test), and conversationToJson now takes the same exportedAt and writes an exported_at field so it's symmetric with Markdown. Left the activeConversationId fallback as-is

@romanlutz

Copy link
Copy Markdown
Contributor

Why is the button greyed out? Makes it look inactive as if it wasn't usable.

@varunj-msft

Copy link
Copy Markdown
Contributor Author

Why is the button greyed out? Makes it look inactive as if it wasn't usable.

@romanlutz It was the timing of the screenshot! It was transitioning between inactive (light grey) and active (darker grey). Then it appears blue when you hover over the icon and it is active/clickable. Export is intentionally disabled while a message is in flight (so you can't export a half-finished turn), hence it is greyed out in the second prompt.

Add an Export control to the CoPyRIT chat ribbon that downloads the
currently displayed conversation as Markdown or JSON. The file is
serialized client-side from the in-view messages (WYSIWYG), including
the system prompt shown in the banner; no conversation data is sent to
the server.

- conversationExport.ts: pure Markdown/JSON serializers, filename
  builder, and Blob-based download helper
- ChatWindow.tsx: Export menu button (Markdown / JSON) enabled only for
  a viewable, settled conversation
- Unit tests plus a real-browser Playwright E2E; GUI docs updated
Refine the conversation export button based on PR review:

- Add exported_at (ISO 8601) to the JSON envelope so the timestamp is
  self-describing and matches the filename, keeping Markdown and JSON
  consistent.
- Disable export for a lone system prompt: the gate now requires at
  least one non-loading, non-system message.
- Rewrite longestBacktickRun as a single-pass scan with no intermediate
  match array.
- Add tests for the JSON timestamp, shared-timestamp agreement, and the
  system-only disabled state; clarify the GUI docs.
@varunj-msft
varunj-msft force-pushed the varunj-msft/10738-GUI-Export-Conversation branch from 99795fa to f46eef1 Compare July 30, 2026 16:07
@varunj-msft
varunj-msft enabled auto-merge July 30, 2026 16:17
@varunj-msft
varunj-msft added this pull request to the merge queue Jul 30, 2026
Merged via the queue into microsoft:main with commit 991f9a4 Jul 30, 2026
54 checks passed
@varunj-msft
varunj-msft deleted the varunj-msft/10738-GUI-Export-Conversation branch July 30, 2026 16:42
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.

4 participants