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>
The first version of #229 put a Keep state switch on the Run behavior
node. The user wanted it where the variable is declared instead. Whether
a value lives on belongs to the variable, not to every call site.
- The node switch keepState is gone again. RunBehavior, CallResult and
nested.ts are back to what they were before #229.
- BehaviorAsset.keptVariables lists the kept names. It lives on the
asset and not in PropertyDef, because that is the schema of every
inspector row.
- A variable added from now on starts with Keep on. Variables in
existing projects start with Keep off, so old projects run unchanged.
- SetVariableKeptCommand flips the switch as one undo step. Add, remove
and rename carry the list along. Loading drops names that are not
declared.
- The interpreter keeps only the listed variables, per Run behavior
node and per object as before. The others start at their defaults.
- Local state machines in a called behavior start empty on every call
again, as before #229. Global and scene machines are unchanged.
- The inspector shows a Keep button in each variable row of a behavior.
Its state is part of the asset signature, so a click redraws the row.
Without that the button kept its old look until the inspector was
reopened.
Found: the project Garden of Sacrifices still has keepState = true on
the call Player -> Character Movement. It is ignored now. Direction
there predates the switch, so Keep is off until set by hand.
Tests:
- ./check.sh: 163 files, 2392 tests, CHECK EXIT 0 (before 2388)
- tests/core/keep-state.test.ts rewritten, 15 tests
- e2e 19: ALL PASSED, 35 checks. 19c-ii now clicks the Keep button
of a new variable: on when added, off by a click, on again, off
after undo.
- Counter-checks, each fails its own test: keep list ignored (2),
states kept (1), new variable not kept (8), rename drops the list
(1), no Keep button (e2e 19c-ii).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Run behavior call started with fresh variables every time, so a
nested behavior could not count, remember or keep a local state
machine across calls. A new "Keep state" switch on the node lets the
callee resume where its last call left off. It is off by default, so
existing projects run unchanged.
- RunBehavior gets the boolean parameter keepState and its node
description explains it.
- GraphInterpreter keeps the state in keptCalls, keyed by the call
path, the chain of Run behavior nodes. Two nodes calling the same
behavior each keep their own state.
- One interpreter exists per behavior instance, so every object gets
its own state without further code.
- Local state machines of the callee are kept like its variables.
- resumedVariables() matches kept values against today's
declarations. A new variable starts at its default, a removed one
drops out, and one whose kind changed starts over.
- The kept state lives as long as the object in the run. It is not
written to save games.
Limit: a callee input named keepState collides with the switch. The
same already holds for the name behavior, so it is not caught.
Tests:
- ./check.sh: 163 files, 2388 tests, CHECK EXIT 0 (before 2377)
- 10 new unit tests in tests/core/keep-state.test.ts and 1 new
node catalog case.
- e2e 19: ALL PASSED, 35 checks, with the new check 19c-ii for the
checkbox, its click and undo.
- Counter probes: ignoring keepState fails 5 tests, state per
behavior instead of per node fails 1, dropping the outer path
fails 1, skipping the kind check fails 1, and without the node
parameter the e2e check fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>