#2362·mockoon

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

  1. Extend Toast Service & Model:
  • Update the Toast model to optionally accept an interactive action button:
bash
export type ToastAction = {
   label: string;
   action: () => void;
};
  • Update ToastsService.addToast() and app.component.html (ngb-toast) to render the clickable action button alongside the message.
  1. Integrate with EnvironmentsService Deletions: 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]
  1. 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 Environment JSON 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+Z text editing intact.
  • Lightweight: Leverages the existing @ng-bootstrap/ng-bootstrap (ngb-toast) container already present in app.component.html.

I will be working on the PR for this!