Agent Zero AI framework
flat kvps in step detail modals
3clyp50c25815f752da
diff --git a/webui/components/modals/process-step-detail/process-step-detail.html b/webui/components/modals/process-step-detail/process-step-detail.htmlindex 483e3254e..9e25446c9 100644--- a/webui/components/modals/process-step-detail/process-step-detail.html+++ b/webui/components/modals/process-step-detail/process-step-detail.html@@ -60,12 +60,16 @@</div></template>- <!-- Generic KVPs for all types -->+ <!-- Flattened KVPs --><template x-if="$store.stepDetail.selectedStepForDetail?.kvps">- <div class="content-block">- <h4>Details</h4>- <div class="kvps-display"><template x-for="[key, value] in Object.entries($store.stepDetail.selectedStepForDetail?.kvps || {})" :key="key"><span class="kvp-line"><span class="kvp-key" x-text="$store.stepDetail.formatKey(key)"></span><span class="kvp-value" x-text="$store.stepDetail.formatValue(value)"></span></span></template></div>- <div class="step-action-buttons" data-segment="details"></div>+ <div class="kvp-boxes">+ <template x-for="[key, value] in Object.entries($store.stepDetail.flattenKvps($store.stepDetail.selectedStepForDetail?.kvps) || {})" :key="key">+ <div class="content-block kvp-box">+ <h4 x-text="key"></h4>+ <pre class="kvp-value-content" x-text="$store.stepDetail.formatFlatValue(value)"></pre>+ <div class="step-action-buttons kvp-box-actions" x-init="$store.stepDetail.renderKvpCopyButton($el, key, value)"></div>+ </div>+ </template></div></template>@@ -225,31 +229,22 @@word-break: break-word;}- .kvps-display {+ .kvp-boxes {display: flex;flex-direction: column;- gap: 0.25rem;- font-size: 0.9rem;- line-height: 1.5;- }-- .kvp-line {- display: block;- }-- .kvp-key {- color: var(--color-text-muted);- margin-right: 0.5rem;- }-- .kvp-key::after {- content: ':';+ gap: 1rem;}- .kvp-value {+ .kvp-value-content {color: var(--color-text);white-space: pre-wrap;word-break: break-word;+ margin: 0;+ font-size: 0.85rem;+ }++ .kvp-box-actions {+ margin-top: 0.5rem;}.step-action-buttons {diff --git a/webui/components/modals/process-step-detail/step-detail-store.js b/webui/components/modals/process-step-detail/step-detail-store.jsindex bcbb4598f..cc3618475 100644--- a/webui/components/modals/process-step-detail/step-detail-store.js+++ b/webui/components/modals/process-step-detail/step-detail-store.js@@ -22,22 +22,21 @@ const model = {renderSegmentButtons() {const step = this.selectedStepForDetail;- // heading- document.querySelector('[data-segment="heading"]')?.replaceChildren(- createActionButton("copy", "", () => copyToClipboard(this.cleanHeading(step.heading)))- );-- // details (kvps)- const kvpsText = Object.entries(step.kvps || {})- .map(([k, v]) => `${this.formatKey(k)}: ${this.formatValue(v)}`)- .join('\n');- document.querySelector('[data-segment="details"]')?.replaceChildren(- createActionButton("copy", "", () => copyToClipboard(kvpsText))- );+ [+ { segment: "heading", value: this.cleanHeading(step?.heading) },+ { segment: "content", value: step?.content ?? "" }+ ].forEach(({ segment, value }) => {+ document.querySelector(`[data-segment="${segment}"]`)?.replaceChildren(+ createActionButton("copy", "", () => copyToClipboard(value))+ );+ });+ },- // content- document.querySelector('[data-segment="content"]')?.replaceChildren(- createActionButton("copy", "", () => copyToClipboard(step.content))+ // render copy buttons for individual kvp boxes+ renderKvpCopyButton(container, key, value) {+ const copyText = this.formatFlatValue(value);+ container?.replaceChildren(+ createActionButton("copy", "", () => copyToClipboard(copyText)));},@@ -59,7 +58,8 @@ const model = {if (!step) return "";const lines = [];lines.push(`Type: ${step.type || "unknown"}`);- if (step.heading) lines.push(`Heading: ${step.heading}`);+ const heading = this.cleanHeading(step.heading);+ if (heading) lines.push(`Heading: ${heading}`);if (step.timestamp) {const date = new Date(parseFloat(step.timestamp) * 1000);lines.push(`Timestamp: ${date.toISOString()}`);@@ -68,9 +68,9 @@ const model = {if (step.kvps) {lines.push("");lines.push("--- Data ---");- for (const [key, value] of Object.entries(step.kvps)) {- const formattedValue = typeof value === "object" ? JSON.stringify(value, null, 2) : String(value);- lines.push(`${key}: ${formattedValue}`);+ const flattenedKvps = this.flattenKvps(step.kvps);+ for (const [key, value] of Object.entries(flattenedKvps)) {+ lines.push(this.buildKvpCopyText(key, value));}}if (step.content) {@@ -183,9 +183,9 @@ const model = {// Format value for display (handles objects)formatValue(value) {- if (value === null || value === undefined) return '';- if (typeof value === 'object') return JSON.stringify(value, null, 2);- return String(value);+ return value == null+ ? ''+ : (typeof value === 'object' ? JSON.stringify(value, null, 2) : String(value));},// Format key for display (title case)@@ -193,17 +193,33 @@ const model = {return key.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());},- // Clean text value (handle arrays, remove brackets)- cleanTextValue(value) {- if (Array.isArray(value)) {- return value- .filter(item => item && String(item).trim() && !/^[\[\]]$/.test(String(item).trim()))- .join('\n');- }- if (typeof value === 'object' && value !== null) {- return JSON.stringify(value, null, 2);- }- return String(value).replace(/^\s*[\[\]]\s*$/gm, '').trim();+ // flatten nested kvps into top-level entries+ flattenKvps(kvps, parentKey = "") {+ const isPlainObject = value => value && typeof value === "object" && !Array.isArray(value);+ return Object.entries(kvps || {}).reduce((acc, [key, value]) => {+ const fullKey = [parentKey, this.formatKey(key)].filter(Boolean).join(" / ");+ return {+ ...acc,+ ...(isPlainObject(value) ? this.flattenKvps(value, fullKey) : { [fullKey]: value })+ };+ }, {});+ },++ // format values+ formatFlatValue(value) {+ return Array.isArray(value)+ ? value+ .map(item => this.formatValue(item))+ .filter(item => item.trim())+ .join('\n')+ : this.formatValue(value);+ },++ // build copy text+ buildKvpCopyText(key, value) {+ const formattedValue = this.formatFlatValue(value);+ const separator = formattedValue.includes("\n") ? ":\n" : ": ";+ return `${key}${separator}${formattedValue}`;},// Clean heading by removing icon:// prefixes