Agent Zero AI framework
InlineButtonConfirmations
Wabifocusc07bbba4da55
diff --git a/webui/components/modals/file-browser/file-browser-store.js b/webui/components/modals/file-browser/file-browser-store.jsindex 3764f7215..7825b37b0 100644--- a/webui/components/modals/file-browser/file-browser-store.js+++ b/webui/components/modals/file-browser/file-browser-store.js@@ -172,7 +172,6 @@ const model = {// --- File actions --------------------------------------------------------async deleteFile(file) {- if (!confirm(`Are you sure you want to delete ${file.name}?`)) return;try {const resp = await fetchApi("/delete_work_dir_file", {method: "POST",@@ -186,9 +185,9 @@ const model = {this.browser.entries = this.browser.entries.filter((e) => e.path !== file.path);- alert("File deleted successfully.");+ window.toastFrontendSuccess("File deleted successfully", "File Deleted");} else {- alert(`Error deleting file: ${await resp.text()}`);+ window.toastFrontendError(`Error deleting file: ${await resp.text()}`, "Delete Error");}} catch (e) {window.toastFrontendError(diff --git a/webui/components/modals/file-browser/file-browser.html b/webui/components/modals/file-browser/file-browser.htmlindex b9689fb53..0ccec66a6 100644--- a/webui/components/modals/file-browser/file-browser.html+++ b/webui/components/modals/file-browser/file-browser.html@@ -48,11 +48,11 @@<div class="file-size" x-text="$store.fileBrowser.formatFileSize(file.size)"></div><div class="file-date" x-text="$store.fileBrowser.formatDate(file.modified)"></div><div class="file-actions">- <button class="action-button download-button" @click.stop="$store.fileBrowser.downloadFile(file)">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.5 19.5"><path d="m.75,14.25v2.25c0,1.24,1.01,2.25,2.25,2.25h13.5c1.24,0,2.25-1.01,2.25-2.25v-2.25m-4.5-4.5l-4.5,4.5m0,0l-4.5-4.5m4.5,4.5V.75" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/></svg>+ <button class="btn-icon-action" @click.stop="$store.fileBrowser.downloadFile(file)" title="Download file">+ <span class="material-symbols-outlined">download</span></button>- <button class="delete-button" @click.stop="$store.fileBrowser.deleteFile(file)">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.03 22.53" fill="currentColor"><path d="m14.55,7.82H4.68L14.09,3.19c.83-.41,1.17-1.42.77-2.25-.41-.83-1.42-1.17-2.25-.77l-3.16,1.55-.15-.31c-.22-.44-.59-.76-1.05-.92-.46-.16-.96-.13-1.39.09l-2.08,1.02c-.9.44-1.28,1.54-.83,2.44l.15.31-3.16,1.55c-.83.41-1.17,1.42-.77,2.25.29.59.89.94,1.51.94.25,0,.5-.06.74-.17l.38-.19s.09.03.14.03h11.14v11.43c0,.76-.62,1.38-1.38,1.38h-.46v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-2.39v-11.28c0-.26-.21-.47-.47-.47s-.47.21-.47.47v11.28h-.46c-.76,0-1.38-.62-1.38-1.38v-9.9c0-.26-.21-.47-.47-.47s-.47.21-.47.47v9.9c0,1.28,1.04,2.32,2.32,2.32h8.55c1.28,0,2.32-1.04,2.32-2.32v-11.91c0-.26-.21-.47-.47-.47Z" stroke-width="0"/></svg>+ <button class="btn-icon-action" @click.stop="$confirmClick($event, () => $store.fileBrowser.deleteFile(file))" title="Delete file">+ <span class="material-symbols-outlined">delete</span></button></div></div>@@ -279,47 +279,12 @@.btn-upload:active {background-color: #2b309c;}- /* Delete Button Styles */- .delete-button {- background: none;- border: none;- color: var(--color-primary);- cursor: pointer;- width: 32px;- padding: 4px 8px;- border-radius: 4px;- transition: opacity 0.2s, background-color 0.2s;- }- .delete-button:hover {- color: #ff7878;- }- .delete-button:active {- opacity: 0.6;- }/* File Actions */.file-actions {display: flex;gap: var(--spacing-xs);}- .action-button {- background: none;- border: none;- cursor: pointer;- width: 32px;- padding: 6px 8px;- border-radius: 4px;- transition: background-color 0.2s;- }- .download-button {- color: var(--color-primary);- }- .download-button:hover {- background-color: var(--color-border);- }- .light-mode .download-button:hover {- background-color: #c6d4de;- }/* Responsive Design */@media (max-width: 768px) {.file-header,diff --git a/webui/components/settings/memory/memory-dashboard-store.js b/webui/components/settings/memory/memory-dashboard-store.jsindex bf246f5e8..fe8317370 100644--- a/webui/components/settings/memory/memory-dashboard-store.js+++ b/webui/components/settings/memory/memory-dashboard-store.js@@ -554,14 +554,6 @@ ${memory.content_full}},async deleteMemory(memory) {- if (- !confirm(- `Are you sure you want to delete this memory from ${memory.area}?`- )- ) {- return;- }-try {// Check if this is the memory currently being viewed in detail modalconst isViewingThisMemory =diff --git a/webui/components/settings/memory/memory-dashboard.html b/webui/components/settings/memory/memory-dashboard.htmlindex aaaeac15d..887f32117 100644--- a/webui/components/settings/memory/memory-dashboard.html+++ b/webui/components/settings/memory/memory-dashboard.html@@ -235,8 +235,8 @@<span class="material-symbols-outlined">content_copy</span></button>- <button class="btn btn-action delete"- @click="$store.memoryDashboardStore.deleteMemory(memory)"+ <button class="btn-icon-action"+ @click="$confirmClick($event, () => $store.memoryDashboardStore.deleteMemory(memory))"title="Delete Memory"><span class="material-symbols-outlined">delete</span></button>diff --git a/webui/components/settings/memory/memory-detail-modal.html b/webui/components/settings/memory/memory-detail-modal.htmlindex 0bd45ba4c..0905bff23 100644--- a/webui/components/settings/memory/memory-detail-modal.html+++ b/webui/components/settings/memory/memory-detail-modal.html@@ -35,7 +35,7 @@title="Edit Memory"><span class="material-symbols-outlined">edit_document</span></button>- <button class="btn btn-action-header delete danger" @click="$store.memoryDashboardStore.deleteMemory($store.memoryDashboardStore.detailMemory)"+ <button class="btn-icon-action" @click="$confirmClick($event, () => $store.memoryDashboardStore.deleteMemory($store.memoryDashboardStore.detailMemory))"title="Delete Memory"><span class="material-symbols-outlined">delete</span></button>diff --git a/webui/components/sidebar/chats/chats-list.html b/webui/components/sidebar/chats/chats-list.htmlindex 7a11ec98f..ab464d58f 100644--- a/webui/components/sidebar/chats/chats-list.html+++ b/webui/components/sidebar/chats/chats-list.html@@ -22,7 +22,9 @@<span class="chat-name" :title="context.name ? context.name : 'Chat #' + context.no"x-text="context.name ? context.name : 'Chat #' + context.no"></span></div>- <button class="edit-button" @click.stop="$store.chats.killChat(context.id)">X</button>+ <button class="btn-icon-action" title="Close chat" @click.stop="$confirmClick($event, () => $store.chats.killChat(context.id))">+ <span class="material-symbols-outlined">close</span>+ </button></div></li></template>@@ -110,28 +112,9 @@font-size: var(--font-size-small);}- .edit-button {+ .chat-container .btn-icon-action {flex-shrink: 0;margin-right: 8px;- background-color: transparent;- border: 1px solid var(--color-border);- border-radius: 0.1875rem;- color: var(--color-primary);- cursor: pointer;- padding: 0.125rem 0.5rem;- transition: all var(--transition-speed) ease-in-out;- width: 2rem;- height: 2rem;- }-- .edit-button:hover {- border-color: var(--color-primary);- background-color: #32455690;- }-- .edit-button:active {- background-color: #131a2090;- color: rgba(253, 253, 253, 0.35);}.empty-list-message {diff --git a/webui/components/sidebar/tasks/tasks-list.html b/webui/components/sidebar/tasks/tasks-list.htmlindex bf51bfabe..0344fb44f 100644--- a/webui/components/sidebar/tasks/tasks-list.html+++ b/webui/components/sidebar/tasks/tasks-list.html@@ -38,20 +38,20 @@<span class="scheduler-status-badge scheduler-status-badge-small":class="task.state ? `scheduler-status-${task.state}` : 'scheduler-status-idle'"x-text="task.state || 'idle'"></span>- <button class="edit-button"- @click.stop="$store.tasks.openDetail(task.id)"- title="View task details" style="margin-left: auto; margin-right: 5px;">- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 512 512" fill="var(--color-primary)" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M256 0c70.69 0 134.69 28.66 181.02 74.98C483.34 121.3 512 185.31 512 256c0 70.69-28.66 134.7-74.98 181.02C390.69 483.34 326.69 512 256 512c-70.69 0-134.69-28.66-181.02-74.98C28.66 390.69 0 326.69 0 256c0-70.69 28.66-134.69 74.98-181.02C121.31 28.66 185.31 0 256 0zm-9.96 161.03c0-4.28.76-8.26 2.27-11.91 1.5-3.63 3.77-6.94 6.79-9.91 3-2.95 6.29-5.2 9.84-6.7 3.57-1.5 7.41-2.28 11.52-2.28 4.12 0 7.96.78 11.49 2.27 3.54 1.51 6.78 3.76 9.75 6.73 2.95 2.97 5.16 6.26 6.64 9.91 1.49 3.63 2.22 7.61 2.22 11.89 0 4.17-.73 8.08-2.21 11.69-1.48 3.6-3.68 6.94-6.65 9.97-2.94 3.03-6.18 5.32-9.72 6.84-3.54 1.51-7.38 2.29-11.52 2.29-4.22 0-8.14-.76-11.75-2.26-3.58-1.51-6.86-3.79-9.83-6.79-2.94-3.02-5.16-6.34-6.63-9.97-1.48-3.62-2.21-7.54-2.21-11.77zm13.4 178.16c-1.11 3.97-3.35 11.76 3.3 11.76 1.44 0 3.27-.81 5.46-2.4 2.37-1.71 5.09-4.31 8.13-7.75 3.09-3.5 6.32-7.65 9.67-12.42 3.33-4.76 6.84-10.22 10.49-16.31.37-.65 1.23-.87 1.89-.48l12.36 9.18c.6.43.73 1.25.35 1.86-5.69 9.88-11.44 18.51-17.26 25.88-5.85 7.41-11.79 13.57-17.8 18.43l-.1.06c-6.02 4.88-12.19 8.55-18.51 11.01-17.58 6.81-45.36 5.7-53.32-14.83-5.02-12.96-.9-27.69 3.06-40.37l19.96-60.44c1.28-4.58 2.89-9.62 3.47-14.33.97-7.87-2.49-12.96-11.06-12.96h-17.45c-.76 0-1.38-.62-1.38-1.38l.08-.48 4.58-16.68c.16-.62.73-1.04 1.35-1.02l89.12-2.79c.76-.03 1.41.57 1.44 1.33l-.07.43-37.76 124.7zm158.3-244.93c-41.39-41.39-98.58-67-161.74-67-63.16 0-120.35 25.61-161.74 67-41.39 41.39-67 98.58-67 161.74 0 63.16 25.61 120.35 67 161.74 41.39 41.39 98.58 67 161.74 67 63.16 0 120.35-25.61 161.74-67 41.39-41.39 67-98.58 67-161.74 0-63.16-25.61-120.35-67-161.74z"/>- </svg>- </button>- <button class="edit-button" title="Clear task chat"- @click.stop="$store.tasks.reset(task.id)" style="margin-right: 5px;">- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 122.88 121.1" fill="var(--color-primary)" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M62.89,56.03c1.11-0.35,2.34-0.25,3.72,0.37l10.4,7.87c2.26,1.71,4.24,3.78,2.73,6.9 c-0.51,1.06-1.4,2.1-2.38,3.49l-0.53,0.75c-1.97,2.8-2.61,2-5.71,1.83c0.56,13.37,1.75,27.82-2.64,40.88 c-0.87,2.7-3.32,3.44-6.95,2.71l-6.1-2.03c4.11-6.14,6.16-13.85,6.44-22.89c-3.46,8.58-6.8,16.96-10.68,20.86l-6.28-2.08 c0.61-3.05,1.05-5.43,0.35-6.9l-4.07,4.24l-9.33-5.77c6.36-3.36,11.62-7.87,15.6-13.73c-6.69,5.01-12.76,8.1-18.14,8.99 c-2.75,0.83-4.49,0.35-5.16-1.53c-0.48-1.34-0.05-1.77,0.81-2.86c1.11-1.41,2.61-2.67,4.35-3.79c-3.13,1.1-4.64,0.95-6.37,1.51 c-4.9,1.59-9.94-1.86-8.26-6.9c1.07-3.23,3.54-3.09,6.67-4.07l5.42-1.69c-5.19,0.28-10.32,0.45-15.02-0.25 c-5.4-0.8-5.31-0.99-8.24-5.38c-3.94-5.91-6.25-11.45,2.52-9.16c16.73,3.18,33.56,5.34,51.25-0.98c-0.76-1.32-0.9-2.57-0.5-3.73 C57.37,60.94,61.13,56.58,62.89,56.03L62.89,56.03z M113.8,2.42L74.45,51.53c-4.71,6.68,3.2,11.91,8.39,5.64l39.2-49.27 C125.12,1.86,119.13-3.16,113.8,2.42L113.8,2.42z"/>- </svg>- </button>- <button class="edit-button" title="Delete task" @click.stop="$store.tasks.deleteTask(task.id)">X</button>+ <div class="task-actions">+ <button class="btn-icon-action"+ @click.stop="$store.tasks.openDetail(task.id)"+ title="View task details">+ <span class="material-symbols-outlined">info</span>+ </button>+ <button class="btn-icon-action" title="Clear task chat"+ @click.stop="$store.tasks.reset(task.id)">+ <span class="material-symbols-outlined">refresh</span>+ </button>+ <button class="btn-icon-action" title="Delete task" @click.stop="$confirmClick($event, () => $store.tasks.deleteTask(task.id))">+ <span class="material-symbols-outlined">close</span>+ </button>+ </div></div></div></div>@@ -138,6 +138,7 @@.light-mode .task-name:hover { background-color: rgba(0,0,0,0.05); }.task-info-line { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 2px; }+ .task-actions { display: flex; gap: 0.375rem; margin-left: auto; }.task-container {width: 100%;diff --git a/webui/css/buttons.css b/webui/css/buttons.cssindex 8836591fd..db8331488 100644--- a/webui/css/buttons.css+++ b/webui/css/buttons.css@@ -61,3 +61,51 @@padding-left: 0.75rem;padding-right: 0.75rem;}++/* Inline Confirmation State */+.confirming {+ border-color: var(--color-highlight) !important;+ background-color: var(--color-highlight) !important;+ color: #fff !important;+}++.confirming:hover {+ filter: brightness(1.1);+}++/* Standard icon-only action button for destructive actions */+.btn-icon-action {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ background: transparent;+ border: 1px solid var(--color-border);+ border-radius: 0.25rem;+ color: var(--color-primary);+ cursor: pointer;+ padding: 0.25rem;+ width: 1.75rem;+ height: 1.75rem;+ transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);+ flex-shrink: 0;+}++.btn-icon-action .material-symbols-outlined,+.btn-icon-action .material-icons-outlined {+ font-size: 1rem;+}++.btn-icon-action:hover {+ border-color: var(--color-primary);+ background-color: rgba(50, 69, 86, 0.56);+}++.btn-icon-action:active {+ background-color: rgba(19, 26, 32, 0.56);+ color: rgba(253, 253, 253, 0.35);+}++.btn-icon-action.danger:hover {+ border-color: #e57373;+ color: #e57373;+}diff --git a/webui/js/confirmClick.js b/webui/js/confirmClick.jsnew file mode 100644index 000000000..6e5f2cdf3--- /dev/null+++ b/webui/js/confirmClick.js@@ -0,0 +1,59 @@+// Inline button two-click confirmation for destructive actions.+// First click arms, second click confirms, timeout resets.++const CONFIRM_TIMEOUT = 2000;+const CONFIRM_CLASS = 'confirming';+const CONFIRM_ICON = 'check';++const buttonStates = new WeakMap();++// Handles inline two-click confirmation for a button.+export function confirmClick(event, action) {+ const button = event.currentTarget;+ if (!button) return;++ const state = buttonStates.get(button);++ if (state?.confirming) {+ clearTimeout(state.timeoutId);+ resetButton(button, state);+ buttonStates.delete(button);+ action();+ } else {+ const iconEl = button.querySelector('.material-symbols-outlined, .material-icons-outlined');+ const originalIcon = iconEl?.textContent?.trim();++ const newState = {+ confirming: true,+ originalIcon,+ timeoutId: setTimeout(() => {+ resetButton(button, newState);+ buttonStates.delete(button);+ }, CONFIRM_TIMEOUT)+ };++ buttonStates.set(button, newState);++ // Apply confirming state+ button.classList.add(CONFIRM_CLASS);+ if (iconEl) {+ iconEl.textContent = CONFIRM_ICON;+ }+ }+}++// Reset button to original state+function resetButton(button, state) {+ button.classList.remove(CONFIRM_CLASS);+ const iconEl = button.querySelector('.material-symbols-outlined, .material-icons-outlined');+ if (iconEl && state.originalIcon) {+ iconEl.textContent = state.originalIcon;+ }+}++// Register Alpine magic helper+export function registerAlpineMagic() {+ if (globalThis.Alpine) {+ Alpine.magic('confirmClick', () => confirmClick);+ }+}diff --git a/webui/js/initFw.js b/webui/js/initFw.jsindex c758b6d6c..f56ba15d3 100644--- a/webui/js/initFw.js+++ b/webui/js/initFw.js@@ -1,6 +1,7 @@import * as initializer from "./initializer.js";import * as _modals from "./modals.js";import * as _components from "./components.js";+import { registerAlpineMagic } from "./confirmClick.js";// initialize required elementsawait initializer.initialize();@@ -8,6 +9,9 @@ await initializer.initialize();// import alpine libraryawait import("../vendor/alpine/alpine.min.js");+// register $confirmClick magic helper for inline button confirmations+registerAlpineMagic();+// add x-destroy directive to alpineAlpine.directive("destroy",diff --git a/webui/js/scheduler.js b/webui/js/scheduler.jsindex 96cb548dd..63d5b65ba 100644--- a/webui/js/scheduler.js+++ b/webui/js/scheduler.js@@ -1090,11 +1090,6 @@ const fullComponentImplementation = function() {// Delete a taskasync deleteTask(taskId) {- // Confirm deletion- if (!confirm('Are you sure you want to delete this task? This action cannot be undone.')) {- return;- }-try {// if we delete selected context, switch to another first