Skip to content

Fix variable manipulation and serialization#8547

Open
ClementPasteau wants to merge 1 commit intomasterfrom
fix-field-prefilling
Open

Fix variable manipulation and serialization#8547
ClementPasteau wants to merge 1 commit intomasterfrom
fix-field-prefilling

Conversation

@ClementPasteau
Copy link
Copy Markdown
Collaborator

@ClementPasteau ClementPasteau commented Apr 28, 2026

Before:

Enregistrement.de.l.ecran.2026-04-28.a.10.17.09.mov

After:

Enregistrement.de.l.ecran.2026-04-28.a.10.27.23.mov

Multiple fixes:

  • boolean variable conditions initial value was "true" instead of "True"

    • it is now fixed so that when a new condition is added the default value
      is "True"
    • previous "true" were being read as "False" in the editor and the
      runtime, because != "True". This is kept as-is so no breaking change.
    • opening an instruction with "true" will now automatically convert it to
      "False" in the editor (normalize-on-load, not at serialization time).
  • When adding a condition "Boolean variable is true/false" after having
    manipulated a "Number variable = x" the instruction was being serialized as
    "variable/=" ("=" was being pre-populated from the previous instruction
    because of the relational operator instead of being reset). It means the
    JSON contained "=" on a boolean condition.

    • We now reset those parameters when changing the type, and pick the first
      valid operator for the new instruction type (e.g. "True" for boolean, "="
      for number/string)
    • previous "=" were being read as "False" in the editor and the runtime,
      because != "True". This is kept as-is so no breaking change.
    • opening an instruction with "=" where it's not a valid value will now
      automatically convert it to "False" in the editor
  • When editing a variable name inline (e.g. changing from var1 (number) to
    var2 (boolean)), the operator parameter was being corrected using the
    metadata of the old instruction type (captured when the inline editor
    opened), not the new one. This meant the reset picked operators from the
    wrong list — for example switching to a boolean variable could still end up
    with "=" in the JSON.

    • We now re-fetch the instruction metadata from the current instruction
      type at apply time, so the operator is always validated against the right
      list
  • handle changing a variable type either in the variable declaration (ex:
    switch number->boolean) or in the instruction itself (changing from
    var1(number) to var2(boolean))

    • This used to keep wrong parameters in the JSON (ex: "=", "True" where
      they don't belong)
    • It now automatically converts the parameters to what they're most likely
      to be with the new type
  • setupInstructionParameters now validates and corrects existing operator
    values, not just empty ones. Previously it only filled in a value when the
    parameter was empty, so a stale "startsWith" left on a NumberVariable
    condition (for example) would be silently kept. Now any value not in the
    valid set for that operator type is replaced with the first valid one.

@ClementPasteau ClementPasteau requested a review from 4ian as a code owner April 28, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant