Skip to content

Per-message copy + whole-conversation markdown export#47

Open
vahid-ahmadi wants to merge 1 commit intomainfrom
feat/copy-and-export
Open

Per-message copy + whole-conversation markdown export#47
vahid-ahmadi wants to merge 1 commit intomainfrom
feat/copy-and-export

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Contributor

Summary

  • Adds a small Copy button next to the cost line on completed assistant turns. Copies only the user-facing prose (post-last-tool, chart placeholders rewritten as `[Chart]`) — what the user reads, not the working section.
  • Adds a Download .md button in the chat header next to "Report issue". Exports the whole conversation as Markdown including the working section (as a `
    Details` collapsible) and tool calls (Python code + output as fenced blocks). File is named `policyengine-chat-[-].md`.
  • All export helpers (`extractFinalProse`, `messageToMarkdown`, `conversationToMarkdown`, `stripChartPlaceholders`, `formatPythonOutput`, `slugify`) are pure functions colocated above the component for now — easy to lift into `utils/` later if other surfaces need them.

Closes #43.

Test plan

  • `docker-compose up` → ask a question that triggers `run_python`. Confirm a "Copy" button appears under the assistant answer once it finishes streaming. Click it → "Copied" feedback shows for 2s; pasting elsewhere yields the rendered markdown source of the answer (no working/CoT, no tool code).
  • Click "Download .md" in the chat header → a `policyengine-chat-YYYY-MM-DD[-slug].md` file downloads. Open it: contains every user/assistant turn, the working section is a collapsible `
    Details`, Python code is a fenced ```python``` block, and chart placeholders read `[Chart]`.
  • During streaming, the Copy button is hidden (only shows when `isComplete`).
  • Download button is disabled while streaming.
  • Plan-mode replies (no tools) — Copy gives the clarifying questions text; Download produces a clean export with no working section.

Per-message copy: small Copy button next to the cost line on completed
assistant messages. Copies the user-facing prose only — the text after
the last tool call, with chart placeholders rewritten as `[Chart]`.

Conversation download: "Download .md" button in the chat header next to
"Report issue". Exports the full conversation including the working
section (rendered as a `<details>` collapsible) and tool calls (Python
code + output as fenced blocks). File is named
`policyengine-chat-<date>[-<title-slug>].md`.

Helpers (`extractFinalProse`, `messageToMarkdown`, `conversationToMarkdown`,
`stripChartPlaceholders`, `formatPythonOutput`, `slugify`) are colocated
in ChatPage.tsx — pure functions, easy to lift later if needed.

Closes #43

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-uk-chat Ready Ready Preview, Comment May 6, 2026 11:30am

Request Review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Beta preview is ready.

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.

Whole-message copy + markdown export

1 participant