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:
1 parent
38e0f656be
commit
cf6565d108
4 files changed
+12
-14
No files matched your search
@@ -25,7 +25,7 @@ import { requireBehavior, requireVariableOwner } from './require';
|
||||
|
||||
/**
|
||||
* The variable's default value is written to `props` as well. On a behavior a new variable starts
|
||||
* out kept between calls (#229).
|
||||
* at its default every call; "Keep" is switched on by hand (#229).
|
||||
*/
|
||||
export class AddVariableCommand implements Command {
|
||||
readonly label: string;
|
||||
@@ -47,14 +47,12 @@ export class AddVariableCommand implements Command {
|
||||
throw new CommandError(`Variable "${this.def.key}" already exists`);
|
||||
asset.variables.push(this.def);
|
||||
asset.props[this.def.key] = this.def.default;
|
||||
if (asset.type === 'behavior') setKeptVariable(asset, this.def.key, true);
|
||||
}
|
||||
|
||||
undo(project: Project): void {
|
||||
const asset = requireVariableOwner(project, this.assetId);
|
||||
asset.variables = asset.variables.filter((v) => v.key !== this.def.key);
|
||||
delete asset.props[this.def.key];
|
||||
if (asset.type === 'behavior') setKeptVariable(asset, this.def.key, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user