Part of #79231. Related to #83441.
What problem does this address?
Removing a widget deletes its instance from the layout (packages/widget-dashboard/src/components/widget-layout-controls/widget-layout-controls.tsx:67-73).
Its attributes and size go with it: to get the widget back, you insert the type again and configure it from scratch.
The layout records nothing about what happened to an instance, so neither the inserter nor a host can tell a widget the user removed from one they never placed.
What is your proposed solution?
Give each instance a small record of what happened to it. DashboardWidget gains __meta with inserted (date, and who placed it: the user through the inserter, or the host) and removed (date); each key keeps only the last occurrence. A removed instance stays in the layout marked as removed.
The engine skips removed instances everywhere it reads the layout (rendering, policy requests, the insert request layout) and emits them in onLayoutChange, so a host stores the layout as it comes and needs no reconciliation of its own.
The first use is the inserter: a "Removed" group lists the removed instances of the current layout; restoring one clears removed and places it again with its previous attributes and width.
To keep the record small, we keep only the latest removed instance per type, and we drop a removed instance whose type is no longer registered after a grace period.
resized, moved, and other keys can join later when something reads them; the record grows only with a consumer.
Tasks
Part of #79231. Related to #83441.
What problem does this address?
Removing a widget deletes its instance from the layout (
packages/widget-dashboard/src/components/widget-layout-controls/widget-layout-controls.tsx:67-73).Its attributes and size go with it: to get the widget back, you insert the type again and configure it from scratch.
The layout records nothing about what happened to an instance, so neither the inserter nor a host can tell a widget the user removed from one they never placed.
What is your proposed solution?
Give each instance a small record of what happened to it.
DashboardWidgetgains__metawithinserted(date, and who placed it: the user through the inserter, or the host) andremoved(date); each key keeps only the last occurrence. A removed instance stays in the layout marked as removed.The engine skips removed instances everywhere it reads the layout (rendering, policy requests, the
insertrequest layout) and emits them inonLayoutChange, so a host stores the layout as it comes and needs no reconciliation of its own.The first use is the inserter: a "Removed" group lists the removed instances of the current layout; restoring one clears
removedand places it again with its previous attributes and width.To keep the record small, we keep only the latest removed instance per type, and we drop a removed instance whose type is no longer registered after a grace period.
resized,moved, and other keys can join later when something reads them; the record grows only with a consumer.Tasks
__metaonDashboardWidget, written on insert and remove; canonicalization, staging and the policy backstop preserve it.insertrequest layout; keep one per type; drop after the grace period.