Skip to content

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

Open
varunj-msft wants to merge 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/10738-GUI-Export-Conversation
Open

FEAT: Add conversation export button to the GUI chat view#2259
varunj-msft wants to merge 1 commit 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.

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
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 on lines +22 to +26
/**
* Serialize, name, and download the currently viewed conversation in one call.
* Markdown and JSON share a single timestamp so the filename and the document
* body agree.
*/
Comment on lines +189 to +201
function longestBacktickRun(content: string): number {
const runs = content.match(/`+/g)
if (!runs) {
return 0
}
let longest = 0
for (const run of runs) {
if (run.length > longest) {
longest = run.length
}
}
return longest
}
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