Skip to content

feat(chat): copy answers, questions and code, and export from the web app - #484

Merged
adeelahmad merged 13 commits into
mainfrom
claude/project-thread-r960xc-c3-export-ui
Oct 17, 2026
Merged

adeelahmad merged 13 commits into
mainfrom
claude/project-thread-r960xc-c3-export-ui

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Description

Before: the only way to copy an answer was to select its text. Citations were lost, code blocks showed as plain paragraphs, and the web app couldn't export a conversation.

After:

  • Answers have a copy button with two options. Copy as Markdown keeps citations as footnotes that name the asset, its time and speaker, with a link back to that moment in Lens (or to the web page). Copy text drops Markdown and citation numbers. The same menu exports that answer, together with its question, as Markdown, PDF or JSON.
  • Questions get a copy button that appears on hover, next to Edit.
  • Code blocks written with fences (``` or ~~~) are now shown as code, kept as written, with a copy button that says "Copied".
  • Conversation header: on wide screens, an open conversation now shows its title with a download icon that exports the whole conversation. On phones the existing header gains the same icon.
  • PDF fallback: if the server can't make a PDF (409), a toast explains that the browser's print dialog is opening. Print styles then hide the app around the conversation (navigation, list, composer, sources, buttons), and for one answer they hide every other message, so Save as PDF still works.

Motivation and Context

This is the web app part of module C3 (copy and export). It is stacked on #474, which adds the export API and MCP tools and sits on #469 (C1's answer record). Until those merge, this PR's diff includes them. Main is merged in, with #471's versions UI: the message request keeps both C1's via and C2's parent and regenerate, and chat-versions.test.tsx stubs matchMedia, which C1's answer Details reads. It also carries a fix to #474's Markdown export: grouped citations such as [2, 3] now become footnotes too.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (eslint, prettier, tsc clean).
  • I added or updated tests: __tests__/chat-copy-export.test.tsx, and chat.test.tsx now checks the question's copy button.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/assistant.md › Copy and export).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md (the export entry, updated).

Done questions (AGENTS.md)

  • Goal: with feat(chat): export a conversation as Markdown, PDF or JSON #474 this delivers copy and export end to end. Not merged yet.
  • Agents: the same exports are available through the API and the MCP tools list_chats, read_chat and export_chat (feat(chat): export a conversation as Markdown, PDF or JSON #474).
  • Zero setup: nothing to install. Without a PDF printer on the server, the browser prints.
  • Fewest clicks: an answer is copied in two clicks and a download takes two. File names are filled in, and on a 409 the print dialog opens without another click.
  • Configurable: n/a, no new settings.
  • Light: no new dependency; this is client-side only.
  • Private and secure: copies go to the person's own clipboard and exports to their own device. No new server surface beyond feat(chat): export a conversation as Markdown, PDF or JSON #474, whose threat-model row covers it.
  • Cost: no model calls.
  • User decides: everything happens on the person's click, and no defaults change.
  • Upgrades: n/a, no stored data changes.
  • Honest: copies and exports keep their citations with links, and the docs describe only what's built. Planned items stay labelled as planned.
  • Tests, docs and generated files updated (the client was generated in feat(chat): export a conversation as Markdown, PDF or JSON #474).
  • Open standards: Markdown footnotes and the browser's own print path.
  • Result reported with evidence. Refine-later items are noted in docs/assistant.md: importing a conversation from JSON, exporting to a note, and a styled PDF without Chromium.

Local CI (ci/local-ci.sh HEAD --jobs backend,frontend,pre-commit,title) on 4f0ad9b62a41:

Job Result Time
FastAPI (embedded SurrealDB) pass 2844s
Next.js pass 1018s
pre-commit pass 274s
PR title pass 1s

Generated by Claude Code

claude added 12 commits October 16, 2026 23:28
Importing app.domain.ai_tools on its own failed: it imported automations,
which loads the actions, and the agent's action subclasses Toolbox before
ai_tools had defined it. Running one test file (tests/api/test_chats.py)
hit it. ai_tools now imports automations last.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
Every answer keeps `meta`: the model and the host name of its server,
the tools offered and asked for, the scope it answered in (after
auto-scope), its limits and what it used, how it ended (answered,
direct, limit, fallback, stopped, error), tool results that read like
instructions to an AI, how long it took, Lens's version, and tokens and
cost from the ledger rows that name it. Questions keep how they were
sent (web, api, voice, room, automation) and their options.

The answer's id is taken once the question is saved and the answer
runs in activity.scope(chat:<cid>, chat_message:<mid>), in the web
chat, chat rooms and the automations' agent; the streamed answer holds
the scope across its steps (activity.scoped). App completions keep no
messages, so their record comes back in lens.record. The stream sends
`meta` before `done`; GET /chats/{cid}/messages/{mid} returns one
message with its record and ledger rows. Each tool step keeps its time
and whether it failed. The web app shows it all from an i in the
answer's header (a sheet on a phone); old answers say they weren't
recorded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
The last check asked for 2026-10-17's note after the call without a date had made today's note, so on that day it
found the note the deleted root had left behind. It now asks for a day no earlier call makes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
The answer's record uses C2's reserved answer_id for its ledger scope and is saved under the question (parent);
a message of any version can be read with its record and ledger rows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
GET /api/v1/chats/{cid}/export.{md,json,pdf} gives the version showing,
one message (?message=), or with JSON every version (?all=true) and the
OpenAI {"messages": [...]} shape (?format=messages). Markdown carries
citations as footnotes linking back to Lens and the tools used as a
"Looked up" list; JSON is a tree of OpenAI chat messages with Dublin
Core terms, published as docs/schemas/chat-export.schema.json; the PDF
is that Markdown printed by Chromium, else anytopdf, else LibreOffice,
and 409 when none can run. MCP gains list_chats, read_chat and
export_chat, kept off a namespace's own server.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
…record' into claude/project-thread-r960xc-c3-export
The threat model lists a conversation's export as an output: the
person's own, with tool summaries and citations, never raw tool results.
The OpenAPI schema and client are regenerated with make openapi's two
commands.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
The model sometimes cites several passages in one bracket, as the web
app already shows; each cited number now becomes its own footnote, and
a number with no passage stays as written.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
… app

An answer's copy button copies it as Markdown (citations as footnotes
linking back to Lens) or plain text, and exports it with its question as
Markdown, PDF or JSON. Questions and code blocks get copy buttons (code
blocks are now parsed from fenced Markdown), and the conversation's
header, now shown on wide screens too, exports the whole conversation.
When the server answers 409 for a PDF, the browser prints the
conversation, or that one answer, without the app around it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
Keeps both C1's question record (`via`) and C2's versions (`parent`,
`regenerate`) in the message request, and C2's version switch beside the
new copy buttons. The versions test stubs matchMedia, which C1's answer
Details reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
@adeelahmad adeelahmad self-assigned this Oct 17, 2026
main now carries the export API as one squashed commit (#474), so this keeps only the web app's copy and
export on top of it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
@adeelahmad
adeelahmad merged commit 8236905 into main Oct 17, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-r960xc-c3-export-ui branch October 17, 2026 08:37
adeelahmad pushed a commit that referenced this pull request Oct 17, 2026
Brings in conversation export (#474, #484). Exports keep a docs or
server citation's source (lens_help) instead of calling it a web page;
the export schema lists both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHrWfYDCaCbKKDX4w9at9C
adeelahmad pushed a commit that referenced this pull request Oct 18, 2026
…ay and clipper sign-in as built

Since the last README refresh, #474, #484, #510, #511, #497, #495, #406, #516, #517
and #491 merged. The README's built list now says a conversation exports as Markdown,
PDF or JSON and its answers, questions and code copy; a Tools chip picks an answer's
tools, limit and namespaces; sandbox runs open under the answer with downloads, and
Settings starts the gateway; deep research plans, runs and returns a cited report;
ready-made MCP servers (the browser, GitHub) and the optional containers start from
the web app; and the web clipper signs in or takes an API token. Each has its checks
in docs/requirements.md. In progress drops the merged PRs and lists the open feature
PRs; the Planned proof item keeps only the Raspberry Pi timing (#481 and #482 are
closed); the docs index links requirements and checks, and published feeds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS
adeelahmad pushed a commit that referenced this pull request Oct 18, 2026
…ay and clipper sign-in as built

Since the last README refresh, #474, #484, #510, #511, #497, #495, #406, #516, #517,
#491, #400 and #506 merged. The README's built list now says the assistant answers
questions about Lens itself; a conversation exports as Markdown, PDF or JSON and its
answers, questions and code copy; a Tools chip picks an answer's tools, limit and
namespaces; sandbox runs open under the answer with downloads, and Settings starts the
gateway; deep research plans, runs and returns a cited report; ready-made MCP servers,
the MCP servers page and the optional containers start from the web app; and the web
clipper signs in or takes an API token. Each has its checks in docs/requirements.md.
In progress lists only open PRs; the Nebula mesh (#546, merged, partly built) moves to
Planned with what's next; the Planned proof item keeps only the Raspberry Pi timing;
the docs index links requirements and checks, and published feeds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS
adeelahmad added a commit that referenced this pull request Oct 18, 2026
…ay and clipper sign-in as built (#536)

Since the last README refresh, #474, #484, #510, #511, #497, #495, #406, #516, #517,
#491, #400 and #506 merged. The README's built list now says the assistant answers
questions about Lens itself; a conversation exports as Markdown, PDF or JSON and its
answers, questions and code copy; a Tools chip picks an answer's tools, limit and
namespaces; sandbox runs open under the answer with downloads, and Settings starts the
gateway; deep research plans, runs and returns a cited report; ready-made MCP servers,
the MCP servers page and the optional containers start from the web app; and the web
clipper signs in or takes an API token. Each has its checks in docs/requirements.md.
In progress lists only open PRs; the Nebula mesh (#546, merged, partly built) moves to
Planned with what's next; the Planned proof item keeps only the Raspberry Pi timing;
the docs index links requirements and checks, and published feeds.


Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS

Co-authored-by: Adeel Ahmad <noreply@anthropic.com>
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