Skip to content

diagram: editing an arrayed variable's equation turns it into a scalar #1094

Done

Description

@bpowers

In the web editor, changing the equation of an arrayed variable replaces the array with one scalar equation.
No message is shown.
Editing only its units or notes is safe.

Example

A project with a dimension Region (North, South) and an apply-to-all auxiliary price[Region] = 10.
Its details panel shows

{apply-to-all:}
10

Change 10 to 12 and click the canvas.

  • Expected: price[Region] = 12.
  • Actual: price is a scalar whose equation is {apply-to-all:}12.

A variable with an equation per element is worse.
The panel shows { TODO: arrayed variable editing isn't supported yet}, and typing one space saves that text as the variable's scalar equation and discards every element's equation.

Why it matters

The web editor is the main way people use Simlin, and this loses their work silently.
Undo recovers it only within the session.
We found it by reading the code and reproduced it with the real editor and engine in a test; we know of no user report.

Fix

Send the engine's setEquation patch operation, which changes the text and keeps the dimensions, instead of re-sending the whole variable.
The engine has it, with setElementEquation for one element; the TypeScript types do not list either yet.
A day or two.
Stopgap: make the equation field read-only for arrayed variables, about an hour.

Pointers

  • src/diagram/Editor.tsx: equationChangeOp clears arrayedEquation whenever the equation text changed
  • src/diagram/VariableDetails.tsx: scalarEquationFor builds the text the panel shows
  • src/simlin-engine/src/patch_fields.rs: set_equation
  • src/engine/src/json-types.ts: the patch operations TypeScript knows

Activity

  1. added
    bug
    frontend
    on Nov 24, 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

    bugfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions