Agent Zero AI framework
action buttons
frdel41c2bc2f74c2
diff --git a/webui/components/messages/action-buttons/simple-action-buttons.css b/webui/components/messages/action-buttons/simple-action-buttons.cssindex 707236d91..91a5e810d 100644--- a/webui/components/messages/action-buttons/simple-action-buttons.css+++ b/webui/components/messages/action-buttons/simple-action-buttons.css@@ -1,52 +1,55 @@/* Simplified Action Buttons - Keeping the Great Look & Feel */-/* Main action buttons container - matches original positioning */+/* Main action buttons container - precise positioning */.action-buttons {- position: sticky;- top: var(--spacing-sm);+ position: absolute;+ top: 0.3em;right: 0;- display: flex;- align-items: center;- gap: var(--spacing-xs);- opacity: 0;+ display: none;+ flex-direction: row;+ gap: 0;+ background: var(--color-panel);+ border: 1px solid var(--color-border);+ border-radius: 6px;transition: opacity var(--transition-speed) ease-in-out;z-index: 10;- align-self: flex-start;- margin-left: auto;- margin-top: var(--spacing-sm);- margin-right: var(--spacing-xs);+ overflow: hidden;}-/* Individual action button - exact same styling as original */+/* Individual action button - precise hit area */.action-button {- position: relative;display: flex;align-items: center;justify-content: center;- width: 32px;- height: 32px;- background: var(--color-panel);- border: 1px solid var(--color-border);- border-radius: 6px;+ width: 26px;+ height: 26px;+ background: transparent;+ border: none;cursor: pointer;- transition: all var(--transition-speed) ease-in-out;+ transition: background-color var(--transition-speed) ease-in-out;color: var(--color-text);padding: 0;- font-size: 16px;+ font-size: 14px;opacity: 0.7;+ margin: 0;+}++.action-button:first-child {+ border-radius: 5px 0 0 5px;+}++.action-button:last-child {+ border-radius: 0 5px 5px 0;}.action-button:hover {opacity: 1;background: var(--color-background);- border-color: var(--color-primary);- transform: translateY(-1px);- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);}.action-button:active {- transform: translateY(0);- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);}/* Material icons - same as original */@@ -96,14 +99,15 @@.msg-content:hover .action-buttons,.kvps-row:hover .action-buttons,.message-text:hover .action-buttons {- opacity: 1;+ display: flex;+ animation: fadeInAfterDelay 0.3s ease-in-out;+ animation-delay: 0.3s;+ animation-fill-mode: forwards;+ opacity: 0;}-/* Ensure message containers are positioned for sticky children */-.msg-content,-.kvps-row,-.message-text {- position: relative;- display: flex;- flex-direction: column;-}\ No newline at end of file+/* Animation to fade in action buttons after delay */+@keyframes fadeInAfterDelay {+ 0% { opacity: 0; }+ 100% { opacity: 1; }+}diff --git a/webui/components/messages/action-buttons/simple-action-buttons.js b/webui/components/messages/action-buttons/simple-action-buttons.jsindex 6ee61834c..cc0f2b838 100644--- a/webui/components/messages/action-buttons/simple-action-buttons.js+++ b/webui/components/messages/action-buttons/simple-action-buttons.js@@ -3,121 +3,118 @@ import { store as speechStore } from "/components/chat/speech/speech-store.js";// Extract text content from different message typesfunction getTextContent(element) {- if (element.classList.contains("kvps-row")) {- return element.querySelector(".kvps-val")?.innerText || "";- } else if (element.classList.contains("message-text")) {- return element.querySelector("pre")?.innerText || element.querySelector("span")?.innerText || "";- } else {- return element.querySelector("span")?.innerText || "";- }+ if (element.classList.contains("kvps-row")) {+ return element.querySelector(".kvps-val")?.innerText || "";+ } else if (element.classList.contains("message-text")) {+ return (+ element.querySelector("pre")?.innerText ||+ element.querySelector("span")?.innerText ||+ ""+ );+ } else {+ return element.querySelector("span")?.innerText || "";+ }}// Create and add action buttons to elementexport function addActionButtonsToElement(element) {- // Skip if buttons already exist- if (element.querySelector(".action-buttons")) return;-- // Create container with same styling as original- const container = document.createElement("div");- container.className = "action-buttons";-- // Copy button - matches original design- const copyBtn = document.createElement("button");- copyBtn.className = "action-button copy-action";- copyBtn.setAttribute("aria-label", "Copy text");- copyBtn.innerHTML = '<span class="material-symbols-outlined">content_copy</span>';-- copyBtn.onclick = async (e) => {- e.stopPropagation();- const text = getTextContent(element);- const icon = copyBtn.querySelector(".material-symbols-outlined");-- try {- // Try modern clipboard API- if (navigator.clipboard && window.isSecureContext) {- await navigator.clipboard.writeText(text);- } else {- // Fallback for local dev- const textarea = document.createElement("textarea");- textarea.value = text;- textarea.style.position = "fixed";- textarea.style.left = "-999999px";- document.body.appendChild(textarea);- textarea.select();- document.execCommand("copy");- document.body.removeChild(textarea);- }-- // Visual feedback - matches original- icon.textContent = "check";- copyBtn.classList.add("success");- setTimeout(() => {- icon.textContent = "content_copy";- copyBtn.classList.remove("success");- }, 2000);-- } catch (err) {- console.error("Copy failed:", err);- icon.textContent = "error";- copyBtn.classList.add("error");- setTimeout(() => {- icon.textContent = "content_copy";- copyBtn.classList.remove("error");- }, 2000);- }- };-- // Speak button - matches original design- const speakBtn = document.createElement("button");- speakBtn.className = "action-button speak-action";- speakBtn.setAttribute("aria-label", "Speak text");- speakBtn.innerHTML = '<span class="material-symbols-outlined">volume_up</span>';-- speakBtn.onclick = async (e) => {- e.stopPropagation();- const text = getTextContent(element);- const icon = speakBtn.querySelector(".material-symbols-outlined");-- if (!text || text.trim().length === 0) return;-- try {- // Check if already speaking and stop it- if (speechStore.isSpeaking) {- if (speechStore.stop) speechStore.stop();- else speechSynthesis.cancel();- return;- }-- // Visual feedback - matches original- speakBtn.classList.add("speaking");- icon.textContent = "stop_circle";-- // Use speech store if available, otherwise browser TTS- if (speechStore?.speak) {- const cleanedText = speechStore.cleanText ? speechStore.cleanText(text) : text;- await speechStore.speak(cleanedText);- } else {- const utterance = new SpeechSynthesisUtterance(text);- utterance.lang = 'en-US';- utterance.onend = () => {- icon.textContent = "volume_up";- speakBtn.classList.remove("speaking");- };- speechSynthesis.speak(utterance);- return; // Don't reset immediately for browser TTS- }-- // Reset for speech store- icon.textContent = "volume_up";- speakBtn.classList.remove("speaking");-- } catch (err) {- console.error("Speech failed:", err);- icon.textContent = "volume_up";- speakBtn.classList.remove("speaking");- }- };-- container.append(copyBtn, speakBtn);- element.appendChild(container);-}\ No newline at end of file+ // Skip if buttons already exist+ if (element.querySelector(".action-buttons")) return;++ // Create container with same styling as original+ const container = document.createElement("div");+ container.className = "action-buttons";++ // Copy button - matches original design+ const copyBtn = document.createElement("button");+ copyBtn.className = "action-button copy-action";+ copyBtn.setAttribute("aria-label", "Copy text");+ copyBtn.innerHTML =+ '<span class="material-symbols-outlined">content_copy</span>';++ copyBtn.onclick = async (e) => {+ e.stopPropagation();++ // Check if the button container is still fading in (opacity < 0.5)+ if (parseFloat(window.getComputedStyle(container).opacity) < 0.5) return; // Don't proceed if still fading in++ const text = getTextContent(element);+ const icon = copyBtn.querySelector(".material-symbols-outlined");++ try {+ // Try modern clipboard API+ if (navigator.clipboard && window.isSecureContext) {+ await navigator.clipboard.writeText(text);+ } else {+ // Fallback for local dev+ const textarea = document.createElement("textarea");+ textarea.value = text;+ textarea.style.position = "fixed";+ textarea.style.left = "-999999px";+ document.body.appendChild(textarea);+ textarea.select();+ document.execCommand("copy");+ document.body.removeChild(textarea);+ }++ // Visual feedback+ icon.textContent = "check";+ copyBtn.classList.add("success");+ setTimeout(() => {+ icon.textContent = "content_copy";+ copyBtn.classList.remove("success");+ }, 2000);+ } catch (err) {+ console.error("Copy failed:", err);+ icon.textContent = "error";+ copyBtn.classList.add("error");+ setTimeout(() => {+ icon.textContent = "content_copy";+ copyBtn.classList.remove("error");+ }, 2000);+ }+ };++ // Speak button - matches original design+ const speakBtn = document.createElement("button");+ speakBtn.className = "action-button speak-action";+ speakBtn.setAttribute("aria-label", "Speak text");+ speakBtn.innerHTML =+ '<span class="material-symbols-outlined">volume_up</span>';++ speakBtn.onclick = async (e) => {+ e.stopPropagation();++ // Check if the button container is still fading in (opacity < 0.5)+ if (parseFloat(window.getComputedStyle(container).opacity) < 0.5) return; // Don't proceed if still fading in++ const text = getTextContent(element);+ const icon = speakBtn.querySelector(".material-symbols-outlined");++ if (!text || text.trim().length === 0) return;++ try {+ // Visual feedback+ icon.textContent = "check";+ speakBtn.classList.add("success");+ setTimeout(() => {+ icon.textContent = "volume_up";+ speakBtn.classList.remove("success");+ }, 2000);++ // Use speech store+ await speechStore.speak(text);+ } catch (err) {+ console.error("Speech failed:", err);+ icon.textContent = "error";+ speakBtn.classList.add("error");+ setTimeout(() => {+ icon.textContent = "volume_up";+ speakBtn.classList.remove("error");+ }, 2000);+ }+ };++ container.append(copyBtn, speakBtn);+ element.appendChild(container);+}diff --git a/webui/css/messages.css b/webui/css/messages.cssindex c731112dd..a1178f4ea 100644--- a/webui/css/messages.css+++ b/webui/css/messages.css@@ -1,5 +1,6 @@/* Chat History */#chat-history {+ position: relative;display: -webkit-flex;display: flex;flex-direction: column;@@ -79,20 +80,25 @@.message-user {background-color: #4a4a4a;/* border-bottom-right-radius: var(--spacing-xxs); */- min-width: 195px;+ /* min-width: 195px; */text-align: end;}.message-user > div {padding-top: var(--spacing-xs);- font-family: "Roboto Mono", monospace;+ /* font-family: "Roboto Mono", monospace; */font-optical-sizing: auto;-webkit-font-optical-sizing: auto;- font-size: var(--font-size-small);+ font-size: var(--font-size-smaller);}-.message-user .message-text{+.message-user .message-text {text-align: start;+ font-family: var(--font-family-main);+}++.message-user .message-text pre {+ font-family: var(--font-family-main);}.message-ai {@@ -207,6 +213,7 @@border-radius: 0.5em;margin-top: 0.5em;padding: 0.3em;+ font-family: var(--font-family-code);}/* Agent and AI Info */@@ -227,6 +234,10 @@.kvps-val pre {white-space: pre-wrap; /* keep \n, collapse no spaces, allow wrapping */word-break: break-word; /* optional – forces really long “words” to break */+ font-family: var(--font-family-code);+ font-optical-sizing: auto;+ -webkit-font-optical-sizing: auto;+ font-size: 0.75rem;}.msg-kvps th,diff --git a/webui/index.css b/webui/index.cssindex e337a4798..dabec04cc 100644--- a/webui/index.css+++ b/webui/index.css@@ -60,6 +60,10 @@--font-size-normal: 1rem;--font-size-large: 1.2rem;+ /* Font families */+ --font-family-main: "Rubik", Arial, Helvetica, sans-serif;+ --font-family-code: "Roboto Mono", monospace;+/* Other variables */--border-radius: 1.125rem;--transition-speed: 0.3s;@@ -88,7 +92,7 @@ body,html {background-color: var(--color-background);color: var(--color-text);- font-family: "Rubik", Arial, Helvetica, sans-serif;+ font-family: var(--font-family-main);width: 100%;height: 100%;min-width: 320px !important;@@ -464,13 +468,6 @@ h4 {user-select: all;}-pre {- font-family: "Roboto Mono", monospace;- font-optical-sizing: auto;- -webkit-font-optical-sizing: auto;- font-size: 0.75rem;-}-/* Logo Container */#logo-container {@@ -1605,18 +1602,18 @@ input:checked + .slider:before {flex-shrink: 0; /* prevents SVG from shrinking */}- .copy-button {+ /* .copy-button {display: none !important;- }+ } */- .msg-content span,+ /* .msg-content span,.kvps-val,.message-text span {cursor: pointer;position: relative;- }+ } */- .msg-thoughts span::after,+ /* .msg-thoughts span::after,.msg-content span::after,.kvps-val::after,.message-text::after {@@ -1634,14 +1631,14 @@ input:checked + .slider:before {border: none;border-radius: 5px;color: inherit;- }+ } */- .msg-thoughts span.copied::after,+ /* .msg-thoughts span.copied::after,.msg-content span.copied::after,.kvps-val.copied::after,.message-text.copied::after {opacity: 1;- }+ } */}@media (min-width: 768px) {diff --git a/webui/js/messages.js b/webui/js/messages.jsindex 7fcf21443..11882e82d 100644--- a/webui/js/messages.js+++ b/webui/js/messages.js@@ -242,11 +242,6 @@ export function _drawMessage(if (!spanElement) {spanElement = document.createElement("span");preElement.appendChild(spanElement);-- // Add click handler for small screens (only once)- spanElement.addEventListener("click", () => {- copyText(spanElement.textContent, spanElement);- });}// reapply scroll position or autoscroll@@ -429,11 +424,6 @@ export function drawMessageUser(spanElement.innerHTML = escapeHTML(content);textDiv.appendChild(spanElement);- // Add click handler- textDiv.addEventListener("click", () => {- copyText(content, textDiv);- });-addActionButtonsToElement(textDiv);messageDiv.appendChild(textDiv);}@@ -735,12 +725,7 @@ function drawKvps(container, kvps, latex) {span.innerHTML = convertHTML(value);pre.appendChild(span);tdiv.appendChild(pre);- addCopyButtonToElement(row);-- // Add click handler- span.addEventListener("click", () => {- copyText(span.textContent, span);- });+ addActionButtonsToElement(row);// KaTeX rendering for markdownif (latex) {@@ -861,11 +846,6 @@ function drawKvpsIncremental(container, kvps, latex) {addActionButtonsToElement(row);}- // Add click handler- span.addEventListener("click", () => {- copyText(span.textContent, span);- });-// KaTeX rendering for markdownif (latex) {span.querySelectorAll("latex").forEach((element) => {@@ -909,18 +889,6 @@ function convertImageTags(content) {return updatedContent;}-async function copyText(text, element) {- try {- await navigator.clipboard.writeText(text);- element.classList.add("copied");- setTimeout(() => {- element.classList.remove("copied");- }, 2000);- } catch (err) {- console.error("Failed to copy text:", err);- }-}-function convertHTML(str) {if (typeof str !== "string") str = JSON.stringify(str, null, 2);