From 30e1879ac233764dacae3d777a5f122e03f3eee1 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 16 Jul 2026 09:45:45 -0400 Subject: [PATCH] fix: deleteWithUndo uses _reloadAfterAction() instead of manual tree manipulation Replaced fragile _removeFromTree() + displayTree spread (which had Alpine reactivity issues) with a clean _reloadAfterAction() call that reloads the tree from the API. This is the same approach used by doDelete() and doRename(), which work reliably. _reloadAfterAction also triggers the sidebar refresh via window.appState.refreshSidebarTree(). --- app/templates/local_workspace.html | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html index fb502af..5c8fdc5 100644 --- a/app/templates/local_workspace.html +++ b/app/templates/local_workspace.html @@ -1209,23 +1209,16 @@ window._wsInitData = (function() { this.undoItemId = node.db_id || node.id; this.undoMessage = 'Deleted "' + (node.name || 'item') + '"'; this.undoVisible = true; - // Soft-delete: actually delete after timeout + // Delete via API var r = await fetch('/api/local-workspace/items/' + this.undoItemId, { method:'DELETE' }); if (!r.ok) { this.undoVisible = false; return; } - // Remove from tree immediately - this._removeFromTree(this.tree, this.undoItemId); - if (!this.searchQuery && !this.filterType && !this.sortBy) this.displayTree = [...this.tree]; - else if (this.sortBy) this.doSort(); - else this.doFilter(); - // Auto-dismiss + permanent after 5s + // Reload from API for reliability (sidebar refresh handled by _reloadAfterAction) + this._reloadAfterAction(); + // Auto-dismiss undo banner after 5s this.undoTimeout = setTimeout(function() { self.undoVisible = false; self.undoItemId = null; }, 5000); - // Directly refresh sidebar tree - if (window.appState && window.appState.refreshSidebarTree) { - window.appState.refreshSidebarTree(); - } }, undoDelete() { if (this.undoTimeout) clearTimeout(this.undoTimeout);