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

+4 -4
View File
@@ -36,11 +36,11 @@ import {
/**
* A behavior that counts its calls in `count` and hands the new count out as `out1`. `steps`
* counts the same way but is switched off, so it shows what an unkept variable does meanwhile.
* counts the same way but is left off, so it shows what an unkept variable does meanwhile.
*/
function counter(fixture: ProjectFixture): BehaviorAsset {
const callee = makeBehavior(fixture, 'Counter', ['count', 'steps']);
fixture.stack.execute(new SetVariableKeptCommand(callee.id, 'steps', false));
fixture.stack.execute(new SetVariableKeptCommand(callee.id, 'count', true));
const edit = graphEditor(fixture, callee);
const start = edit.addNode(BEHAVIOR_START);
const end = edit.addNode(BEHAVIOR_END);
@@ -105,10 +105,10 @@ function threeCalls(fixture: ProjectFixture, callee: BehaviorAsset): unknown[][]
}
describe('Keep on a behavior variable (#229)', () => {
it('starts on for a variable added to a behavior, and off on a Variables asset', () => {
it('starts off for a variable added to a behavior, and on a Variables asset', () => {
const fixture = makeProject();
const behavior = makeBehavior(fixture, 'B', ['count']);
expect(behavior.keptVariables).toEqual(['count']);
expect('keptVariables' in behavior).toBe(false);
const shared = new CreateAssetCommand('variables', 'Shared');
fixture.stack.execute(shared);
fixture.stack.execute(new AddVariableCommand(shared.asset.id, 'score', 'number'));