cleanup(#1014): remove is_manager from ContainerView, add manager_name to StateSnapshot

This commit is contained in:
damocles 2026-06-03 16:24:13 +02:00 committed by mara
commit 6feab54882
3 changed files with 18 additions and 14 deletions

View file

@ -169,6 +169,13 @@ window.marked = marked;
if (containersState.delete(ev.name)) renderContainersFromState();
}
// Logical name of the manager agent. Populated from `s.manager_name`
// on snapshot load so chip lists don't hardcode the manager name.
let managerNameState = 'ruth';
function syncManagerNameFromSnapshot(s) {
if (s.manager_name) managerNameState = s.manager_name;
}
// Derived tombstones + meta_inputs. Both are emitted as full
// snapshots (not diffs) — the lists are tiny and recomputing
// avoids ordering races between a same-tick destroy + purge.
@ -2586,14 +2593,12 @@ window.marked = marked;
// one place. Returns the wrapping `<label class="schedule-field">`
// ready to append to the form.
function buildTargetChips({ idPrefix, fieldName, checked, extraNames = [] }) {
// Derive the manager's actual name from live state rather than
// hardcoding it — surface it first so it always appears before agents.
const managerContainer = Array.from(containersState.values()).find((c) => c.is_manager);
const managerName = managerContainer?.name;
// Surface manager first so it always appears before non-manager agents.
const managerName = containersState.has(managerNameState) ? managerNameState : null;
const candidates = ['operator'];
if (managerName) candidates.push(managerName);
const containerNames = Array.from(containersState.values())
.filter((c) => !c.is_manager)
.filter((c) => c.name !== managerNameState)
.map((c) => c.name)
.filter((n) => n !== 'operator')
.sort();
@ -2898,10 +2903,9 @@ window.marked = marked;
const out = [];
const push = (n) => { if (!seen.has(n)) { seen.add(n); out.push(n); } };
push('operator');
const managerContainer = Array.from(containersState.values()).find((c) => c.is_manager);
if (managerContainer) push(managerContainer.name);
if (containersState.has(managerNameState)) push(managerNameState);
const containerNames = Array.from(containersState.values())
.filter((c) => !c.is_manager)
.filter((c) => c.name !== managerNameState)
.map((c) => c.name)
.filter((n) => n !== 'operator')
.sort();
@ -3470,6 +3474,7 @@ window.marked = marked;
// `transientsState` + `containersState`, not from `s.*`).
syncTransientsFromSnapshot(s);
syncContainersFromSnapshot(s);
syncManagerNameFromSnapshot(s);
syncTombstonesFromSnapshot(s);
syncMetaInputsFromSnapshot(s);
syncRebuildQueueFromSnapshot(s);