feat: rebuild reactivity state from store after replay

Add `rebuildReactivityFromStore` to synchronize local reactivity
state with the hydrated variable store. This ensures tag activations
are correctly tracked following a reducer replay.

Also remove the unused `invalidateCompletions` function.
This commit is contained in:
2026-07-13 10:34:44 +08:00
parent 6f01a29723
commit 3137970b97
4 changed files with 26 additions and 7 deletions
+21
View File
@@ -167,6 +167,27 @@ export function setBase(key: string, value: string): void {
baseValues.set(key, value);
}
/**
* Rebuild local reactivity state (baseValues, activeMods, sourceActivations)
* from the hydrated stream variable store. Must be called after replayReducers
* so that tag activations are correctly tracked for subsequent cascade
* computations.
*/
export function rebuildReactivityFromStore(variables: VariableStore): void {
if (!tagModMap) return;
for (const [key, value] of Object.entries(variables)) {
if (!baseValues.has(key)) {
baseValues.set(key, value);
}
const tag = isTagValue(value);
if (tag && !sourceActivations.has(key)) {
activateTagFromSource(key, tag, variables);
}
}
}
/**
* Compute cascade effects after a variable change.
*