Repository navigation
Export a chat to PDF from the terminal, and /export in the TUI (ATO-1054) - #1715
Draft
sosidudku1 wants to merge 1 commit into
Draft
sosidudku1 wants to merge 1 commit into
sosidudku1 wants to merge 1 commit into
Conversation
…O-1054) The core exporter gains a PDF writer built with Node alone: text pages in the standard PDF fonts with WinAnsi encoding, so no browser and no new dependency. Text outside Western European scripts is transliterated or shown as ?, and the PDF ends with a note saying how many characters changed. atomic-agent export and the export route accept --format pdf. The TUI gets /export [md|docx|pdf|html] [path], registered in the menu registry and the palette, writing the open chat with the same exporter and showing the saved path.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What the user gets
atomic-agent export --last --format pdfwrites a PDF named after the chat (or to--out). The export route takesformat=pdftoo (base64, like DOCX)./exportin the TUI. It saves the open chat with the same exporter and prints the saved path in the chat:/exportwrites Markdown named after the chat into the folder the terminal was started in. It never writes over an earlier file: the second one isTrip plan (2).md./export md|docx|pdf|html [path]picks the format; the path may hold spaces or quotes,~works, a folder gets the chat's file name, a name with no extension gets the format's./export notes.pdfpicks the format from the extension./export <file>and our--outdo./rewind) and in the menu under Session as "Export chat".Copied from Claude Code:
/export <filename>writes the conversation to that file and says where. Claude Code's bare/exportopens a copy-or-save dialog; here bare/exportsaves Markdown straight away and shows the path, with no clipboard step.What changed
src/session/chat-export-pdf.ts(new): Markdown to PDF with Node only (zlibfor the page streams). Text pages in the four standard PDF fonts (Helvetica, Bold, Oblique, Courier), so nothing is embedded. Real AFM widths for wrapping, A4, headings, bold/italic/code, lists with hanging markers, task boxes, block quotes with a bar, shaded code blocks, tables asA | Brows, rules,Page n of Nfooter, UTF-16 title in the document info.ПриветbecomesPrivet), accents outside Latin-1 drop to the base letter, arrows and similar become->,<=, and everything else (CJK, emoji) becomes?. When anything changed, the PDF ends with a note saying how many characters changed and that Markdown and Word keep them all; the TUI line says so too. No font file is in the repo, so none is embedded.src/session/chat-export.ts,chat-export-render.ts,index.ts:pdfis a format (application/pdf,.pdf).src/cli/export-command.ts:--format pdf, help text updated.src/http/route-session-export.ts: acceptspdf; the desktop still prints its own PDF fromhtml.src/tui/commands/export-command.ts(new): argument parsing, path resolution, writing. Wired throughslash-command-handler.ts(chatExport),submit-handler.ts,TuiAppCallbacks.onChatExportRequested,tui-command.tsandChatOrchestrator.exportOpenChat.src/tui/menu/menu-registry.ts: thesession.exportnode with the/exportslash entry.Tests
src/session/chat-export-pdf.test.ts(new): header, every xref offset points at its object, trailer andstartxref, fonts and WinAnsi, title and date; page count in the page tree matches the streams for a long chat and the footer counts them; wrapping and PDF string escaping; WinAnsi mapping, transliteration,?and the closing note (only when needed); lists, task boxes, quotes, code and tables.src/tui/commands/export-command.test.ts(new): argument parsing, path resolution, numbered default names, overwrite of a named path, PDF bytes, the font note, nothing to export, missing folder.slash-command-handler.test.ts,submit-handler.test.ts:/exportdispatch and the callback.menu-registry.test.ts: palette snapshot gains/export.pdfused to be the rejected format (nowrtf), and the route test checks a base64 PDF.Not done, and why
/export.Part of ATO-1512.
Not yet checked on the second Mac.