MCPcopy Create free account
hub / github.com/codeaashu/claude-code / exportConversations

Function exportConversations

web/components/settings/DataSettings.tsx:13–49  ·  view source on GitHub ↗
(format: "json" | "markdown")

Source from the content-addressed store, hash-verified

11 const [showClearConfirm, setShowClearConfirm] = useState(false);
12
13 function exportConversations(format: "json" | "markdown") {
14 let content: string;
15 let filename: string;
16 const ts = new Date().toISOString().split("T")[0];
17
18 if (format === "json") {
19 content = JSON.stringify(conversations, null, 2);
20 filename = `claude-code-conversations-${ts}.json`;
21 } else {
22 content = conversations
23 .map((conv) => {
24 const messages = conv.messages
25 .map((m) => {
26 const role = m.role === "user" ? "**You**" : "**Claude**";
27 const text = typeof m.content === "string"
28 ? m.content
29 : m.content
30 .filter((b) => b.type === "text")
31 .map((b) => (b as { type: "text"; text: string }).text)
32 .join("\n");
33 return `${role}\n\n${text}`;
34 })
35 .join("\n\n---\n\n");
36 return `# ${conv.title}\n\n${messages}`;
37 })
38 .join("\n\n====\n\n");
39 filename = `claude-code-conversations-${ts}.md`;
40 }
41
42 const blob = new Blob([content], { type: "text/plain" });
43 const url = URL.createObjectURL(blob);
44 const a = document.createElement("a");
45 a.href = url;
46 a.download = filename;
47 a.click();
48 URL.revokeObjectURL(url);
49 }
50
51 function clearAllConversations() {
52 const ids = conversations.map((c) => c.id);

Callers 1

DataSettingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected