apply method

bool apply(
  1. Map<String, Map<String, Object?>> byShell
)

Records selections and asks for a rebuild. Returns whether anything moved.

A shell's map is replaced rather than merged. What arrives is the full state for that shell: the host holds selections in the address, and an axis on its default is written there as nothing at all, so an absent name is an instruction to forget rather than an absence of instruction. A null value says the same thing explicitly, and both put an axis back to the default the shell wrote.

Merging was right when the host kept its own store and sent deltas, and it is what made a top bar look stuck: choosing the default removed the name from the payload, nothing here removed it from _selected, and the shell went on rebuilding with the old choice.

Shells not named at all are untouched, which is what lets the host push everything it knows up front and have the right values already in hand when a shell first builds.

Implementation

bool apply(Map<String, Map<String, Object?>> byShell) {
  var changed = false;
  for (var MapEntry(key: shellId, value: selections) in byShell.entries) {
    var next = {
      for (var MapEntry(key: name, value: selection) in selections.entries)
        name: ?selection,
    };
    if (mapEquals(_selected[shellId], next)) continue;
    _selected[shellId] = next;
    changed = true;
  }
  if (changed) revision.value++;
  return changed;
}