SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
show warning when we have stringified json output
Forhad Hosainf4970095a6db
diff --git a/packages/app/src/builder-ui/debugger.ts b/packages/app/src/builder-ui/debugger.tsindex 3605f66c..5bbc5f0e 100644--- a/packages/app/src/builder-ui/debugger.ts+++ b/packages/app/src/builder-ui/debugger.ts@@ -169,7 +169,7 @@ function toggleSwitch(on: boolean) {updateInspectButtonIcon(inspectButton, true);} else {// Reset the components state before toggling the debug switch- resetComponentsState({ resetPinned: true });+ resetComponentsState({ resetDebugMessages: true, resetPinned: true });// debugMenu.classList.add('hidden');switcherText.textContent = 'Debug Off';debugSwitcher.classList.remove('active');@@ -1325,6 +1325,56 @@ async function previewHandler(event: Event) {}}+/**+ * Checks if the output content is a stringified JSON+ * @param outputContent - The output content to check+ * @returns True if the output is a string that starts with '{' and ends with '}'+ */+function isStringifiedJSON(outputContent: any): boolean {+ if (typeof outputContent !== 'string') {+ return false;+ }+ const trimmed = outputContent.trim();+ return trimmed.startsWith('{') && trimmed.endsWith('}');+}++/**+ * Checks if this is a default output endpoint (not a mapped output like Response.id)+ * @param outputEndpoint - The output endpoint element to check+ * @returns True if this is a default output (no dots or brackets in name)+ */+function isDefaultOutput(outputEndpoint: HTMLElement): boolean {+ const outputName = outputEndpoint.getAttribute('smt-name') || '';+ const outputExpression = outputEndpoint.getAttribute('smt-expression') || '';+ // A default output has no dots or brackets in its name/expression+ return !/[.\[\]]/.test(outputName) && !/[.\[\]]/.test(outputExpression);+}++/**+ * Checks if the component has mapped outputs (output endpoints with expressions like Response.id)+ * @param outputEndpoint - The current output endpoint element+ * @returns True if the component has other output endpoints with mapped expressions+ */+function hasMappedOutputs(outputEndpoint: HTMLElement): boolean {+ const componentElement = outputEndpoint.closest('.component');+ if (!componentElement) {+ return false;+ }++ // Get all output endpoints in the component+ const allOutputEndpoints = componentElement.querySelectorAll('.smyth.output-endpoint');++ // Check if any output endpoint has an expression (contains dots or brackets)+ for (const endpoint of allOutputEndpoints) {+ const expression = endpoint.getAttribute('smt-expression') || endpoint.getAttribute('smt-name');+ if (expression && /[.\[\]]/.test(expression)) {+ return true;+ }+ }++ return false;+}+function showOutputInfo(outputEndpoint, outputContent, compName?) {//console.log('showOutputInfo', outputContent);let div = outputEndpoint.querySelector('.dbg-element.dbg-output');@@ -1345,7 +1395,21 @@ function showOutputInfo(outputEndpoint, outputContent, compName?) {? getFormattedContent(outputContent, compName): outputContent + '';- div.innerHTML = `<button class="pin button primary"><span class="mif-pin icon"></span></button>${formattedContent}`;+ // Check if we should show the stringified JSON warning in the output window+ const isDefault = isDefaultOutput(outputEndpoint);+ const isStringified = isStringifiedJSON(outputContent);+ const hasMapped = hasMappedOutputs(outputEndpoint);+ const shouldShowWarning = isDefault && isStringified && hasMapped;++ // Build the warning message HTML if needed+ const warningMessage = shouldShowWarning+ ? `<div class="dbg-json-warning-message">+ <span class="dbg-json-warning-icon">!</span>+ <span class="dbg-json-warning-text">Stringified JSON detected - mapped outputs won't work</span>+ </div>`+ : '';++ div.innerHTML = `<button class="pin button primary"><span class="mif-pin icon"></span></button>${warningMessage}<span class="dbg-output-content">${formattedContent}</span>`;div.className = 'dbg-element dbg-output';// keep the pinning state if the debugger window is already pinned@@ -2404,6 +2468,12 @@ function clearDebugUIInfo() {nodes.forEach((node) => {node.remove();});++ // Also clear warning icons+ const warningIcons = [...workspace.domElement.querySelectorAll('.dbg-json-warning')];+ warningIcons.forEach((icon) => {+ icon.remove();+ });}export async function stopDebugSession(resetUI = true) {repaintDebugComponentsAfter();@@ -3138,6 +3208,7 @@ export async function registerDbgMonitorUI(monitor: Monitor) {const comp = document.querySelector(`#${e.data.id}`);if (!comp) return;comp.classList.remove('dbg-running');+ comp.classList.remove('dbg-active');// hide overlay// if duration was below 500ms, wait for 500ms - duration before hiding to give the visual feedbackif (e.data.duration < 500) {@@ -3155,11 +3226,27 @@ export async function registerDbgMonitorUI(monitor: Monitor) {if (!comp) return;workspace.refreshComponentSelection(comp as HTMLElement);comp.classList.add('dbg-running');+ comp.classList.add('dbg-active');// show overlay$(comp.querySelector('.cpt-overlay')).show();}});+ // Listen to the agent event+ monitor.on('agent', (e: any) => {+ const data = e.data;++ // Session START: when there's startTime but no endTime/duration+ if (data.startTime && !data.endTime && !data.duration) {+ workspace.domElement.classList.add('debugging');+ }++ // Session END: when there's endTime or duration+ if (data.endTime || data.duration) {+ workspace.domElement.classList.remove('debugging');+ }+ });+monitor.on('computer-use/ui-state', (e: any) => {const comp = document.querySelector(`#${e.data.componentId}`);if (!comp) return;@@ -3200,9 +3287,11 @@ function toggleDebugBarVisibility(componentElement: HTMLElement) {function resetComponentsState({resetMessages = false,+ resetDebugMessages = false,resetPinned = false,}: {resetMessages?: boolean;+ resetDebugMessages?: boolean;resetPinned?: boolean;}) {document.querySelectorAll('#workspace-container .component').forEach((component: HTMLElement) => {@@ -3227,6 +3316,13 @@ function resetComponentsState({component['_control']?.clearComponentMessages();}+ if (resetDebugMessages) {+ const messagesContainer = component.querySelector('.messages-container');+ if (messagesContainer) {+ messagesContainer.querySelectorAll('.message.missing-input').forEach((msg) => msg.remove());+ }+ }+if (resetPinned) {// enable endpoints if debugger window is not pinnedconst isPinned = component.querySelector('.pinned');diff --git a/packages/app/static/css/smyth-debugger.css b/packages/app/static/css/smyth-debugger.cssindex 86cae653..73301a3c 100644--- a/packages/app/static/css/smyth-debugger.css+++ b/packages/app/static/css/smyth-debugger.css@@ -126,7 +126,7 @@}.debug-enabled.debugging .component:not(.dbg-active) .btn-debug {- opacity: 0.5;+ filter: grayscale(1) brightness(1.2);pointer-events: none;cursor: not-allowed;}@@ -229,6 +229,49 @@right: auto;}+/* Warning icon for stringified JSON outputs */+.dbg-output-content {+ display: inline-block;+ position: relative;+ width: 100%;+}++/* Warning message container */+.dbg-json-warning-message {+ display: flex;+ align-items: center;+ gap: 6px;+ padding: 5px 8px;+ margin-bottom: 6px;+ background-color: #fff3e0;+ border-left: 3px solid #ff9800;+ border-radius: 3px;+ font-size: 10px;+ line-height: 1.3;+}++/* Warning icon */+.dbg-json-warning-icon {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 12px;+ height: 12px;+ background-color: #ff9800;+ color: white;+ border-radius: 50%;+ font-weight: bold;+ font-size: 9px;+ flex-shrink: 0;+}++/* Warning text */+.dbg-json-warning-text {+ color: #e65100;+ font-weight: normal;+ flex: 1;+}+.component .endpoint .dbg-output.pinned .pin .icon {display: none;}