Skip to content

diagram: editing a view drops Vensim sketch details needed for MDL export #811

Open

Description

@bpowers

Editing a view in the app replaces the whole view, and the replacement is built from JSON that lacks several Vensim sketch details.
Any view edit, even a pan or zoom, silently drops them, so a later MDL export of an imported Vensim model loses fidelity.
Simulation results are not affected.

What is dropped

  • Per-element Vensim sketch data (ViewElementCompat: width, height, flag bits) and flow label data
  • The view's Vensim sketch segments and links (StockFlow.sketch_compat)
  • The view font
  • The group "is an MDL view marker" flag (the engine's JSON has it; src/core/datamodel.ts ignores it)
  • The view name (the engine's JSON has it; datamodel.ts ignores it)

Example

Import a Vensim .mdl, move one variable, export to .mdl: element sizes and the sketch's segments and links come out as defaults.
Not reproduced end to end; traced from json.rs, where converting a JSON view to the datamodel sets every one of these fields to None.

Fix

Recommended: when UpsertView replaces an existing view, carry these fields over from the old view (per element, matched by uid, as apply_upsert_view already does to share unchanged elements).
The TypeScript side then never needs to know about Vensim sketch details.
Alternative: add every field to the JSON types and round-trip them through datamodel.ts; more surface to keep in sync.

Pointers

  • src/simlin-engine/src/patch.rs: apply_upsert_view
  • src/simlin-engine/src/json.rs: From<View> for datamodel::View and the view-element conversion
  • src/core/datamodel.ts: stockFlowViewToJson, groupViewElementFromJson
  • src/diagram/view-model-sync.ts: where edits become upsertView
  • mdl: saving loses a variable's custom sketch shape #402: custom sketch shapes lost on MDL round-trip

Activity

  1. added
    frontend
    compat
    bug
    on Oct 12, 2026
  2. changed the title [-]core: view-element fidelity fields dropped on view edits (ViewElementCompat, View.font, group MDL marker, View.name)[/-] [+]diagram: editing a view drops Vensim sketch details needed for MDL export[/+] on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcompatfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions