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

Function DataSettings

web/components/settings/DataSettings.tsx:9–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import { cn } from "@/lib/utils";
8
9export function DataSettings() {
10 const { settings, updateSettings, conversations, deleteConversation } = useChatStore();
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);
53 ids.forEach((id) => deleteConversation(id));
54 setShowClearConfirm(false);
55 }
56
57 const totalMessages = conversations.reduce((sum, c) => sum + c.messages.length, 0);
58
59 return (
60 <div>
61 <SectionHeader title="Data & Privacy" />
62
63 <SettingRow
64 label="Export conversations"
65 description={`Export all ${conversations.length} conversations (${totalMessages} messages).`}
66 >

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
exportConversationsFunction · 0.85

Tested by

no test coverage detected