Add "Undo" toast to recover recently deleted entities
Author: rohanakode490Created Sep 20, 2026Updated Sep 21, 2026
Labelscomponent:appstatus:approved
Problem to solve
Accidentally deleting an entity in Mockoon (such as a route with complex rules, a databucket, a callback, or a folder) currently results in immediate, unrecoverable data loss unless manually recreated.
Following the discussion on the global undo/redo proposal (#1395), a full document-style Ctrl+Z engine introduces significant complexity (race conditions in collaborative cloud sync, conflicts with browser-native text undo in input fields, and lossy inverse action tracking).
As agreed, a much cleaner, resilient, and non-intrusive solution is to introduce an "Undo" action in toast notifications when an entity is deleted.
Proposed solution
- Extend Toast Service & Model:
- Update the
Toastmodel to optionally accept an interactive action button:
export type ToastAction = {
label: string;
action: () => void;
};- Update
ToastsService.addToast()andapp.component.html(ngb-toast) to render the clickable action button alongside the message.
- Integrate with
EnvironmentsServiceDeletions: When an entity is deleted, trigger an undo toast with a callback that re-inserts the deleted entity:
- Routes:
removeRoute()$\rightarrow$ "Route {method} {endpoint} deleted."[Undo] - Route Responses:
removeRouteResponse()$\rightarrow$ "Response {label/status} deleted."[Undo] - Data Buckets:
removeDatabucket()$\rightarrow$ "Data bucket {name} deleted."[Undo] - Callbacks:
removeCallback()$\rightarrow$ "Callback {name} deleted."[Undo] - Folders:
removeFolder()$\rightarrow$ "Folder {name} deleted."[Undo]
- Restoration Behavior:
- Clicking [Undo] executes the callback, dispatching the respective
ADD_*action (e.g.addRouteAction) with the preserved entity data and position. - If the toast auto-dismisses (e.g. after 6–8 seconds) or is closed, the in-memory entity reference is naturally garbage collected.
Why this approach?
- Zero schema or migration changes: The
EnvironmentJSON data model remains completely untouched (no monorepo-wide major version bumps). - 100% Cloud-Sync friendly: Restoring simply dispatches standard
ADD_*actions, which existing WebSockets sync broadcasts to collaborators without any new sync payloads. - Zero shortcut conflicts: Leaves native browser and Ace editor
Ctrl+Ztext editing intact. - Lightweight: Leverages the existing
@ng-bootstrap/ng-bootstrap(ngb-toast) container already present inapp.component.html.
I will be working on the PR for this!
Source: mockoon/mockoon