Skip to content

Agent Zero AI framework

ui: message queue polishing, scrollbars unified

frdel020822adfd44
diff --git a/webui/components/chat/attachments/inputPreview.html b/webui/components/chat/attachments/inputPreview.html
index 5effd1f8d..de57e6f1d 100644
--- a/webui/components/chat/attachments/inputPreview.html
+++ b/webui/components/chat/attachments/inputPreview.html
@@ -6,7 +6,7 @@
<div x-data>
<template x-if="$store.chatAttachments">
- <div x-show="$store.chatAttachments.hasAttachments" class="preview-section">
+ <div x-show="$store.chatAttachments.hasAttachments" class="preview-section scrollbar">
<template x-for="(attachment, index) in $store.chatAttachments.attachments" :key="index">
<div class="attachment-item"
:class="{'image-type': attachment.type === 'image', 'file-type': attachment.type === 'file'}">
diff --git a/webui/components/chat/input/input-store.js b/webui/components/chat/input/input-store.js
index 3a3cf5751..78f6ba545 100644
--- a/webui/components/chat/input/input-store.js
+++ b/webui/components/chat/input/input-store.js
@@ -16,7 +16,7 @@ const model = {
const running = chatTopStore?.running;
if (hasQueue && !hasInput) return "send-all";
- if (running && hasInput) return "queue";
+ if ((running || hasQueue) && hasInput) return "queue";
return "send";
},
diff --git a/webui/components/chat/message-queue/message-queue-store.js b/webui/components/chat/message-queue/message-queue-store.js
index 49cc7b506..2426c073b 100644
--- a/webui/components/chat/message-queue/message-queue-store.js
+++ b/webui/components/chat/message-queue/message-queue-store.js
@@ -1,11 +1,31 @@
import { createStore } from "/js/AlpineStore.js";
import { store as navStore } from "/components/chat/navigation/chat-navigation-store.js";
import * as api from "/js/api.js";
+import { toastFrontendInfo, NotificationPriority } from "/components/notifications/notification-store.js";
+import { sleep } from "/js/sleep.js";
const model = {
items: [],
pendingItems: [], // Local pending items (uploading to queue)
+ _getQueueScrollerEl() {
+ return document.querySelector(".queue-preview .queue-items");
+ },
+
+ scrollQueueToBottom() {
+ const el = this._getQueueScrollerEl();
+ if (!el) return;
+
+ const scroll = () => {
+ el.scrollTop = el.scrollHeight;
+ };
+
+ requestAnimationFrame(() => {
+ scroll();
+ requestAnimationFrame(scroll);
+ });
+ },
+
get hasQueue() {
return this.items.length > 0 || this.pendingItems.length > 0;
},
@@ -34,6 +54,7 @@ const model = {
// Add to pending immediately for UI feedback
this.pendingItems = [...this.pendingItems, pendingItem];
+ this.scrollQueueToBottom();
try {
let filenames = [];
@@ -49,14 +70,16 @@ const model = {
}
}
const response = await api.callJsonApi("/message_queue_add", { context, text, attachments: filenames });
-
- // Remove from pending (poll will add the confirmed item)
- this.pendingItems = this.pendingItems.filter(p => p.id !== tempId);
+
+ const serverId = response?.item_id;
+ if (serverId) {
+ this.pendingItems = this.pendingItems.map((p) =>
+ p.id === tempId ? { ...p, serverId } : p,
+ );
+ }
return response?.ok || false;
} catch (e) {
console.error("Failed to queue message:", e);
- // Remove from pending on error
- this.pendingItems = this.pendingItems.filter(p => p.id !== tempId);
return false;
}
},
@@ -94,6 +117,24 @@ const model = {
async sendAll() {
const context = globalThis.getContext?.();
if (!context || !this.hasQueue) return;
+
+ // check for pending uploads and notify user
+ if (this.pendingItems.length > 0) {
+ await sleep(1000);
+ if (this.pendingItems.length > 0) {
+ toastFrontendInfo(
+ "There are pending uploads in the queue. You can wait for them to finish or remove them.",
+ "Pending uploads",
+ 3,
+ "pending-uploads",
+ NotificationPriority.NORMAL,
+ true,
+ );
+ return;
+ }
+ }
+
+ if (!this.hasQueue) return;
try {
navStore.scrollToBottom();
await api.callJsonApi("/message_queue_send", { context, send_all: true });
@@ -104,6 +145,18 @@ const model = {
updateFromPoll(queue) {
this.items = queue || [];
+
+ if (this.pendingItems.length > 0) {
+ const hasPendingWithServerId = this.pendingItems.some((p) => p.serverId);
+ if (hasPendingWithServerId) {
+ const serverIds = new Set(this.items.map((i) => i.id).filter(Boolean));
+ this.pendingItems = this.pendingItems.filter((p) => {
+ if (!p.serverId) return true;
+ return !serverIds.has(p.serverId);
+ });
+ }
+ }
+ // this.scrollQueueToBottom();
},
getAttachmentUrl(filename) {
diff --git a/webui/components/chat/message-queue/message-queue.html b/webui/components/chat/message-queue/message-queue.html
index e4f78494d..397a328ed 100644
--- a/webui/components/chat/message-queue/message-queue.html
+++ b/webui/components/chat/message-queue/message-queue.html
@@ -233,7 +233,7 @@
}
.queue-item-pending .queue-item-actions {
- display: none;
+ visibility: hidden !important;
}
.queue-item-pending-icon {
diff --git a/webui/css/messages.css b/webui/css/messages.css
index 9710fcd0a..3396c0f5a 100644
--- a/webui/css/messages.css
+++ b/webui/css/messages.css
@@ -16,34 +16,6 @@
padding-bottom: 4rem !important;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
- scrollbar-width: thin;
- scrollbar-color: #555 transparent;
-}
-
-/* Scrollbar styling for Firefox */
-#chat-history::-webkit-scrollbar {
- width: 5px;
-}
-
-#chat-history::-webkit-scrollbar-track {
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
- border-radius: 3px;
-}
-
-#chat-history::-webkit-scrollbar-thumb {
- border-radius: 3px;
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
- background-color: #555;
- -webkit-transition: background-color var(--transition-speed) ease-in-out;
- transition: background-color var(--transition-speed) ease-in-out;
-}
-
-#chat-history::-webkit-scrollbar-thumb:hover {
- background-color: #666;
-}
-
-#chat-history::-webkit-scrollbar-thumb:active {
- background-color: #888;
}
/* Message Styles */
diff --git a/webui/index.css b/webui/index.css
index 475e97170..3339d3e53 100644
--- a/webui/index.css
+++ b/webui/index.css
@@ -1561,4 +1561,55 @@ nav ul li a img {
.display-none{
display: none !important;
+}
+
+body * {
+ scrollbar-width: thin;
+ scrollbar-color: #555 transparent;
+}
+
+body *::-webkit-scrollbar {
+ width: 5px;
+}
+
+body *::-webkit-scrollbar-track {
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
+ border-radius: 3px;
+}
+
+body *::-webkit-scrollbar-thumb {
+ border-radius: 3px;
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
+ background-color: #555;
+ -webkit-transition: background-color var(--transition-speed) ease-in-out;
+ transition: background-color var(--transition-speed) ease-in-out;
+}
+
+body *::-webkit-scrollbar-thumb:hover {
+ background-color: #666;
+}
+
+body *::-webkit-scrollbar-thumb:active {
+ background-color: #888;
+}
+
+.light-mode * {
+ scrollbar-color: #b7b7b7 transparent;
+}
+
+.light-mode *::-webkit-scrollbar-track {
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.12);
+}
+
+.light-mode *::-webkit-scrollbar-thumb {
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.12);
+ background-color: #b7b7b7;
+}
+
+.light-mode *::-webkit-scrollbar-thumb:hover {
+ background-color: #9f9f9f;
+}
+
+.light-mode *::-webkit-scrollbar-thumb:active {
+ background-color: #8a8a8a;
}
\ No newline at end of file
diff --git a/webui/index.js b/webui/index.js
index 5e0ee4ef2..a9c70362e 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -54,13 +54,14 @@ export async function sendMessage() {
if (message || hasAttachments) {
// Check if agent is busy - queue instead of sending
- if (chatTopStore.running) {
- const success = await messageQueueStore.addToQueue(message, attachmentsWithUrls);
- if (success) {
+ if (chatTopStore.running || messageQueueStore.hasQueue) {
+ const success = messageQueueStore.addToQueue(message, attachmentsWithUrls);
+ // no await for the queue
+ // if (success) {
chatInputEl.value = "";
attachmentsStore.clearAttachments();
adjustTextareaHeight();
- }
+ // }
return;
}
diff --git a/webui/js/messages.js b/webui/js/messages.js
index 74f3558b0..61b74431d 100644
--- a/webui/js/messages.js
+++ b/webui/js/messages.js
@@ -336,8 +336,7 @@ function drawProcessStep({
stepDetail,
".process-step-detail-scroll",
"div",
- "process-step-detail-scroll",
- );
+ "process-step-detail-scroll" );
// set click handlers
setupProcessStepHandlers(step, stepHeader);