Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: include tool calls in copy-as-markdown from AI chat

Louis Beaumont455194cbaa28
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
index a6a4e4835..03e15439c 100644
--- a/apps/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
@@ -231,7 +231,44 @@ export function AIPanel({
const md = chatMessages
.map((m) => {
const role = m.role === "user" ? "**User**" : "**Assistant**";
- return `### ${role}\n\n${m.content}`;
+ let body = m.content || "";
+
+ // include tool calls from parts (ai sdk v4+)
+ if (m.parts && m.parts.length > 0) {
+ const partSections: string[] = [];
+ for (const part of m.parts) {
+ if (part.type === "text" && part.text) {
+ partSections.push(part.text);
+ } else if (part.type === "tool-invocation") {
+ const inv = (part as any).toolInvocation;
+ if (inv) {
+ const argsStr = inv.args ? JSON.stringify(inv.args, null, 2) : "";
+ let section = `\n**Tool: ${inv.toolName}**\n\`\`\`json\n${argsStr}\n\`\`\``;
+ if (inv.state === "result" && inv.result !== undefined) {
+ const result = typeof inv.result === "string" ? inv.result : JSON.stringify(inv.result, null, 2);
+ section += `\n**Result:**\n\`\`\`\n${result}\n\`\`\``;
+ }
+ partSections.push(section);
+ }
+ }
+ }
+ if (partSections.length > 0) {
+ body = partSections.join("\n\n");
+ }
+ }
+ // include tool invocations (ai sdk legacy)
+ else if (m.toolInvocations && m.toolInvocations.length > 0) {
+ for (const inv of m.toolInvocations) {
+ const argsStr = inv.args ? JSON.stringify(inv.args, null, 2) : "";
+ body += `\n\n**Tool: ${inv.toolName}**\n\`\`\`json\n${argsStr}\n\`\`\``;
+ if ("result" in inv && inv.result !== undefined) {
+ const result = typeof inv.result === "string" ? inv.result : JSON.stringify(inv.result, null, 2);
+ body += `\n**Result:**\n\`\`\`\n${result}\n\`\`\``;
+ }
+ }
+ }
+
+ return `### ${role}\n\n${body}`;
})
.join("\n\n---\n\n");
await navigator.clipboard.writeText(md);