Repository navigation
Description
Problem
The engine-side fix for #890 makes the Rust patch path (src/simlin-engine/src/patch.rs) preserve the caller's display spelling verbatim: upserts store the payload's name as-is, renames store the raw to string, and all lookup/matching remains canonicalization-based. But the patch payload is now authoritative for the display spelling -- and the TypeScript layer sends canonical idents in those payloads, so web-editor edits still erode display names.
Two mechanisms in the TS layer:
-
Deserializers discard the display spelling on read.
src/core/datamodel.tsstockFromJson/flowFromJson/auxFromJson/moduleFromJson(around lines 707 / 809 / 919 / 993) doident: canonicalize(json.name). The corresponding*ToJsonfunctions then serialize that canonical ident back asname(lines 736 / 840 / 943 / 1013).src/diagram/Editor.tsxhandleEquationChangebuilds upsert payloads viastockToJsonetc. (lines ~1700-1744), so every equation/documentation/units edit sends the canonical form as the variable's name. -
Renames canonicalize the target.
src/diagram/Editor.tsxline ~790 sendspayload: { from: oldIdent, to: canonicalize(newName) }, so even an explicit rename to "New Students" storesnew_students.
Net effect
For a model imported from Stella/XMILE, where the datamodel idents carry display names like Students or testing\nassymptomatic, any web-editor edit of a variable downgrades the stored ident to its canonical form (students, testing_assymptomatic). The web editor gets away with it visually because the diagram renders the VIEW element's name (src/diagram/drawing/common.ts displayName), but the <variables> block in exported XMILE degrades -- exactly the 2021 report in #82.
Why it matters
- Silent, incremental erosion: only edited variables lose their display names, so a model's presentation degrades one edit at a time.
- Exported XMILE mixes display-cased and canonical names in the
<variables>block, breaking downstream consumers that match by exact name (XMILE export from simlin: variable name to lowercase but not in equations #82's readsdr scenario). - It undoes the engine: patch UpsertVariable canonicalizes the variable ident in place, destroying the human-facing display name #890 engine fix for the web-editor surface: the engine now faithfully preserves whatever the client sends, and the client sends the wrong thing.
Components affected
src/core/datamodel.ts(*FromJson/*ToJson)src/diagram/Editor.tsx(handleEquationChange,handleRename)
Possible approaches
- Preserve the raw name in the TS Variable model: store
name(display spelling) alongsideident(canonical), have*FromJsonkeepjson.nameverbatim,*ToJsonemit the preserved name, andhandleRenamesend the rawnewName. Lookups/comparisons keep using the canonical ident. - Longer term: the dual-name datamodel design discussed in XMILE export from simlin: variable name to lowercase but not in equations #82, separating display name from canonical ident end-to-end so canonicalization can never be lossy.
Related
- XMILE export from simlin: variable name to lowercase but not in equations #82 -- the 2021 symptom report (XMILE export lowercases names in
<variables>but not equations); same single-field name/ident conflation. - engine: patch UpsertVariable canonicalizes the variable ident in place, destroying the human-facing display name #890 -- engine-side patch canonicalization, fixed on branch
conveyor-engine; this issue is the remaining client-side half.
Discovery context
Identified while fixing #890 on branch conveyor-engine: after making the engine preserve payload spelling verbatim, the TS client remains a source of canonical-only payloads.
Activity
engine: preserve display names through patch upserts and renames
engine: preserve display names through patch upserts and renames