When you have several « retrieve last state » actions and use them in other steps, deleting one of the « retrieve last state » actions sometimes causes a shift in the numbering
I had to go through my previous votes again for this one ^^
It’s true that for a long scene it’s quickly annoying if you cut out a part.
Instead of propagating, why not have a field to give the variable a name so there are no more issues — it would be fixed by us?
@Prof_Techno not a fan of this option, it’s an additional configuration that doesn’t really make sense.
That said, it’s true that up until now we used a variable name that is specific to its position in the scene; nothing would prevent generating a variable name unrelated to the position in the scene.
mutmut
January 31, 2025, 11:27am
5
I would lean towards a visible name for the front-end as it is now (it’s very handy for finding) and a UID (random?) for the back-end, and Gladys would rely on the UID for links (that might already be the case).
However, for the front-end, it would be good if the numbering were rebuilt when there is a deletion or an addition.
Anyway, visually I wasn’t suggesting changing the current behavior; the idea is that nothing changes.
I edited this old request to add the to-be-processed label, and perhaps a devt with AI could be undertaken…
Hi everyone!
This topic is now in development .
A PR has been opened to propagate the renumbering of scene variables when an action is deleted in a group:
master ← claude/scene-variable-renumbering-4o6dvr
ouvert 09:40AM - 28 Aug 26 UTC
### Description
In the scene editor, the references to scene variables (e.g. `{… {0.1.last_value}}`) are position-based. The renumbering was already propagated when an action **group** is inserted, deleted, moved or reordered — but not when a single action is deleted **inside** a group ("at the same time" actions), nor when a condition is deleted inside an if/while block: the following actions of the group shift one index down, and every reference to their variables in the rest of the scene became stale, forcing the user to fix each step by hand.
`deleteAction` now reuses the exact same mechanism as group deletion:
- the sibling actions which follow the deleted one produce `prevPath → newPath` replacements (`0.2 → 0.1`, …), built from the smallest index up so a path is never rewritten twice;
- the variables map is rebuilt: the variables declared by the deleted action are dropped (including the ones nested in its if/then/else branches — they were previously left behind), and the variables of the shifted actions are renamed (including nested ones, which were previously not renamed at all);
- `replaceVariablePathsInActions` rewrites every reference to a renamed variable in the whole scene (texts, evaluate values, condition variable selectors, nested branches).
The now-unused `updatePathAfterDeletion` helper is removed.
The logic was validated against the real helper functions with simulations covering: deleting the middle of 3 parallel "get last state" actions, chained index shifts (no double rewrite), a shifted sibling if/then/else block with nested variables and references, deleting a block that declares nested variables, deleting a condition inside an `if` list, and 2-digit indexes (segment-boundary matching).
## Forum
Forum: ``https://community.gladysassistant.com/t/scene-propager-la-renumerotation-des-variables-recuperees-quand-lune-delles-est-supprimee``/9343
### Checklist
- [x] Tests pass: server untouched (front-only change); Cypress scene suite has no coverage of variable renumbering (unchanged)
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier` on the changed file)
- [x] No undocumented breaking change
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01VTBWxzxbVWRGtveU28WuP8
---
_Generated by [Claude Code](https://claude.ai/code/session_01VTBWxzxbVWRGtveU28WuP8)_
Feel free to follow the PR, test (optional, especially for small requests) and give your feedback here if needed.