Skip to content

Self-improving AI Employees for everyone

feat(output): spec-driven terminal rendering via uiHints.outputMode

trohitg587a2162b54d
diff --git a/client/src/components/output/OutputPanel.tsx b/client/src/components/output/OutputPanel.tsx
index 0f54505f..2407b35e 100644
--- a/client/src/components/output/OutputPanel.tsx
+++ b/client/src/components/output/OutputPanel.tsx
@@ -20,7 +20,8 @@ import {
CollapsibleTrigger,
} from '@/components/ui/collapsible';
import { ExecutionResult } from '@/services/executionService';
-import { copyToClipboard } from '@/utils/formatters';
+import { useNodeSpec } from '@/lib/nodeSpec';
+import { copyToClipboard, tryParseJson } from '@/utils/formatters';
import { cn } from '@/lib/utils';
/** Extract output data from ExecutionResult. */
@@ -34,6 +35,14 @@ const unwrap = (d: any) =>
/** Convert escaped newlines to real ones. */
const fmt = (s: string) => s.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
+/** Terminal-style surface for CLI stdout — the same --code-* tokens the
+ * JSON viewer uses, so all 12 themes paint it in their own palette. */
+const TERMINAL_STYLE = {
+ background: 'var(--code-bg)',
+ color: 'var(--code-text)',
+ borderColor: 'var(--code-border)',
+} as React.CSSProperties;
+
/** Map metadata field names to badge variants. */
const TAG_VARIANT: Record<string, 'secondary' | 'info' | 'success'> = {
model: 'secondary',
@@ -103,6 +112,10 @@ function Section({ label, defaultOpen = false, action, children }: SectionProps)
export default function OutputPanel({ results, onClear, selectedNode }: Props) {
const filtered = selectedNode ? results.filter(r => r.nodeId === selectedNode.id) : results;
const latest = filtered[0];
+ // Backend owns display logic: CLI-wrapper plugins declare
+ // uiHints.outputMode = "terminal" on their NodeSpec.
+ const spec = useNodeSpec(selectedNode?.type);
+ const isTerminal = spec?.uiHints?.outputMode === 'terminal';
if (!latest) {
return (
@@ -114,7 +127,15 @@ export default function OutputPanel({ results, onClear, selectedNode }: Props) {
const raw = getData(latest);
const data = unwrap(raw);
- const response = data?.response ?? data?.output ?? data?.text ?? data?.content ?? data?.stdout;
+ // `result` is the codebase's canonical payload key (same convention
+ // `unwrap` peels) — CLI nodes put server-side-parsed JSON there.
+ // Arrays survive `unwrap` un-peeled, so surface them here.
+ const parsedResult = data?.result !== null && typeof data?.result === 'object' ? data.result : undefined;
+ const response =
+ data?.response ?? data?.output ?? data?.text ?? data?.content ?? parsedResult ?? data?.stdout;
+ // Terminal nodes sometimes emit JSON on stdout anyway — a tree view
+ // beats a wall of braces (stdlib JSON.parse via shared formatter).
+ const stdoutJson = isTerminal && typeof response === 'string' ? tryParseJson(response) : null;
const thinking = data?.thinking;
const metaTags = ['model', 'provider', 'agent_type'].filter(k => data?.[k]);
@@ -154,16 +175,7 @@ export default function OutputPanel({ results, onClear, selectedNode }: Props) {
<div className="space-y-0">
{response && (
<Section label="Response" defaultOpen>
- {typeof response === 'string' ? (
- // Markdown text (LLM response). No whitespace-pre-wrap: it
- // double-counts newlines against remarkBreaks (each <br>
- // carries a trailing \n that pre-wrap renders as a 2nd break).
- <div className="prose prose-sm max-w-none dark:prose-invert">
- <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
- {fmt(response)}
- </ReactMarkdown>
- </div>
- ) : (
+ {typeof response !== 'string' ? (
// Object/array response — themed JSON viewer (same --code-*
// palette as Raw JSON), not stringified-into-markdown.
<JsonView
@@ -172,6 +184,33 @@ export default function OutputPanel({ results, onClear, selectedNode }: Props) {
displayDataTypes={false}
style={CODE_JSON_THEME}
/>
+ ) : stdoutJson ? (
+ // Terminal node whose stdout is itself JSON — tree view.
+ <JsonView
+ value={stdoutJson}
+ collapsed={2}
+ displayDataTypes={false}
+ style={CODE_JSON_THEME}
+ />
+ ) : isTerminal ? (
+ // CLI text (uiHints.outputMode === 'terminal'): preformatted,
+ // never markdown — `#` would become headings and indentation
+ // would collapse (gh/vercel tables, clone progress).
+ <pre
+ className="overflow-auto rounded-md border p-3 font-mono text-sm whitespace-pre-wrap break-words"
+ style={TERMINAL_STYLE}
+ >
+ {fmt(response)}
+ </pre>
+ ) : (
+ // Markdown text (LLM response). No whitespace-pre-wrap: it
+ // double-counts newlines against remarkBreaks (each <br>
+ // carries a trailing \n that pre-wrap renders as a 2nd break).
+ <div className="prose prose-sm max-w-none dark:prose-invert">
+ <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
+ {fmt(response)}
+ </ReactMarkdown>
+ </div>
)}
</Section>
)}
diff --git a/client/src/types/INodeProperties.ts b/client/src/types/INodeProperties.ts
index 367762d5..dd813475 100644
--- a/client/src/types/INodeProperties.ts
+++ b/client/src/types/INodeProperties.ts
@@ -221,6 +221,11 @@ export interface INodeUIHints {
* instead of showing direct upstream connections. Auto-derived on
* the backend from group membership; plugins can override. */
isConfigNode?: boolean;
+ /** OutputPanel: how the node's textual output renders. `"terminal"`
+ * = preformatted CLI text (never markdown — `#` would become
+ * headings and indentation would collapse). Declared by CLI-wrapper
+ * plugins (githubAction, vercelAction, shell). */
+ outputMode?: 'terminal';
}
export interface INodeTypeDescription {
diff --git a/client/src/utils/formatters.ts b/client/src/utils/formatters.ts
index 6d820033..7443d72e 100644
--- a/client/src/utils/formatters.ts
+++ b/client/src/utils/formatters.ts
@@ -25,6 +25,24 @@ export const formatJson = (obj: any, compact: boolean = false): string => {
return JSON.stringify(obj, null, compact ? 0 : 2);
};
+/**
+ * Parse a string that is wholly a JSON object/array; null otherwise.
+ * Stdlib JSON.parse behind a cheap shape check — used by output
+ * surfaces to route JSON-looking CLI/stdout strings to the tree
+ * viewer instead of markdown/plain text.
+ */
+export const tryParseJson = (s: string): object | null => {
+ const t = s.trim();
+ const looksJson = (t.startsWith('{') && t.endsWith('}')) || (t.startsWith('[') && t.endsWith(']'));
+ if (!looksJson) return null;
+ try {
+ const v = JSON.parse(t);
+ return typeof v === 'object' && v !== null ? v : null;
+ } catch {
+ return null;
+ }
+};
+
/**
* Format timestamp to locale string
*/
diff --git a/server/nodes/filesystem/shell/__init__.py b/server/nodes/filesystem/shell/__init__.py
index 7c343880..5f76ef83 100644
--- a/server/nodes/filesystem/shell/__init__.py
+++ b/server/nodes/filesystem/shell/__init__.py
@@ -50,6 +50,8 @@ class ShellNode(ActionNode):
{"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},
)
annotations = {"destructive": True, "readonly": False, "open_world": True}
+ # OutputPanel renders stdout preformatted (terminal text, not markdown).
+ ui_hints = {"outputMode": "terminal"}
task_queue = TaskQueue.DEFAULT
usable_as_tool = True
diff --git a/server/nodes/vercel/vercel_action.py b/server/nodes/vercel/vercel_action.py
index 6e84c37a..c7e07f8b 100644
--- a/server/nodes/vercel/vercel_action.py
+++ b/server/nodes/vercel/vercel_action.py
@@ -163,6 +163,9 @@ class VercelActionNode(ActionNode):
{"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},
)
annotations = {"destructive": False, "readonly": False, "open_world": True}
+ # OutputPanel renders textual output preformatted (vercel tables /
+ # build logs are terminal text, not markdown).
+ ui_hints = {"outputMode": "terminal"}
credentials = (VercelCredential,)
task_queue = TaskQueue.REST_API
usable_as_tool = True
@@ -236,15 +239,24 @@ class VercelActionNode(ActionNode):
@staticmethod
def _shape(operation: str, result: Dict[str, Any], *, url: Optional[str] = None) -> Dict[str, Any]:
+ """Output-panel shaping: when the CLI returned JSON, the parsed
+ data IS the payload — the raw stdout string would duplicate it
+ as an unreadable blob (pre-stringified JSON violates the output
+ contract). Keys are omitted (not None'd) when empty so the
+ panel shows only meaningful fields (`exclude_unset`)."""
+ shaped: Dict[str, Any] = {"operation": operation, "success": True}
+ if url:
+ shaped["url"] = url
+ parsed = result.get("result")
+ stdout = (result.get("stdout") or "").strip()
+ if parsed is not None:
+ shaped["result"] = parsed
+ elif stdout:
+ shaped["stdout"] = stdout
stderr = (result.get("stderr") or "").strip()
- return {
- "operation": operation,
- "success": True,
- "url": url,
- "result": result.get("result"),
- "stdout": result.get("stdout"),
- "stderr_tail": stderr[-_STDERR_TAIL_CHARS:] or None,
- }
+ if stderr:
+ shaped["stderr_tail"] = stderr[-_STDERR_TAIL_CHARS:]
+ return shaped
# ---- operations ------------------------------------------------------
diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.py
index f922e086..47795824 100644
--- a/server/tests/test_node_spec.py
+++ b/server/tests/test_node_spec.py
@@ -911,6 +911,10 @@ class TestNodeSpecContractInvariants:
# parameter panel that this node is an auxiliary config node
# and should inherit the parent's main inputs.
"isConfigNode",
+ # OutputPanel: 'terminal' renders the node's textual output
+ # preformatted instead of through ReactMarkdown (CLI-wrapper
+ # plugins: githubAction, vercelAction, shell).
+ "outputMode",
}
for node_type, meta in NODE_METADATA.items():
hints = meta.get("uiHints") or {}