Repository navigation
Conversation
1d79382 to
5b5f82d
Compare
…old#220) to_folder/from_folder work on an in-memory file map: canonical JSON in model key order, nulls dropped only where reloading proves it changes nothing (Chart.title and Chart.legend keep theirs), stable ULID slide keys matched by slide id, media named by SHA-256, slide order and sections in slides.order. Keys the model doesn't know are kept from the previous files. Reading ends in the same media + repair path as load().
… file.export) (storytold#220) A path ending in .deck, an existing folder or a folder's deck.json opens as a folder deck. Saving writes changed files to hidden temporary siblings, renames them into place, then removes the slide, master and media files that no longer belong; files the format doesn't own are left alone, and a non-deck folder is refused. A new folder is written next to its place and renamed in one step.
…torytold#220) File ▸ Open Folder… (and on the start screen) picks a .deck folder; the Open dialog also takes a folder's deck.json. Save As lists the presentation formats with the current one first, including DeckCraft folder (.deck), and suggests .deck for a presentation opened from a folder. A dropped folder opens. In the browser the folder actions say they aren't available. deckcraft-cli convert and info take .deck folders.
…torytold#220) docs/deck-folder-format.md describes the layout and rules; the MCP file tools mention .deck folders and export lists the deck format.
The File tab (storytold#344) arrived after the .deck folder format (storytold#220) was written against the old Save As and Export dialogs. Its pages now offer the folder format too: Open has Open Folder next to Browse, Save As and Export > Change File Type list DeckCraft Folder (*.deck) (Save As makes the presentation live in the folder, Export writes a copy), and file.info gives the size of a folder's files instead of the size of the directory entry. Tests: the File tab exports, saves as and opens a folder through real egui input; file.info on a saved folder.
5b5f82d to
ed8955e
Compare
…name says (.png, .jpg, .tif or .pam) (storytold#255) `render --out p1.png` wrote a netpbm PAM stream (P7) whatever the name, so a `.png` could not be opened by any PNG reader. The CLI already links the engine, whose export module encodes PNG, JPEG and TIFF, so the output format now follows the extension: `.png`, `.jpg`/`.jpeg` (quality 90), `.tif`/`.tiff`, and `.pam` for the raw stream as before. Any other name is refused up front, before the page is rendered, with the accepted list. `export::encode_image` wraps the three encoders behind `ImageFormat` so the CLI and `Exporter::image` share one match. Tests (apps/pdfcraft-cli/tests/render.rs): a `.png` gets the PNG signature and an IHDR with the rendered size; `.JPG` and `.tif` get JPEG/TIFF magic; `.pam` still gets the P7 header and the right number of bytes; `.bmp` fails with the message and writes nothing. Co-authored-by: wstock <1394687+wstock@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: a .deck folder format, a presentation as one JSON file per slide, for Git. The README says to save as a .deck folder to review and merge decks in Git, with a format document at docs/deck-folder-format.md; the lock gains deckcraft-color and deckcraft-geom edges for the new crate. A folder format makes diffs and merges reviewable, which is a real gain, and the design questions are the stability of the schema (a version field and a rule for unknown keys), how media are stored (as files beside the JSON, with names that cannot escape the folder), and whether saving is atomic. Reading a folder is a parser of untrusted input like any other. The ROADMAP hunks are hand-edited. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
Closes #220.
Problem
A
.deckcraftfile is a zip whosepresentation.jsonis one compact line. In Git it is an opaquebinary: no readable diff, no review, and two branches that touch the same deck conflict on the
whole file. Decks edited by agents through the CLI or MCP leave changes nobody can review.
What changes
A second on-disk form of the same document, a folder that DeckCraft opens and saves directly
(spec:
docs/deck-folder-format.md):Five commits, rebased on
mainat 9859da3:crates/format/src/folder/):to_folder(&Presentation, previous) -> FileMapandfrom_folder(&FileMap) -> Result<Presentation>, pure functions over an in-memory file map, sothe crate stays free of I/O and wasm is unaffected.
model writes them. A small ordered JSON value (
folder/json.rs) keeps that order withoutturning on serde_json's
preserve_orderfor the whole workspace.key: nullpairs are dropped only when reloading without them gives the same model; thecheck found
Chart.titleandChart.legend(defaults aren't null) and keeps those.version of each file, in place.
reordering only touches
slides.orderand two branches adding slides never collide. Clockand randomness are injectable (
KeyGen::fixedin tests); on wasm the clock part is zero.FIPS vectors), stored once per content;
generatorandnextIdaren't written.sections.json; masters or media out of idorder get an explicit order in
deck.json.repair()path asload()(a sharedfinish()that also keepsthe first of repeated media ids, as
load()now does);"format": "deckgit"is read too (the external tool this started as), and anexisting folder keeps its
formatvalue andslides.orderheader when saved again.crates/engine/src/folder.rs,cmd/file.rs):file.openandfile.adopttake a.deckfolder or itsdeck.json(folders are read inread_presentation_file, so the app's background open handles them too);file.save/file.saveAs/file.exportwrite one for a.deckpath or format
deck. Only changed files are written: each goes to a hidden temporarysibling, then all are renamed into place, then owned files that no longer belong are removed.
Files the format doesn't own (README,
.gitattributes…) are never touched; saving into afolder that isn't a deck is refused. A new folder is written beside its place and renamed in
one step.
engine::folderis a checked gateway likeio.rs: the folder and every file read,written or removed in it pass the automation roots (
file_access::check_read/check_write)first, and the
commands_do_not_touch_the_file_system_themselvestest lists it next toio.rs..deckjoinsWRITABLE_EXTENSIONS.app.openFolderDialog: menu tree, command palette), the Open dialogaccepts a folder's
deck.json, Save As lists DeckCraft / PowerPoint / DeckCraft folder (.deck)with the current format first and suggests
.deckfor a presentation opened from a folder,Export (
SlideApp::export_as) takes thedeckformat, a dropped folder opens, command-linepaths and recent files work as for files. The browser build says folder open/save isn't available.
deckcraft-cli convertand
infotake.deckfolders.docs/deck-folder-format.md, a row indocs/file-format-parity.md,ROADMAP.mdprogress log, architecture and README lines; MCP file tools mention folders andexportlistsdeck.Browse; Save As and Export › Change File Type list DeckCraft Folder (*.deck) (Save As makes the
presentation live in the folder, Export writes a copy);
file.infogives the size of afolder's files instead of the size of the directory entry (through the read root, like
io::file_len).How it was tested
cargo xtask cipasses onmainat 9859da3 (all 7 steps: fmt, pdf-deps, clippy-D warnings, 1,706tests passed and 6 ignored, assets, layers, wasm32 check; on Windows the
deckcraft-ui-eguilibtests sometimes crash with an access violation when run in parallel, on
mainas well, so the runused
RUST_TEST_THREADS=1). New tests, all on decks generated incode:
crates/format/src/folder/(27): lossless round trip against the zip path on a deck withevery shape kind (picture, group, connector, table, charts, media clip, ink, opaque/SmartArt),
notes, comments, sections, custom shows, notes and handout masters, shared and linked media;
byte-identical re-save (also after a load); slide keys across reorder, delete and add; the
Chart.title/legendnulls; one media file per content; unknown keys kept in slides,deck.jsonand media records;sections.json,mastersOrder,mediaOrderfallbacks; afolder in the external tool's layout built from its spec; damaged folders (bad JSON, duplicate
keys, missing files, hash mismatch with a Git LFS hint, truncated files) are errors, not
panics; owned-path rules; SHA-256 vectors; ULID and
slides.ordergrammar.crates/engine/src/folder/tests.rs(6):file.infoon a saved folder; Save As/Open on disk with the sample deck plustables, charts, pictures, SmartArt and sections; an unchanged save writes nothing; deleting a
slide removes its file and nothing else, user files stay; a slide move rewrites only
slides.order; refusal to write into a non-deck folder; zip ⇄ folder conversion.crates/ui-egui(2): Save As with the folder format, Open Folder…, and the.decksuggestion afterwards, through injected dialog services; the File tab exports, saves as and
opens a folder through real egui input (
backstage_tests.rs).apps/deckcraft-cli/tests/deck_folder.rs(1):convertboth ways andinfo.Interop with the external tool: a folder it writes opens and saves again byte-identical; a
fresh folder from the same
.deckcraftdiffers only by theformatvalue, theslides.orderheader line and the random slide keys; its
packof a DeckCraft-saved folder loads as the samemodel.
Known limits
alloc_idcounter). Keeping ids apart per branch, repairing them after a merge, and importingPowerPoint files returned by reviewers are left to external tools, as proposed in Proposal: a Git-friendly folder format for presentations (
.deck/: one JSON file per slide) #220.slides.orderwith a key listed twice (amerge=unionmerge of a move) is reported as anerror rather than resolved.
videos).
"format": "deckcraft-folder"is the name proposed in Proposal: a Git-friendly folder format for presentations (.deck/: one JSON file per slide) #220, pending the maintainers' answer.