You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix first-use nested history defaults by requiring a complete source-independent configuration containing the history owner and using it to rebuild inactive compound and parallel ancestors.
Copy file name to clipboardExpand all lines: docs/agent-guide.md
+32-6Lines changed: 32 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,7 +228,8 @@ const States = Machine.defineStates({
228
228
})
229
229
```
230
230
231
-
Every history node needs a default parent snapshot for the first use:
231
+
Every history node needs a source-independent default for the first use. The
232
+
default is a complete root snapshot containing the history owner:
232
233
233
234
```ts
234
235
checkout: {
@@ -256,10 +257,35 @@ payment: {
256
257
}
257
258
```
258
259
259
-
A recorded nested history can rebuild inactive ancestors. A first-use fallback
260
-
cannot: it constructs the history node's direct parent snapshot, so it cannot
261
-
currently reconstruct values for inactive ancestors above that owner. Those
262
-
ancestors must already be active when an unrecorded nested history is targeted.
260
+
A nested default must include every ancestor above its owner and every region
261
+
of any parallel ancestor. The containing branch is checked statically, so an
262
+
unrelated root, a sibling compound branch, a direct-owner-only nested snapshot,
263
+
or an incomplete parallel configuration is rejected. A canonical nested
264
+
default looks like:
265
+
266
+
```ts
267
+
Workspace: {
268
+
history: {
269
+
resume: {
270
+
default: ({ target }) =>
271
+
target.App(
272
+
State.cases.App.make({ workspaceId: "default" }),
273
+
(app) =>
274
+
app.Workspace(
275
+
State.cases.Workspace.make({}),
276
+
(workspace) =>
277
+
workspace.Editing(State.cases.Editing.make({}))
278
+
)
279
+
)
280
+
}
281
+
}
282
+
}
283
+
```
284
+
285
+
On first use from an inactive root, this complete configuration is entered. If
286
+
a parallel ancestor is already active, unaffected active regions are retained.
287
+
Once a history record exists, shallow or deep recorded restoration wins over
288
+
the default.
263
289
264
290
The machine's readiness type tracks missing defaults and shallow initializers.
265
291
History is an overwriteable register, not a stack: restoration does not consume
@@ -273,7 +299,7 @@ prior effects, actors, and timers are not rewound.
273
299
|`target.local`| The destination is inside the nearest compound scope containing the source | The compound value, active ancestors, and unrelated parallel regions |
274
300
|`target.branch`| The destination is elsewhere under the active top-level root | Omitted current ancestor values and parallel regions |
275
301
|`target.full`| The destination may be under any top-level root | Nothing is inferred for a newly selected root; build its complete active snapshot |
276
-
|`target.history`| The destination is a declared history pseudo-state | Its parent's remembered configuration, or its default before the first capture; an unrecorded nested fallback requires ancestors above its owner to be active|
302
+
|`target.history`| The destination is a declared history pseudo-state | Its parent's remembered configuration, or a source-independent complete default containing that owner before the first capture|
277
303
278
304
Entering an inactive parallel state through `target.local` or `target.branch`
279
305
requires a complete callback with one selection per region. A parallel state
0 commit comments