Skip to content

Drawing W11, W12, W15: where drawings are saved, their records and their commands #3890

Open

Description

@CamWight

Part of #860: packages W11, W12 and W15 of the consolidated plan. They cover where drawings are saved, the records they are saved as, and the commands that change them.

Why now

Sheets, borders and title blocks (#3875), and parts lists, revision tables and balloons (#3874), can be designed and tested as data today. None of them can be saved until these exist. Nobody has claimed them.

What this covers, in order

  1. W11, where drawings live (the G3 decision, which is @bherbruck's). I'll write a comparison first, with no code: drawings embedded in the .solidcraft design, separate drawing files linked to designs, or both. It works through concrete cases:

    • saving and reopening;
    • moving or renaming files;
    • a missing or changed design;
    • the browser build;
    • crash recovery;
    • older releases opening newer files;
    • undo;
    • sharing and packaging.

    For each, it covers the format and migration consequences. My own preference (separate files, undo per file) is marked as mine, and nothing is built until the decision is made.

  2. W12, the saved records for the chosen mode: drawing, sheet, view, annotation, table and resource records.

    • Each has a stable id, an explicit source (design identity and configuration), a drafting profile, units and a content language.
    • Native changes follow the pending-format rule; a separate drawing file gets its own versioned schema.
    • Tests cover old files, missing and duplicate ids, cycles, size limits, recovery, and save and reopen.
  3. W15, the commands: create, query, update and delete by explicit id. Undo is routed as W11 decides.

    • Drawing-only changes never re-evaluate the model, and refreshes add no undo step.
    • A failing command changes nothing.

Sections and visibility (#2068, #2105, #2455) are untouched.

Related

Refs #860

Activity

  1. added
    needs-triage
    in progress
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    Claimed by @CamWight through #3891. The claim lapses after 14 days without pushes.

  3. CamWight commented on Oct 22, 2026

    @CamWight
    ContributorAuthor

    Where drawings live: a comparison for the G3 decision (W11)

    The decision is @bherbruck's. This lays out three options against concrete cases, with what each costs in code and in
    the format, so it can be made once. Nothing is built until it is.

    What exists today (main 3b982ca, 2026-10-22)

    • A .solidcraft file is a ZIP container (solidcraft-container/1) holding document.json (the versioned
      solidcraft/N document), content-addressed blobs (STEP, meshes, images) and disposable caches (model, preview,
      thumbnail). Plain JSON stays a fully supported, self-contained format. docs/design-container.md.
    • Saving is temporary file, flush, rename, with a .bak. Recovery and autosave read both containers and JSON. The
      browser uses OPFS, downloads and the same container code.
    • Embedded precedent: render settings live in the document behind their own Arc
      (Document.render), and a change that touches only them refreshes without rebuilding the model
      (render_only_change).
    • Separate-file precedent: a linked design (DesignLink {path, feature}) keeps the other file's path relative to
      this design's folder. Its bodies are copied in as an Import feature, so the design opens without the file;
      component.update_links, relink, break_link and links manage it. docs/linked-design-paste.md.
    • Undo is per session: one Session per open design (up to 32 tabs), whole-document snapshots, at most 200
      steps, and checkpoints. The crash journal is per session, restarted by each autosave.
    • Format rule: a saved change adds one pending file; the build writes the next number, which no release reads, so
      a release refuses rather than drops.

    The options

    • A. Embedded: drawings are records inside the design (a drawings field behind its own Arc, or container
      entries of their own).
    • B. Separate files: a drawing is its own file (the same container format, marked as a drawing), linked to the
      design it documents like DesignLink: a path relative to the drawing, plus the design's identity and the revision
      it was last updated against.
    • C. Both: either, with commands to extract an embedded drawing to a file and to embed a file.

    The cases

    Case A. Embedded B. Separate files
    Save and reopen One file, one save; nothing to resolve Two files; the drawing resolves its design on open
    Move or rename files Nothing can break A moved design needs Relink (the DesignLink flow); a moved pair keeps working through the relative path
    A missing or changed design Can't happen The drawing opens with its views in the states planned for model references (#4892: lost, or out of date), never shown as current, and offers Relink
    Several drawings of one design Several records in the design Several files
    One drawing of several designs Only through linked designs inside the design Possible, though SolidCraft keeps parts as components of one design, so it's rarely needed
    Release and revision The design's revision covers both; a drawing revision is a field in its record The drawing has its own revision and history, the usual practice (ISO 7200 identifies the drawing separately from the part)
    Version history (#2869, #2995, #3002) Planned per design file, so a drawing shares its design's versions; a drawing revision is a version of the whole file A drawing is one more file with its own versions; each drawing revision records the design versions its views showed
    Who edits what Edits to model and drawing serialise in one file A drafter can work on the drawing while someone edits the model
    Undo One history per design: undoing an early model edit means undoing later drawing edits first; drawing edits can push model edits out of the 200 steps Per file, as I'd prefer. A sheet-driven model edit runs in the design's session as an ordinary step, with a marker in the drawing's history; undo in the drawing never changes the design
    Live update Same session: views go out of date and recompute from the same evaluation The drawing needs the design evaluated: shared with the design's tab when it is open, otherwise a hidden session; changes in the design tab notify the drawing
    Crash recovery and replay One journal Two journals, replayed in order
    Older releases One pending format file; a release refuses a newer design A new file kind with its own versioned schema; older releases can't open drawings at all, which is safe; the design itself needs no change
    The browser Works as designs do (OPFS) Needs both files in OPFS, and a picker that keeps them together
    Sharing and packaging The design file is the package A drawing needs its design: a pack command, or embedding a snapshot of what it references
    Size Drawings make the design file bigger Each file stays its own size
    Effort Smallest: the render-settings pattern Larger: file kind, resolve and relink flow, cross-session update and undo marker, packaging

    What doesn't depend on the choice

    The drawing, sheet, view, annotation, table and resource records (W12) can be the same in both. Each has a stable
    id, an explicit source (the design's identity and configuration), a profile, units and a language, all in a record of
    their own behind an Arc. View definitions (W17a, #4816) name their source the same way: a design and one
    configuration. The commands (W15) take explicit ids and work through the same session either way. So the records can
    be designed now and the storage added once the decision is made.

    Preferences

    • My preference (from my work as a design engineer): separate files, with undo per file.
    • Industry practice: most desktop CAD keeps drawings as separate files referencing the model. Cloud CAD keeps
      them as a tab in the same document.
    • 0xlillith's plan asks for one mode to be chosen first, not both built to put off deciding.

    The question

    @bherbruck, which do you want for the first implementation: A (embedded), B (separate files) or C (both)? With B, should a
    drawing file use the same container format with a "drawing" marker, and a name of its own (for example
    .solidcraft-drawing)?

  4. CamWight commented on Oct 22, 2026

    @CamWight
    ContributorAuthor

    Decided by @bherbruck in the project's Discord (#contributing, 2026-10-22): drawings are separate files (option B above). Thank you!

    What follows on this issue:

    1. A build plan for W11, W12 and W15 on that basis, posted here before any code. It covers:
      • the drawing file kind;
      • linking a drawing to its design (the DesignLink pattern: a path relative to the drawing, plus the design's identity);
      • resolving and relinking on open;
      • undo per file;
      • crash recovery for both files;
      • the browser build.
    2. The sheet, title block, parts list and balloon work (Drawing W18: sheets, borders, title blocks and drawing templates #3875, Drawing W24–W26: bill of materials, sheet tables (parts lists) and balloons #3874) keeps going as data, and gets saved once W12's records land.

    One detail is left from the comparison. I'd suggest that a drawing file uses the same container as a design (solidcraft-container/1), with a marker saying it's a drawing and its own versioned schema, and the extension .solidcraft-drawing. Say if you'd like a different name.

  5. CamWight commented on Oct 22, 2026

    @CamWight
    ContributorAuthor

    The build plan for W11, W12 and W15, now that drawings are separate files

    Thanks again to @bherbruck for the decision. Here's how I'd like to build it, posted before any code so anyone starting nearby can follow the same plan. Everything below is against drawings (today the same commit as main, 3b982ca). The work lands as small single-topic PRs into drawings, in order.

    What a drawing file is

    • A .solidcraft-drawing file in the same container as a design (solidcraft-container/1). Its container.json says "content": "drawing", and it holds a drawing.json part with its own format, solidcraft-drawing/N.
    • It has no document.json. So no release can ever open a drawing as an empty design and save over it. Older releases refuse it, and newer ones say it's a drawing.
    • The drawing format uses the same versioning code as designs, with its own folder of pending changes (crates/doc/src/drawing/format/pending/). Contributors add one file per change, exactly as for designs, and the release script folds both folders.
    • The extension lives in one constant, so @bherbruck, if you'd like a different name, it's a one-line change.
    • The design format doesn't change at all.

    How a drawing finds its designs

    • A link is a path relative to the drawing's folder, the same rule linked designs use (DesignLink). It's rebased on Save As. The path helpers move out of component_link.rs into one module that both use.
    • What the views last showed is kept in the drawing's cache/, stamped with each design's content fingerprint (SHA-256 of its document.json) and the build.
    • A view counts as current only when every stamp matches. Otherwise it's shown as out of date, or as lost when the design is missing. It's never shown as current by mistake, and a reopened drawing whose designs haven't changed recomputes nothing.
    • A drawing always opens, even when a design is missing, unreadable or from a newer release. Its sources then report their state, and Relink points them at another file.
    • Only design files are followed, within an agent's allowed folders, so a crafted drawing can't make the app read anything else.

    Sessions and undo

    • A drawing tab is an ordinary Session holding a drawing. Tabs, autosave, recovery, the crash journal and the file worker all carry over.
    • Undo is per file. A drawing's undo holds drawing steps only, and a drawing edit never evaluates a model. The tests count evaluations on every session to prove it.
    • One check in Session::execute refuses design commands in a drawing and drawing commands in a design, with a message saying what to do instead.
    • Each design has one session: its own tab when it's open, otherwise a hidden session the drawing holds. The hidden one opens from the model cache, so a design saved warm costs no evaluation.
    • A model edit made from the drawing (drawing.source.execute) runs in the design's session as an ordinary undo step there, and leaves a marker in the drawing's history. Drawing undo passes over the marker, so it never changes the design.
    • Saving a drawing also saves the designs it changed from inside the drawing, and lists every file it wrote.
    • Updated views are a cache, like the model cache: a drawing reopened after its design changed updates without asking to be saved when it closes.

    The commands so far

    • drawing.create, drawing.inspect, drawing.set and drawing.properties[.set/.remove] (the document.metadata rules).
    • drawing.sources, drawing.source.relink, drawing.source.locate (for this session only, used by the browser and crash replays) and drawing.source.remove.
    • drawing.source.execute.
    • doc.open, file.save and file.save_as, which now handle both kinds of file.

    Commands name their sheet and objects by id; the engine has no "active sheet". Bulk edits are list parameters in one undo step, and atomic batches use checkpoints, as elsewhere.

    The order

    1. One versioning rule for designs and drawings.
    2. The drawing record: sources, properties, units, content language and sheets, with one id counter.
    3. The drawing container.
    4. Drawing sessions, the command check and undo per file.
    5. Open, save and links.
    6. Relink, locate and remove.
    7. The cache of last results and its stamps.
    8. Model edits from a drawing.
    9. Recovery, autosave and crash reports.
    10. Drawing tabs in the app, with one session per open file.
    11. Drawings in the browser: OPFS, and "pick it once" for files on disk.
    12. Packing a drawing with its designs into a zip.

    Steps 1 to 9 need no UI.

    For anyone working nearby

    If anything here clashes with what you're building, tell me and let's fit the two together.

    Refs #860

  6. CamWight commented on Oct 22, 2026

    @CamWight
    ContributorAuthor

    @jyviko, after reading your comments on #2869 and #626, here's how the drawing storage plan above changes to follow them:

    • A plain JSON form from the start. A drawing opened from JSON is saved back as JSON, as Version-control-friendly designs: stable text form, semantic diff and merge #626 Phase 1 asks for designs. The container stays the default.
    • Deterministic output from format 1. Fixed key order and number format, and nothing that changes on every save. Save → open → save is tested byte for byte in both forms.
    • Records shaped for a per-object merge. Every object has an id, references are by id, and nothing derived is stored. What the views last showed stays in a cache that never enters the text form.
    • No embedded identity. A drawing's designs are paths, and inside one repository the commit is the set of versions it shows.

    Two questions:

    1. Drawings are a new format with no old files to migrate, so they could start with feat: Random string IDs in design files for git merges and non-Rust JSON tools #1017's collision-free ids instead of a next_id counter. Would you like that, and in which form: random 64-bit numbers (Version-control-friendly designs: stable text form, semantic diff and merge #626) or short random strings (feat: Random string IDs in design files for git merges and non-Rust JSON tools #1017)? We'd put the allocator in doc, so designs use the same one when feat: Random string IDs in design files for git merges and non-Rust JSON tools #1017 lands.
    2. Issuing a drawing revision would add its row to the revision table, since it's printed on the sheet. In a repository it would also be a protected jj tag on the commit, with the row naming the tag. Is that the release you have in mind?
  7. amolinari-autotex commented on Oct 23, 2026

    @amolinari-autotex
    Contributor

    Thanks for considering the PDM integration in your plan. We’d be happy to help. Which part would be most useful for us to take on, and who should we coordinate with to avoid overlapping work?

  8. selun3 commented on Oct 23, 2026

    @selun3
    Collaborator

    @amolinari-autotex, thank you for offering to help, and for being willing to adapt the PDM work to the jj/Git direction in #2869.

    From the Drawing side, a useful first contribution could be a small integration contract and acceptance fixture for a versioned drawing and its source designs. @CamWight is coordinating the drawing records, links and sessions here; @jyviko is the right person to confirm the versioning semantics. We can keep the Drawing-specific agreement in this issue and link it from the revised PDM RFC.

    A concrete starting case would be one drawing and two source designs in the same repository:

    1. List the drawing's source paths without loading/evaluating the models.
    2. Open a historical repository revision and resolve the drawing and both designs from that revision.
    3. Cover Save As/Relink, a missing source and a changed source; cached views must retain an honest current/out-of-date/lost state.
    4. Check that the deterministic text form contains the authored records and references, while derived view caches stay out of the versioned text.

    That would help settle the boundary before adding a PDM-specific API. The ID representation and how the printed revision row relates to a protected jj tag are still the questions above for @jyviko.

    @CamWight, would that be a useful first slice for them alongside your storage work? Once you agree the boundary, it can have its own child issue and draft PR. Thanks again — this is a good point to bring the Drawing and version-history work together.

  9. fpoussin commented on Oct 23, 2026

    @fpoussin

    Hi,
    I'll take drawing into account for the cloud saves implementation. Integration should remain simple.
    Thanks for letting me know!

  10. CamWight commented on Oct 23, 2026

    @CamWight
    ContributorAuthor

    Thanks @amolinari-autotex, and @0xlillith for the suggestion. Yes, that would be a useful first slice.

    I'd suggest the shape #4962 uses for W23a: the four cases 0xlillith lists (one drawing and two designs in one repository), written as an acceptance document with small fixture designs, in a child issue and a draft PR into drawings. They become executable tests as storage steps 4 to 7 land, and we'll turn them into tests then.

    The drawing record (step 2) is what I'm building now. I'll post its fields here first, so the cases can name real ones. How ids and a printed revision relate to the repository waits for @jyviko's answers to the two questions above.

    @fpoussin, thank you, that's great.

  11. amolinari-autotex commented on Oct 23, 2026

    @amolinari-autotex
    Contributor

    Thanks, that sounds like a useful first contribution. Once you post the drawing-record fields, we can prepare the acceptance document and small fixtures for the four cases, following #4962/W23a, with a child issue and a draft PR targeting drawings.

    We'll leave storage implementation to the planned steps and keep the ID/revision expectations pending jyviko's clarification.

  12. CamWight commented on Oct 23, 2026

    @CamWight
    ContributorAuthor

    The drawing record's fields (K2), for the acceptance cases

    @amolinari-autotex, here are the fields as planned, so the cases can name them. Nothing is built yet, so names may still change in review. I'll post any change here.

    A drawing (drawing.json inside the container, or a plain JSON file):

    • format: solidcraft-drawing/N, plus format_pending for changes not yet folded into a release;
    • name;
    • sources: the designs it draws, each {id, path}. The path is relative to the drawing's folder and /-separated, the rule linked designs use. What a design was when last seen isn't stored here;
    • properties: the drawing's own properties, under the document.metadata rules;
    • units: follow the model, or a fixed length unit;
    • language: the content language, a BCP 47 tag;
    • sheets: each {id, name, sheet, border, documents, excluded}. That's the paper size and orientation, a copy of its border profile, the component it documents ({source, component}), and what its parts list leaves out.

    Rules:

    • Ids: every object has an id, and every reference is by id. The ids will be collision-free; their form waits for @jyviko's answer above. A file with a reference that doesn't resolve is reported as damaged, never patched.
    • Nothing derived is stored. What the views last showed lives in the container's cache/, which never enters the text form.
    • The output is deterministic: fixed key order and number format. Save, open and save again gives identical bytes, in both forms.
    • Caps: 1 to 1,000 sheets, at most 64 sources, names up to 256 bytes, paths up to 4,096 bytes.
    • Later record kinds (views, annotations, tables, title blocks) each add themselves through one pending format file.

    How the four cases meet them:

    1. A drawing's source paths can be listed without loading any design. The container step (K3) adds a reader for just that.
    2. A past revision resolves the drawing and both designs from one commit, through the relative paths.
    3. Save As rebases the paths, and Relink replaces a source's path. A view of a missing source shows as lost, and one of a changed source as out of date; neither is ever shown as current.
    4. The text form holds sources, sheets and their ids, and nothing from cache/.
  13. CamWight commented on Oct 23, 2026

    @CamWight
    ContributorAuthor

    One addition to the storage plan, from the Drawing workspace's canvas boundary (#5349): the drawing session prepares a sheet's scene on request. A prepared scene is one fixed result for a drawing and a sheet. It carries:

    • a version token that changes with everything that feeds it (sheet settings, source designs, styles, fonts);
    • the resources it needs, such as font data, kept with it.

    It reports empty, unavailable, pending, failed and stale apart, with a source's freshness given separately (the link states in #5449). The token comes from the update key planned for W14. A prepared scene is derived data: never a saved record or a file format of its own. No drawing command depends on an active sheet; each names its sheet.

  14. 104 remaining items

  15. CamWight commented on Nov 13, 2026

    @CamWight
    ContributorAuthor

    A case for C2 and C3 (the sheet cache in the file), found by the M2 checkpoint run we're adding under #4894 (W23). A deferred drawing that was current when it was saved opens again waiting for an update.

    Steps, by commands, on the milestone plate (W23a case 84, built by examples/acceptance/drawing_m2.json):

    1. Make the plate's drawing: a top view at 1:2, the views below and right of it, and three dimensions.
    2. drawing.set {"updates": "deferred"}, then drawing.update. The export lists nothing out of date.
    3. file.save.
    4. In a new session: doc.open, drawing.open, then drawing.status.

    Expected: the drawing opens as it was saved: current, with nothing waiting, as #12573 made it for a close and open within one session.

    Actual: {"held": true, "waiting": 3}. Until Update Drawing, the sheet has none of its views, as #12449's own run from a saved file showed ("the scene draws no view"). After drawing.update the files are byte for byte the ones from before the save, so nothing was wrong except the wait.

    Why: both halves are session state, and a new session starts with neither:

    What it means for the plan:

    • C3: "reopen unchanged draws 0 views" should include a deferred drawing. Opened unchanged, it shows its saved lines, nothing waits and it isn't held.
    • C2 writes only current lines. A deferred drawing that is held when it's saved (the model moved on, no update yet) would still open with an empty sheet, though the session showed its last lines. So for a deferred drawing, C2 could also write the lines it shows, marked stale. C3 then shows them held and out of date, as Drawings: a deferred drawing keeps its dimensions across a close, and lists them out of date (#12802) #12803 does within one session.
    • The checkpoint test checks today's reply at this step. Whichever of the two lands second updates it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in progressneeds-triage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions