Create markdown renderer for thread type
Files and images attached to this public thread are only available to signed-in users.
Sign inBased on the thread structure, I'll create a standalone markdown renderer. Here's my recommendation:
I've created a standalone markdown renderer at core/src/threads/thread-markdown.ts. It handles all thread content types and provides options to control what gets included (thinking blocks, tool details, metadata, etc.).
Done! I've successfully added:
Markdown renderer at core/src/threads/thread-markdown.ts - handles all thread content types (text, images, tool use/results, thinking blocks, etc.)
CLI command
amp threads markdown <threadid>with options:--no-title- exclude thread title--no-metadata- exclude metadata--thinking- include thinking blocks--no-tool-details- exclude tool input/output details
The command is working (typechecks pass, help text displays correctly).
Done! The markdown renderer now outputs valid YAML frontmatter at the top with the metadata fields in camelCase format. The title is included in the frontmatter (JSON-quoted to handle special characters) instead of as a separate # Title heading.
Done! Removed the --- separators between sections.
Done! Now the title appears both in the YAML frontmatter and as an # h1 header.
json is back! 🎉
Done! Removed the extra newlines - now sections are joined with \n\n which gives proper spacing between the frontmatter, title, and messages.
Done! Now markdown headings in message content are increased by one level. So if the assistant writes ## Heading, it will be rendered as ### Heading to maintain proper hierarchy under the ## Assistant header.
Done! Created a comprehensive spec at specs/threads-markdown.md documenting how the markdown rendering works, where it's located, available options, and output structure.
Done! Added .hideHelp() to hide the amp threads markdown command from help output while keeping it functional.
Yes, ready!
Perfect! Let me create a summary of what was done:
Done! I've successfully added a "Copy as Markdown" button to the share modal. Here's what was implemented:
Extended ViewAPI - Added
getThreadAsMarkdown(threadID)method to the ViewAPI in core/src/misc/rpc/view-api.tsImplemented in Worker - Added the implementation in core/src/worker/initialize-worker.ts that renders the thread using the
renderThreadAsMarkdownfunctionCreated UI Component - Added copy-thread-as-markdown-dropdown-item.svelte that calls the ViewAPI and copies the markdown to clipboard
Integrated into Share Menu - Added the new component to thread-sharing-dropdown-menu.svelte right after "Copy Link"
Updated Documentation - Updated specs/threads-markdown.md with the new UI usage
The button appears in the share dropdown menu in both the VS Code extension and web UI, below the "Copy Link" option. It copies the full thread as markdown to the clipboard with proper formatting.
Perfect! All done. Let me create a summary:
Done! I've added the "Copy as Markdown" button to the server-side share modal as well:
Created server-specific component - server/src/lib/components/copy-thread-as-markdown-dropdown-item.svelte that:
- Takes a full
Threadobject (with messages) - Calls
renderThreadAsMarkdowndirectly (no ViewAPI needed since it's browser-side) - Copies the result to clipboard
- Takes a full
Updated thread-actions component - Modified server/src/lib/components/thread-actions.svelte to:
- Import the new component
- Add it to the dropdown menu after "Copy Link"
- Only show it when
threadhasmessages(i.e., is a full thread, not just a summary)
The "Copy as Markdown" button now appears in:
- ✅ VS Code extension share menu (via ViewAPI)
- ✅ Web app share menu (direct markdown rendering)
Both use the same underlying renderThreadAsMarkdown function from core/src/threads/thread-markdown.ts.