Skip to content

Agent Zero AI framework

Render icon markers in composer progress

Alessandro82280950ea9e
diff --git a/webui/components/chat/input/chat-bar-input.html b/webui/components/chat/input/chat-bar-input.html
index e1b24e589..cc1ef162a 100644
--- a/webui/components/chat/input/chat-bar-input.html
+++ b/webui/components/chat/input/chat-bar-input.html
@@ -44,6 +44,14 @@
@keydown.down="$store.chatInput.historyNext($event)"
@input="$store.chatInput.adjustTextareaHeight()"
x-model="$store.chatInput.message"></textarea>
+ <div
+ id="chat-input-progress-placeholder"
+ x-show="$store.chatInput.showProgressPlaceholder"
+ x-html="$store.chatInput.progressPlaceholderHtml"
+ :class="{ 'progress-active': $store.chatInput.progressActive }"
+ aria-hidden="true"
+ style="display: none;"
+ ></div>
<button id="expand-button" @click="$store.fullScreenInputModal.openModal()" aria-label="Expand input">
<span class="material-symbols-outlined" aria-hidden="true">open_in_full</span>
</button>
@@ -172,6 +180,36 @@
border-color: color-mix(in srgb, var(--color-highlight) 20%, transparent);
outline-color: color-mix(in srgb, var(--color-highlight) 15%, transparent);
}
+ #chat-input-progress-placeholder {
+ position: absolute;
+ top: calc(6px + 0.48rem);
+ left: calc(6px + var(--spacing-sm));
+ right: 46px;
+ color: var(--color-text-muted);
+ opacity: 0.7;
+ font-family: "Roboto Mono", monospace;
+ font-size: 0.9rem;
+ line-height: 1.45;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ pointer-events: none;
+ display: flex;
+ align-items: center;
+ gap: 0.35rem;
+ }
+ #chat-input-progress-placeholder.progress-active {
+ animation: placeholder-pulse 2s ease-in-out infinite;
+ }
+ #chat-input-progress-placeholder .chat-input-progress-cue {
+ color: var(--color-text-muted);
+ }
+ #chat-input-progress-placeholder .chat-input-progress-icon {
+ font-size: 1.15rem;
+ line-height: 1;
+ color: var(--color-highlight);
+ vertical-align: -0.18rem;
+ }
#expand-button {
position: absolute;
diff --git a/webui/components/chat/input/input-store.js b/webui/components/chat/input/input-store.js
index 1f9889eb4..cc860420e 100644
--- a/webui/components/chat/input/input-store.js
+++ b/webui/components/chat/input/input-store.js
@@ -5,6 +5,46 @@ import { store as messageQueueStore } from "/components/chat/message-queue/messa
import { store as attachmentsStore } from "/components/chat/attachments/attachmentsStore.js";
import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
+const ICON_MARKER_RE = /icon:\/\/([a-zA-Z0-9_]+)(\[(?:\\.|[^\]])*\])?/g;
+
+function escapeHTML(value) {
+ return String(value ?? "")
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/"/g, "&quot;")
+ .replace(/'/g, "&#039;");
+}
+
+function unescapeIconTooltip(block) {
+ if (!block) return "";
+ return block
+ .slice(1, -1)
+ .replace(/\\\[/g, "[")
+ .replace(/\\\]/g, "]")
+ .replace(/\\\\/g, "\\");
+}
+
+function convertIconMarkersToHtml(value) {
+ const text = String(value ?? "");
+ let html = "";
+ let lastIndex = 0;
+
+ text.replace(ICON_MARKER_RE, (match, iconName, tooltipBlock, offset) => {
+ html += escapeHTML(text.slice(lastIndex, offset));
+ const tooltip = unescapeIconTooltip(tooltipBlock) || iconName;
+ html += (
+ `<span class="icon material-symbols-outlined chat-input-progress-icon" ` +
+ `title="${escapeHTML(tooltip)}">${escapeHTML(iconName)}</span>`
+ );
+ lastIndex = offset + match.length;
+ return match;
+ });
+
+ html += escapeHTML(text.slice(lastIndex));
+ return html;
+}
+
const model = {
paused: false,
message: "",
@@ -38,13 +78,25 @@ const model = {
get inputPlaceholder() {
const state = this._getSendState();
if (state === "all") return "Press Enter to send queued messages";
- // Show progress as ghost text when agent is working and input is empty
- if (this.progressText && !this.message) {
- return "|> " + this.progressText;
- }
+ if (this.showProgressPlaceholder) return "";
return "Type your message here...";
},
+ get showProgressPlaceholder() {
+ return (
+ this._getSendState() !== "all" &&
+ !!this.progressText &&
+ !this.message
+ );
+ },
+
+ get progressPlaceholderHtml() {
+ return (
+ `<span class="chat-input-progress-cue">|&gt;</span> ` +
+ convertIconMarkersToHtml(this.progressText)
+ );
+ },
+
// Computed: send button icon type
get sendButtonIcon() {
const state = this._getSendState();