Start new behavior variables with Keep switched off

Keep is a choice the author makes per variable. Switching it on for
every new variable meant most behaviors carried state across runs that
nobody asked for, and the toggle had to be turned off by hand.

- AddVariableCommand no longer adds a new variable to keptVariables.
  Keep is only switched on by hand.
- Existing projects are unchanged. Their keptVariables stay as saved.
- The comment in Asset.ts describes the new default.
- The counter fixture in keep-state.test.ts now keeps count
  explicitly instead of relying on the old default.

Tests:
- ./check.sh: 2706 tests, CHECK EXIT 0
- e2e 1, 6, 19: ALL PASSED, 172 checks
- 19c-ii expects [] after adding, then ["var1"], [] and ["var1"]
  after undo, all clicked with the real mouse
- Before the fixtures were adjusted, 8 unit tests failed on the new
  default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-28 12:02:40 +02:00
1 parent 38e0f656be
commit cf6565d108
4 files changed
+12 -14

No files matched your search

+6 -6
View File
@@ -129,7 +129,7 @@ export async function nestedBehavior(t) {
await shot('37-nested-behavior');
// 19c-ii. Keep (#229) is a switch on each variable of the called behavior, not on the node: a new
// variable starts kept, a click on its Keep button lets it go, and undo keeps it again.
// variable starts unkept, a click on its Keep button keeps it, and undo lets it go again.
const kept = async () => JSON.stringify((await asset('nb-double')).keptVariables ?? []);
const nodeKeys = Object.keys((await asset('nb-caller')).graph.nodes.find((n) => n.id === 'nb-call').params);
await t.select({ kind: 'asset', assetId: 'nb-double' });
@@ -147,13 +147,13 @@ export async function nestedBehavior(t) {
await undo();
await undo();
check(
'a variable has a Keep switch: on when added, off by a click, on by the next, off after undo',
'a variable has a Keep switch: off when added, on by a click, off by the next, on after undo',
!nodeKeys.includes('keepState') &&
keptAdded === '["var1"]' &&
keptAdded === '[]' &&
Boolean(keepButton) &&
keptClicked === '[]' &&
keptReclicked === '["var1"]' &&
keptUndone === '[]' &&
keptClicked === '["var1"]' &&
keptReclicked === '[]' &&
keptUndone === '["var1"]' &&
(await kept()) === '[]',
`node=${nodeKeys} added=${keptAdded} button=${JSON.stringify(keepButton)} clicked=${keptClicked} reclicked=${keptReclicked} undone=${keptUndone} after=${await kept()}`,
);