Skip to content

Self-improving AI Employees for everyone

refactor(output): clean NodeOutputPanel, add prism/prose, Tailwind Typography

trohitg66fe059335c8
diff --git a/client/package.json b/client/package.json
index 0c5ab150..c5ac02e1 100644
--- a/client/package.json
+++ b/client/package.json
@@ -15,6 +15,7 @@
"@lobehub/icons": "^2.45.0",
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-dialog": "^1.1.15",
+ "@tailwindcss/typography": "^0.5.19",
"@tanstack/react-query": "^5",
"@types/google.maps": "^3.58.1",
"@types/node": "^24.3.1",
@@ -39,6 +40,7 @@
"react-dom": "^19.1.1",
"react-hook-form": "^7",
"react-js-cron": "^5.2.0",
+ "react-json-view-lite": "^2.5.0",
"react-markdown": "^10.1.0",
"react-simple-code-editor": "^0.14.1",
"react-virtuoso": "^4",
diff --git a/client/src/components/parameterPanel/OutputSection.tsx b/client/src/components/parameterPanel/OutputSection.tsx
index 5398113f..64fc6c51 100644
--- a/client/src/components/parameterPanel/OutputSection.tsx
+++ b/client/src/components/parameterPanel/OutputSection.tsx
@@ -29,17 +29,20 @@ const OutputSection: React.FC<OutputSectionProps> = ({
const combinedResults = React.useMemo(() => {
const results = [...executionResults];
- // Check if there's output from workflow execution in nodeStatuses
+ // Check if there's output from workflow execution in nodeStatuses.
+ // WebSocket node_output messages store data in the `output` field,
+ // while node_status messages use `data`. Check both so the formatted
+ // response renderer (getMainResponse → ReactMarkdown) receives the
+ // actual AI response object instead of falling through to raw JSON.
const nodeStatus = nodeStatuses[selectedNode.id];
- if (nodeStatus && nodeStatus.data && (nodeStatus.status === 'success' || nodeStatus.status === 'error')) {
- // Check if this output is already in executionResults
+ const statusData = nodeStatus?.data || nodeStatus?.output;
+ if (nodeStatus && statusData && (nodeStatus.status === 'success' || nodeStatus.status === 'error')) {
const alreadyExists = results.some(r =>
r.nodeId === selectedNode.id &&
- JSON.stringify(r.outputs) === JSON.stringify(nodeStatus.data)
+ JSON.stringify(r.outputs) === JSON.stringify(statusData)
);
if (!alreadyExists) {
- // Create ExecutionResult from nodeStatus (from workflow execution)
const wsResult: ExecutionResult = {
success: nodeStatus.status === 'success',
nodeId: selectedNode.id,
@@ -47,11 +50,10 @@ const OutputSection: React.FC<OutputSectionProps> = ({
nodeName: selectedNode.type || 'Node',
timestamp: new Date().toISOString(),
executionTime: 0,
- outputs: nodeStatus.data,
- nodeData: [[{ json: nodeStatus.data }]],
- error: nodeStatus.status === 'error' ? nodeStatus.data?.error : undefined
+ outputs: statusData,
+ nodeData: [[{ json: statusData }]],
+ error: nodeStatus.status === 'error' ? statusData?.error : undefined
};
- // Add WebSocket result to the beginning (most recent)
results.unshift(wsResult);
}
}
diff --git a/client/src/components/ui/NodeOutputPanel.tsx b/client/src/components/ui/NodeOutputPanel.tsx
index 746925af..67bbe94a 100644
--- a/client/src/components/ui/NodeOutputPanel.tsx
+++ b/client/src/components/ui/NodeOutputPanel.tsx
@@ -1,34 +1,36 @@
+/**
+ * NodeOutputPanel — displays execution results.
+ *
+ * Response text renders via Tailwind Typography (`prose`).
+ * Raw JSON renders via prismjs with centralized theme tokens.
+ * No node-type-specific rendering logic — the backend sends
+ * standardized output, the frontend renders it uniformly.
+ */
+
import React, { useState } from 'react';
-import { Card, List, Tag, Typography, Space } from 'antd';
-import { SearchOutlined, LinkOutlined, StarFilled, QuestionCircleOutlined, BookOutlined, RobotOutlined } from '@ant-design/icons';
+import { Tag, Space } from 'antd';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkBreaks from 'remark-breaks';
+import Prism from 'prismjs';
+import 'prismjs/components/prism-json';
import { useAppTheme } from '../../hooks/useAppTheme';
+import { styles as themeStyles, getPrismTokenCSS } from '../../styles/theme';
import { ExecutionResult } from '../../services/executionService';
import { Node } from 'reactflow';
import { copyToClipboard } from '../../utils/formatters';
-const { Text, Paragraph, Link: AntLink } = Typography;
+/** Prismjs JSON syntax highlighting (same lib as CodeEditor.tsx). */
+const highlightJSON = (json: string): React.ReactNode => (
+ <code className="prism-code" dangerouslySetInnerHTML={{
+ __html: Prism.highlight(json, Prism.languages.json, 'json'),
+ }} />
+);
-// Simple JSON syntax highlighter using Dracula colors
-const highlightJSON = (json: string, dracula: any): React.ReactNode => {
- const lines = json.split('\n');
- return lines.map((line, i) => {
- // Highlight different parts of JSON
- const highlighted = line
- .replace(/"([^"]+)":/g, `<span style="color: ${dracula.cyan}">"$1"</span>:`)
- .replace(/: "([^"]+)"/g, `: <span style="color: ${dracula.yellow}">"$1"</span>`)
- .replace(/: (\d+\.?\d*)/g, `: <span style="color: ${dracula.purple}">$1</span>`)
- .replace(/: (true|false)/g, `: <span style="color: ${dracula.purple}">$1</span>`)
- .replace(/: (null)/g, `: <span style="color: ${dracula.orange}">$1</span>`);
- return (
- <div key={i} dangerouslySetInnerHTML={{ __html: highlighted }} />
- );
- });
-};
+// ============================================================================
+// Thinking/Reasoning block (collapsible)
+// ============================================================================
-// Collapsible thinking/reasoning block for AI model responses
interface ThinkingBlockProps {
thinking: string;
provider?: string;
@@ -37,467 +39,160 @@ interface ThinkingBlockProps {
const ThinkingBlock: React.FC<ThinkingBlockProps> = ({ thinking, provider, theme }) => {
const [isExpanded, setIsExpanded] = useState(true);
+ if (!thinking?.trim()) return null;
- if (!thinking || !thinking.trim()) return null;
+ const label = provider?.includes('anthropic') ? 'Extended Thinking'
+ : provider?.includes('openai') ? 'Reasoning'
+ : 'Thinking';
return (
<div style={{
- marginBottom: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${theme.dracula.purple}40`,
+ border: `1px solid ${theme.dracula.orange}40`,
borderRadius: theme.borderRadius.md,
- borderLeft: `3px solid ${theme.dracula.purple}`,
+ borderLeft: `3px solid ${theme.dracula.orange}`,
overflow: 'hidden',
}}>
<div
onClick={() => setIsExpanded(!isExpanded)}
style={{
- padding: theme.spacing.md,
- cursor: 'pointer',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- backgroundColor: `${theme.dracula.purple}10`,
- transition: theme.transitions.fast,
+ display: 'flex', alignItems: 'center', gap: theme.spacing.sm,
+ padding: `${theme.spacing.sm} ${theme.spacing.md}`,
+ cursor: 'pointer', backgroundColor: `${theme.dracula.orange}10`,
+ fontSize: theme.fontSize.xs, fontWeight: theme.fontWeight.semibold,
+ color: theme.dracula.orange, textTransform: 'uppercase', letterSpacing: '0.1em',
}}
>
- <div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.sm }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={theme.dracula.purple} strokeWidth="2">
- <circle cx="12" cy="12" r="10"/>
- <path d="M12 6v6l4 2"/>
- </svg>
- <span style={{
- color: theme.dracula.purple,
- fontWeight: theme.fontWeight.semibold,
- fontSize: theme.fontSize.xs,
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- }}>
- Thinking Process {provider && `(${provider})`}
- </span>
- </div>
- <svg
- width="12" height="12" viewBox="0 0 24 24" fill="none"
- stroke={theme.dracula.purple} strokeWidth="2"
- style={{ transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform 0.2s ease' }}
- >
+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ strokeWidth="2" style={{ transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)', transition: '0.2s' }}>
<polyline points="9 18 15 12 9 6"/>
</svg>
+ {label}
</div>
{isExpanded && (
- <pre style={{
- padding: theme.spacing.md,
- margin: 0,
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
- fontSize: theme.fontSize.sm,
- color: theme.colors.textSecondary,
- fontFamily: '"Fira Code", Monaco, Menlo, monospace',
- lineHeight: 1.6,
- maxHeight: '300px',
- overflow: 'auto',
- backgroundColor: theme.colors.background,
+ <div className="prose prose-sm dark:prose-invert max-w-none" style={{
+ padding: theme.spacing.md, fontSize: theme.fontSize.sm,
+ maxHeight: '300px', overflow: 'auto',
}}>
- {thinking}
- </pre>
+ <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
+ {thinking.replace(/\\n/g, '\n')}
+ </ReactMarkdown>
+ </div>
)}
</div>
);
};
+// ============================================================================
+// Data extraction helpers (minimal, no node-type-specific formatting)
+// ============================================================================
+
+/** Extract output data object from ExecutionResult. */
+const getOutputData = (result: ExecutionResult) => {
+ if (result.outputs && Object.keys(result.outputs).length > 0) return result.outputs;
+ if (result.data && Object.keys(result.data).length > 0) return result.data;
+ if (result.nodeData?.[0]?.[0]?.json) return result.nodeData[0][0].json;
+ return { success: result.success, message: 'Execution completed' };
+};
+
+/** Extract thinking content from result. */
+const getThinkingContent = (result: ExecutionResult) => {
+ const data = getOutputData(result);
+ if (data?.result?.thinking) return { thinking: data.result.thinking, provider: data.result.provider };
+ if (data?.thinking) return { thinking: data.thinking, provider: data?.provider };
+ return { thinking: null as string | null };
+};
+
+/** Extract the main response text. Checks standard response field paths. */
+const getMainResponse = (result: ExecutionResult): string | null => {
+ const data = getOutputData(result);
+ // Standard response fields (covers AI agents, code executors, tools)
+ const text = data?.output ?? data?.result?.response ?? data?.response
+ ?? data?.result?.text ?? data?.text
+ ?? data?.result?.content ?? data?.content
+ ?? data?.result?.message ?? data?.result?.preview ?? data?.preview;
+ if (text !== undefined && text !== null) {
+ return typeof text === 'string' ? text : JSON.stringify(text, null, 2);
+ }
+ // Shell/command output
+ if (data?.stdout !== undefined || data?.result?.stdout !== undefined) {
+ const r = data?.result ?? data;
+ return `$ ${r.command ?? ''}\n[${r.exit_code === 0 ? 'OK' : `Exit ${r.exit_code}`}]\n\n${r.stdout || '(no output)'}`;
+ }
+ return null;
+};
+
+// ============================================================================
+// Component
+// ============================================================================
+
interface NodeOutputPanelProps {
results: ExecutionResult[];
onClear?: () => void;
selectedNode?: Node | null;
}
-const NodeOutputPanel: React.FC<NodeOutputPanelProps> = ({
- results,
- onClear,
- selectedNode
-}) => {
+const NodeOutputPanel: React.FC<NodeOutputPanelProps> = ({ results, onClear, selectedNode }) => {
const theme = useAppTheme();
const [showRawJson, setShowRawJson] = useState(false);
- // Filter results to only show current node's output
- const nodeResults = selectedNode ? results.filter(result => result.nodeId === selectedNode.id) : results;
-
- // Get output data with fallbacks
- const getOutputData = (result: ExecutionResult) => {
- if (result.outputs && Object.keys(result.outputs).length > 0) {
- return result.outputs;
- }
- if (result.data && Object.keys(result.data).length > 0) {
- return result.data;
- }
- if (result.nodeData && result.nodeData.length > 0 && result.nodeData[0].length > 0) {
- return result.nodeData[0][0].json;
- }
- return {
- success: result.success,
- message: 'Execution completed'
- };
- };
-
- // Helper to parse nested JSON strings in Android responses
- const parseAndroidData = (data: any): any => {
- if (typeof data !== 'object' || data === null) return data;
-
- const parsed: any = Array.isArray(data) ? [] : {};
- for (const key in data) {
- const value = data[key];
- // Try to parse string values that look like JSON arrays or objects
- if (typeof value === 'string' && (value.startsWith('[') || value.startsWith('{'))) {
- try {
- parsed[key] = JSON.parse(value);
- } catch {
- parsed[key] = value;
- }
- } else if (typeof value === 'object' && value !== null) {
- parsed[key] = parseAndroidData(value);
- } else {
- parsed[key] = value;
- }
- }
- return parsed;
- };
-
- // Extract thinking content from result data
- const getThinkingContent = (result: ExecutionResult): { thinking: string | null; provider?: string } => {
- const data = getOutputData(result);
- // Check nested result structure first (from backend)
- if (data?.result?.thinking) {
- return { thinking: data.result.thinking, provider: data.result.provider };
- }
- // Then top-level
- if (data?.thinking) {
- return { thinking: data.thinking, provider: data?.provider };
- }
- return { thinking: null };
- };
-
- // Structured output types for different node responses
- type AndroidOutput = { type: 'android'; data: any; service?: string; action?: string };
- type WhatsAppHistoryOutput = { type: 'whatsapp_history'; messages: any[]; total: number; count: number; hasMore: boolean };
- type MapsNearbyOutput = { type: 'maps_nearby'; places: any[]; searchParams: any; total: number };
- type MapsGeocodeOutput = { type: 'maps_geocode'; locations: any[]; total: number };
- type MapsCreateOutput = { type: 'maps_create'; mapUrl: string; center: { lat: number; lng: number }; zoom: number; mapType: string };
- type SearchResultsOutput = { type: 'search_results'; query: string; results: any[]; resultCount: number; provider: string; answer?: string; citations?: string[]; searchType?: string; knowledgeGraph?: any; images?: string[]; relatedQuestions?: string[] };
- type StructuredOutput = AndroidOutput | WhatsAppHistoryOutput | MapsNearbyOutput | MapsGeocodeOutput | MapsCreateOutput | SearchResultsOutput;
-
- // Extract the main response text from execution results
- const formatFilesystemOutput = (r: any): string | null => {
- if (!r) return null;
- // fileRead
- if (r.content && r.file_path) return `File: ${r.file_path}\n\n${r.content}`;
- // fileModify write
- if (r.operation === 'write' && r.file_path) return `Written: ${r.file_path}`;
- // fileModify edit
- if (r.operation === 'edit' && r.file_path) return `Edited: ${r.file_path} (${r.occurrences || 1} replacement${(r.occurrences || 1) > 1 ? 's' : ''})`;
- // shell
- if (r.command !== undefined && r.stdout !== undefined) {
- return `$ ${r.command}\n[${r.exit_code === 0 ? 'OK' : `Exit ${r.exit_code}`}]\n\n${r.stdout || '(no output)'}`;
- }
- // fsSearch ls
- if (r.entries && Array.isArray(r.entries)) {
- const lines = r.entries.map((e: any) => `${e.type === 'dir' ? '[DIR]' : ' '} ${e.name}${e.size != null ? ` (${e.size}b)` : ''}`);
- return `${r.path || '.'} (${r.count || r.entries.length} items)\n\n${lines.join('\n')}`;
- }
- // fsSearch glob/grep
- if (r.matches && Array.isArray(r.matches)) {
- if (r.matches.length === 0) return `No matches for "${r.pattern}"`;
- const lines = r.matches.slice(0, 50).map((m: any) => m.line ? `${m.path}:${m.line}: ${m.text}` : (m.path || JSON.stringify(m)));
- return `${r.count || r.matches.length} match(es) for "${r.pattern}"\n\n${lines.join('\n')}${r.count > 50 ? `\n... and ${r.count - 50} more` : ''}`;
- }
- return null;
- };
-
- const getMainResponse = (result: ExecutionResult): string | StructuredOutput | null => {
- const data = getOutputData(result);
-
- // Python node output
- if (data?.output !== undefined) {
- return typeof data.output === 'string' ? data.output : JSON.stringify(data.output, null, 2);
- }
- // Filesystem/shell nodes
- const fsOut = formatFilesystemOutput(data?.result) || formatFilesystemOutput(data);
- if (fsOut) return fsOut;
-
- if (data?.result?.response) return data.result.response;
- if (data?.response) return data.response;
- if (data?.result?.text) return data.result.text;
- if (data?.text) return data.text;
- if (data?.result?.content) return data.result.content;
- if (data?.content) return data.content;
- if (data?.result?.message) return data.result.message;
- if (data?.message && typeof data.message === 'string' && data.message !== 'Execution completed') return data.message;
- // WhatsApp message preview
- if (data?.result?.preview) return data.result.preview;
- if (data?.preview) return data.preview;
- // WhatsApp Chat History output
- if (data?.result?.messages !== undefined && data?.result?.total !== undefined) {
- return { type: 'whatsapp_history', messages: data.result.messages, total: data.result.total, count: data.result.count, hasMore: data.result.has_more };
- }
- if (data?.messages !== undefined && data?.total !== undefined) {
- return { type: 'whatsapp_history', messages: data.messages, total: data.total, count: data.count || data.messages?.length, hasMore: data.has_more };
- }
- // Search results output (Brave Search, Serper, Perplexity, DuckDuckGo)
- // Check nested result structure: { success, result: { query, results, provider } }
- if (data?.result?.results !== undefined && data?.result?.query !== undefined) {
- return {
- type: 'search_results',
- query: data.result.query,
- results: data.result.results,
- resultCount: data.result.result_count || data.result.results.length,
- provider: data.result.provider || 'search',
- answer: data.result.answer,
- citations: data.result.citations,
- searchType: data.result.search_type,
- knowledgeGraph: data.result.knowledge_graph,
- images: data.result.images,
- relatedQuestions: data.result.related_questions,
- };
- }
- // Search results top-level (tool direct return or unwrapped by useExecution)
- if (data?.results !== undefined && data?.query !== undefined && Array.isArray(data?.results)) {
- return {
- type: 'search_results',
- query: data.query,
- results: data.results,
- resultCount: data.result_count || data.results.length,
- provider: data.provider || 'search',
- answer: data.answer,
- citations: data.citations,
- searchType: data.search_type,
- knowledgeGraph: data.knowledge_graph,
- images: data.images,
- relatedQuestions: data.related_questions,
- };
- }
- // Google Maps nearby places output
- // Check nested result structure (from backend: { success, result: { results, search_parameters } })
- if (data?.result?.results !== undefined && data?.result?.search_parameters !== undefined) {
- return {
- type: 'maps_nearby',
- places: data.result.results,
- searchParams: data.result.search_parameters,
- total: data.result.total_results || data.result.results.length
- };
- }
- // Also check top-level structure (if already unwrapped)
- if (data?.results !== undefined && data?.search_parameters !== undefined) {
- return {
- type: 'maps_nearby',
- places: data.results,
- searchParams: data.search_parameters,
- total: data.total_results || data.results.length
- };
- }
- // Google Maps geocoding output
- if (data?.result?.locations !== undefined && data?.result?.total_found !== undefined) {
- return {
- type: 'maps_geocode',
- locations: data.result.locations,
- total: data.result.total_found
- };
- }
- // Geocode top-level fallback
- if (data?.locations !== undefined && data?.total_found !== undefined) {
- return {
- type: 'maps_geocode',
- locations: data.locations,
- total: data.total_found
- };
- }
- // Google Maps create map output
- if (data?.result?.static_map_url !== undefined) {
- return {
- type: 'maps_create',
- mapUrl: data.result.static_map_url,
- center: data.result.center,
- zoom: data.result.zoom,
- mapType: data.result.map_type
- };
- }
- // Create map top-level fallback
- if (data?.static_map_url !== undefined) {
- return {
- type: 'maps_create',
- mapUrl: data.static_map_url,
- center: data.center,
- zoom: data.zoom,
- mapType: data.map_type
- };
- }
- // Webhook trigger output
- if (data?.method && data?.path !== undefined) {
- let bodyData = data.json || (data.body ? (() => { try { return JSON.parse(data.body); } catch { return data.body; } })() : null);
- const bodyStr = bodyData ? JSON.stringify(bodyData) : '';
- return `${data.method} /${data.path}${bodyStr ? ` - ${bodyStr}` : ''}`;
- }
- // HTTP Request output - format status and data
- if (data?.status !== undefined && data?.data !== undefined) {
- const statusText = data.status >= 200 && data.status < 300 ? 'OK' : data.status >= 400 ? 'Error' : '';
- const isHtml = typeof data.data === 'string' && data.data.trim().startsWith('<');
- const isLong = typeof data.data === 'string' && data.data.length > 200;
-
- if (isHtml) {
- return `${data.status} ${statusText} - HTML response (${data.data.length} chars)`;
- } else if (isLong) {
- return `${data.status} ${statusText} - ${data.data.substring(0, 150)}...`;
- } else if (typeof data.data === 'string') {
- return `${data.status} ${statusText} - ${data.data}`;
- } else {
- return `${data.status} ${statusText}\n${JSON.stringify(data.data, null, 2)}`;
- }
- }
- // Android service output - show received data with parsed nested JSON
- if (data?.service_id && data?.data) {
- const parsedData = parseAndroidData(data.data);
- return { type: 'android', data: parsedData, service: data.service_id, action: data.action };
- }
- return null;
- };
-
- // Get the most recent result
- const latestResult = nodeResults[0];
+ const nodeResults = selectedNode
+ ? results.filter(r => r.nodeId === selectedNode.id)
+ : results;
if (nodeResults.length === 0) {
- const hasOtherResults = results.length > 0;
-
return (
<div style={{
- width: '100%',
- height: '100%',
- backgroundColor: theme.colors.backgroundPanel,
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- justifyContent: 'center',
- padding: theme.spacing.xxl,
+ width: '100%', height: '100%', display: 'flex',
+ alignItems: 'center', justifyContent: 'center',
+ color: theme.colors.textMuted, fontSize: theme.fontSize.sm,
}}>
- <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke={theme.colors.textMuted} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ marginBottom: theme.spacing.lg }}>
- <polygon points="5 3 19 12 5 21 5 3"/>
- </svg>
- <div style={{
- fontSize: theme.fontSize.base,
- fontWeight: theme.fontWeight.medium,
- color: theme.colors.textSecondary,
- marginBottom: theme.spacing.xs
- }}>
- No output yet
- </div>
- <div style={{
- fontSize: theme.fontSize.sm,
- color: theme.colors.textMuted,
- textAlign: 'center'
- }}>
- Run the node to see results
- </div>
- {hasOtherResults && (
- <div style={{
- marginTop: theme.spacing.md,
- fontSize: theme.fontSize.xs,
- color: theme.dracula.orange,
- padding: `${theme.spacing.xs} ${theme.spacing.md}`,
- backgroundColor: theme.dracula.orange + '15',
- borderRadius: theme.borderRadius.sm,
- }}>
- {results.length} result(s) from other nodes
- </div>
- )}
+ No output yet. Run a node to see results.
</div>
);
}
+ const latestResult = nodeResults[0];
const outputData = getOutputData(latestResult);
const mainResponse = getMainResponse(latestResult);
+ const { thinking, provider } = getThinkingContent(latestResult);
return (
<div style={{
- width: '100%',
- height: '100%',
+ width: '100%', height: '100%',
backgroundColor: theme.colors.backgroundPanel,
- display: 'flex',
- flexDirection: 'column',
- overflow: 'hidden',
+ display: 'flex', flexDirection: 'column', overflow: 'hidden',
}}>
{/* Header */}
<div style={{
padding: `${theme.spacing.md} ${theme.spacing.lg}`,
borderBottom: `1px solid ${theme.colors.border}`,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- backgroundColor: theme.colors.backgroundElevated,
- flexShrink: 0,
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
+ backgroundColor: theme.colors.backgroundElevated, flexShrink: 0,
}}>
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.md }}>
- {latestResult.success ? (
- <svg width="20" height="20" viewBox="0 0 24 24" fill={theme.dracula.green} stroke="none">
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
- </svg>
- ) : (
- <svg width="20" height="20" viewBox="0 0 24 24" fill={theme.dracula.red} stroke="none">
- <path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/>
- </svg>
- )}
- <span style={{
- fontSize: theme.fontSize.base,
- fontWeight: theme.fontWeight.semibold,
- color: theme.colors.text,
- }}>
+ <svg width="16" height="16" viewBox="0 0 24 24"
+ fill={latestResult.success ? theme.dracula.green : theme.dracula.red} stroke="none">
+ {latestResult.success
+ ? <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
+ : <path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/>}
+ </svg>
+ <span style={{ fontSize: theme.fontSize.base, fontWeight: theme.fontWeight.semibold, color: theme.colors.text }}>
Output
</span>
- <span style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: latestResult.success ? theme.dracula.green : theme.dracula.red,
- padding: `4px ${theme.spacing.md}`,
- backgroundColor: latestResult.success ? theme.dracula.green + '25' : theme.dracula.red + '25',
- borderRadius: theme.borderRadius.sm,
- border: `1px solid ${latestResult.success ? theme.dracula.green : theme.dracula.red}50`,
- letterSpacing: '0.05em',
- }}>
- {latestResult.success ? 'SUCCESS' : 'FAILED'}
- </span>
+ <Tag color={latestResult.success ? 'green' : 'red'}>
+ {latestResult.success ? 'Success' : 'Error'}
+ </Tag>
{latestResult.executionTime > 0 && (
- <span style={{
- fontSize: theme.fontSize.sm,
- color: theme.colors.textSecondary,
- fontFamily: 'Monaco, Menlo, monospace',
- }}>
- {latestResult.executionTime.toFixed(2)}ms
- </span>
+ <Tag>{(latestResult.executionTime / 1000).toFixed(1)}s</Tag>
)}
</div>
{onClear && (
- <button
- onClick={onClear}
- style={{
- padding: `${theme.spacing.xs} ${theme.spacing.md}`,
- fontSize: theme.fontSize.xs,
- color: theme.colors.textSecondary,
- backgroundColor: 'transparent',
- border: `1px solid ${theme.colors.border}`,
- borderRadius: theme.borderRadius.sm,
- cursor: 'pointer',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.xs,
- transition: theme.transitions.fast,
- }}
- onMouseEnter={(e) => {
- e.currentTarget.style.backgroundColor = theme.colors.backgroundAlt;
- }}
- onMouseLeave={(e) => {
- e.currentTarget.style.backgroundColor = 'transparent';
- }}
- >
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <polyline points="3 6 5 6 21 6"/>
- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
- </svg>
+ <button onClick={onClear} style={{
+ padding: `${theme.spacing.xs} ${theme.spacing.md}`,
+ fontSize: theme.fontSize.xs, cursor: 'pointer',
+ color: theme.dracula.pink, backgroundColor: `${theme.dracula.pink}15`,
+ border: `1px solid ${theme.dracula.pink}40`, borderRadius: theme.borderRadius.sm,
+ }}>
Clear
</button>
)}
@@ -505,1002 +200,114 @@ const NodeOutputPanel: React.FC<NodeOutputPanelProps> = ({
{/* Content */}
<div style={{
- flex: 1,
- overflow: 'auto',
- padding: theme.spacing.md,
+ flex: 1, overflow: 'auto', padding: theme.spacing.lg,
+ display: 'flex', flexDirection: 'column', gap: theme.spacing.md,
}}>
- {/* Error Display */}
+ {/* Error */}
{latestResult.error && (
- <div style={{
- padding: theme.spacing.md,
- marginBottom: theme.spacing.md,
- backgroundColor: theme.dracula.red + '10',
+ <pre style={{
+ margin: 0, padding: theme.spacing.md,
+ backgroundColor: `${theme.dracula.red}10`,
border: `1px solid ${theme.dracula.red}40`,
- borderRadius: theme.borderRadius.md,
+ borderRadius: theme.borderRadius.md, borderLeft: `3px solid ${theme.dracula.red}`,
+ fontSize: theme.fontSize.sm, fontFamily: theme.fontFamily.mono,
+ color: theme.dracula.red, whiteSpace: 'pre-wrap', wordBreak: 'break-word',
}}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.medium,
- color: theme.dracula.red,
- marginBottom: theme.spacing.sm,
- textTransform: 'uppercase',
- letterSpacing: '0.05em',
- }}>
- Error
- </div>
- <pre style={{
- margin: 0,
- fontSize: theme.fontSize.sm,
- fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
- color: theme.dracula.red,
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
- }}>
- {latestResult.error}
- </pre>
- </div>
+ {latestResult.error}
+ </pre>
)}
- {/* Thinking/Reasoning Block (shown before main response) */}
- {(() => {
- const { thinking, provider } = getThinkingContent(latestResult);
- return thinking ? <ThinkingBlock thinking={thinking} provider={provider} theme={theme} /> : null;
- })()}
-
- {/* Main Response */}
- {mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'android' ? (
- /* Android Service Response */
- <div style={{
- padding: theme.spacing.lg,
- marginBottom: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${theme.dracula.green}40`,
- borderRadius: theme.borderRadius.md,
- borderLeft: `3px solid ${theme.dracula.green}`,
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: theme.dracula.green,
- marginBottom: theme.spacing.md,
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <rect x="5" y="2" width="14" height="20" rx="2" ry="2"/>
- <line x1="12" y1="18" x2="12" y2="18"/>
- </svg>
- {(mainResponse as any).service?.replace(/_/g, ' ')} - {(mainResponse as any).action}
- </div>
- <pre style={{
- margin: 0,
- fontSize: theme.fontSize.sm,
- fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
- color: theme.colors.text,
- lineHeight: 1.6,
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
- }}>
- {highlightJSON(JSON.stringify((mainResponse as any).data, null, 2), theme.dracula)}
- </pre>
- </div>
- ) : mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'whatsapp_history' ? (
- /* WhatsApp Chat History Response */
- <div style={{
- marginBottom: theme.spacing.md,
- }}>
- {/* Header with count */}
- <div style={{
- padding: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #25D36640`,
- borderRadius: `${theme.borderRadius.md} ${theme.borderRadius.md} 0 0`,
- borderLeft: `3px solid #25D366`,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: '#25D366',
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="#25D366">
- <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
- </svg>
- Chat History
- </div>
- <div style={{
- fontSize: theme.fontSize.xs,
- color: theme.colors.textSecondary,
- display: 'flex',
- gap: theme.spacing.md,
- }}>
- <span style={{ color: '#25D366' }}>{(mainResponse as any).count || 0} messages</span>
- {(mainResponse as any).total > 0 && (
- <span>of {(mainResponse as any).total} total</span>
- )}
- {(mainResponse as any).hasMore && (
- <span style={{ color: theme.dracula.orange }}>more available</span>
- )}
- </div>
- </div>
-
- {/* Messages list */}
- <div style={{
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #25D36640`,
- borderTop: 'none',
- borderRadius: `0 0 ${theme.borderRadius.md} ${theme.borderRadius.md}`,
- maxHeight: '400px',
- overflow: 'auto',
- }}>
- {(mainResponse as any).messages?.length === 0 ? (
- <div style={{
- padding: theme.spacing.xl,
- textAlign: 'center',
- color: theme.colors.textMuted,
- fontSize: theme.fontSize.sm,
- }}>
- No messages found for this chat
- </div>
- ) : (
- (mainResponse as any).messages?.map((msg: any, idx: number) => (
- <div
- key={msg.message_id || idx}
- style={{
- padding: theme.spacing.md,
- borderBottom: idx < (mainResponse as any).messages.length - 1 ? `1px solid ${theme.colors.border}` : 'none',
- display: 'flex',
- flexDirection: 'column',
- gap: theme.spacing.xs,
- }}
- >
- {/* Message header */}
- <div style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- gap: theme.spacing.sm,
- }}>
- <div style={{
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- {/* From me indicator */}
- {msg.is_from_me ? (
- <span style={{
- fontSize: '10px',
- padding: '2px 6px',
- backgroundColor: theme.dracula.cyan + '20',
- color: theme.dracula.cyan,
- borderRadius: theme.borderRadius.sm,
- fontWeight: theme.fontWeight.medium,
- }}>
- You
- </span>
- ) : (
- <span style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.medium,
- color: theme.dracula.purple,
- }}>
- {msg.sender_phone || msg.sender?.split('@')[0] || 'Unknown'}
- </span>
- )}
- {/* Message type badge */}
- {msg.message_type !== 'text' && (
- <span style={{
- fontSize: '10px',
- padding: '2px 6px',
- backgroundColor: theme.dracula.orange + '20',
- color: theme.dracula.orange,
- borderRadius: theme.borderRadius.sm,
- textTransform: 'uppercase',
- }}>
- {msg.message_type}
- </span>
- )}
- {msg.is_group && (
- <span style={{
- fontSize: '10px',
- padding: '2px 6px',
- backgroundColor: theme.dracula.green + '20',
- color: theme.dracula.green,
- borderRadius: theme.borderRadius.sm,
- }}>
- Group
- </span>
- )}
- </div>
- {/* Timestamp */}
- <span style={{
- fontSize: theme.fontSize.xs,
- color: theme.colors.textMuted,
- }}>
- {msg.timestamp ? new Date(msg.timestamp).toLocaleString() : ''}
- </span>
- </div>
- {/* Message text */}
- {msg.text && (
- <div style={{
- fontSize: theme.fontSize.sm,
- color: theme.colors.text,
- lineHeight: 1.5,
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
- paddingLeft: theme.spacing.sm,
- borderLeft: `2px solid ${msg.is_from_me ? theme.dracula.cyan : theme.dracula.purple}30`,
- }}>
- {msg.text}
- </div>
- )}
- </div>
- ))
- )}
- </div>
- </div>
- ) : mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'maps_nearby' ? (
- /* Google Maps Nearby Places Response */
- <div style={{
- marginBottom: theme.spacing.md,
- }}>
- {/* Header with search params */}
- <div style={{
- padding: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #34a85340`,
- borderRadius: `${theme.borderRadius.md} ${theme.borderRadius.md} 0 0`,
- borderLeft: `3px solid #34a853`,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: '#34a853',
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="#34a853">
- <path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
- </svg>
- Nearby Places
- </div>
- <div style={{
- fontSize: theme.fontSize.xs,
- color: theme.colors.textSecondary,
- display: 'flex',
- gap: theme.spacing.md,
- }}>
- <span style={{ color: '#34a853' }}>{(mainResponse as any).total} places found</span>
- {(mainResponse as any).searchParams?.type && (
- <span>Type: {(mainResponse as any).searchParams.type}</span>
- )}
- {(mainResponse as any).searchParams?.keyword && (
- <span>Keyword: {(mainResponse as any).searchParams.keyword}</span>
- )}
- </div>
- </div>
-
- {/* Places list */}
- <div style={{
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #34a85340`,
- borderTop: 'none',
- borderRadius: `0 0 ${theme.borderRadius.md} ${theme.borderRadius.md}`,
- maxHeight: '400px',
- overflow: 'auto',
- }}>
- {(mainResponse as any).places?.length === 0 ? (
- <div style={{
- padding: theme.spacing.xl,
- textAlign: 'center',
- color: theme.colors.textMuted,
- fontSize: theme.fontSize.sm,
- }}>
- No places found for this search
- </div>
- ) : (
- (mainResponse as any).places?.map((place: any, idx: number) => (
- <div
- key={place.place_id || idx}
- style={{
- padding: theme.spacing.md,
- borderBottom: idx < (mainResponse as any).places.length - 1 ? `1px solid ${theme.colors.border}` : 'none',
- display: 'flex',
- flexDirection: 'column',
- gap: theme.spacing.xs,
- }}
- >
- {/* Place header */}
- <div style={{
- display: 'flex',
- alignItems: 'flex-start',
- justifyContent: 'space-between',
- gap: theme.spacing.sm,
- }}>
- <div style={{ flex: 1 }}>
- <div style={{
- fontSize: theme.fontSize.sm,
- fontWeight: theme.fontWeight.semibold,
- color: theme.colors.text,
- marginBottom: '2px',
- }}>
- {place.name}
- </div>
- {place.vicinity && (
- <div style={{
- fontSize: theme.fontSize.xs,
- color: theme.colors.textMuted,
- }}>
- {place.vicinity}
- </div>
- )}
- </div>
- <div style={{
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- {/* Rating */}
- {place.rating && (
- <div style={{
- display: 'flex',
- alignItems: 'center',
- gap: '4px',
- padding: '2px 8px',
- backgroundColor: theme.dracula.yellow + '20',
- borderRadius: theme.borderRadius.sm,
- }}>
- <svg width="12" height="12" viewBox="0 0 24 24" fill={theme.dracula.yellow}>
- <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
- </svg>
- <span style={{ fontSize: theme.fontSize.xs, color: theme.dracula.yellow, fontWeight: theme.fontWeight.medium }}>
- {place.rating}
- </span>
- {place.user_ratings_total && (
- <span style={{ fontSize: '10px', color: theme.colors.textMuted }}>
- ({place.user_ratings_total})
- </span>
- )}
- </div>
- )}
- {/* Open now */}
- {place.opening_hours?.open_now !== undefined && (
- <span style={{
- fontSize: '10px',
- padding: '2px 6px',
- backgroundColor: place.opening_hours.open_now ? theme.dracula.green + '20' : theme.dracula.red + '20',
- color: place.opening_hours.open_now ? theme.dracula.green : theme.dracula.red,
- borderRadius: theme.borderRadius.sm,
- fontWeight: theme.fontWeight.medium,
- }}>
- {place.opening_hours.open_now ? 'Open' : 'Closed'}
- </span>
- )}
- {/* Price level */}
- {place.price_level !== undefined && (
- <span style={{
- fontSize: theme.fontSize.xs,
- color: theme.colors.textMuted,
- }}>
- {'$'.repeat(place.price_level + 1)}
- </span>
- )}
- </div>
- </div>
- {/* Place types */}
- {place.types && place.types.length > 0 && (
- <div style={{
- display: 'flex',
- flexWrap: 'wrap',
- gap: '4px',
- marginTop: '4px',
- }}>
- {place.types.slice(0, 4).map((type: string) => (
- <span key={type} style={{
- fontSize: '10px',
- padding: '2px 6px',
- backgroundColor: theme.colors.backgroundAlt,
- color: theme.colors.textSecondary,
- borderRadius: theme.borderRadius.sm,
- }}>
- {type.replace(/_/g, ' ')}
- </span>
- ))}
- </div>
- )}
- </div>
- ))
- )}
- </div>
- </div>
- ) : mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'maps_geocode' ? (
- /* Google Maps Geocoding Response */
- <div style={{
- marginBottom: theme.spacing.md,
- }}>
- <div style={{
- padding: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #4285f440`,
- borderRadius: `${theme.borderRadius.md} ${theme.borderRadius.md} 0 0`,
- borderLeft: `3px solid #4285f4`,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: '#4285f4',
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="#4285f4">
- <path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
- </svg>
- Geocoded Locations
- </div>
- <span style={{ fontSize: theme.fontSize.xs, color: '#4285f4' }}>
- {(mainResponse as any).total} location(s) found
- </span>
- </div>
- <div style={{
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #4285f440`,
- borderTop: 'none',
- borderRadius: `0 0 ${theme.borderRadius.md} ${theme.borderRadius.md}`,
- maxHeight: '300px',
- overflow: 'auto',
- }}>
- {(mainResponse as any).locations?.map((loc: any, idx: number) => (
- <div
- key={idx}
- style={{
- padding: theme.spacing.md,
- borderBottom: idx < (mainResponse as any).locations.length - 1 ? `1px solid ${theme.colors.border}` : 'none',
- }}
- >
- <div style={{ fontWeight: theme.fontWeight.medium, color: theme.colors.text, marginBottom: '4px' }}>
- {loc.formatted_address || loc.address}
- </div>
- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textMuted }}>
- Lat: {loc.lat?.toFixed(6)}, Lng: {loc.lng?.toFixed(6)}
- </div>
- </div>
- ))}
- </div>
- </div>
- ) : mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'maps_create' ? (
- /* Google Maps Create Map Response */
- <div style={{
- marginBottom: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid #ea433540`,
- borderRadius: theme.borderRadius.md,
- borderLeft: `3px solid #ea4335`,
- overflow: 'hidden',
- }}>
- <div style={{
- padding: theme.spacing.md,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- borderBottom: `1px solid ${theme.colors.border}`,
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: '#ea4335',
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="#ea4335">
- <path d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM15 19l-6-2.11V5l6 2.11V19z"/>
- </svg>
- Map Created
- </div>
- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textSecondary }}>
- {(mainResponse as any).mapType} | Zoom: {(mainResponse as any).zoom}
- </div>
- </div>
- <div style={{ padding: theme.spacing.md }}>
- <div style={{ fontSize: theme.fontSize.sm, color: theme.colors.textMuted, marginBottom: theme.spacing.sm }}>
- Center: {(mainResponse as any).center?.lat?.toFixed(4)}, {(mainResponse as any).center?.lng?.toFixed(4)}
- </div>
- <a
- href={(mainResponse as any).mapUrl}
- target="_blank"
- rel="noopener noreferrer"
- style={{
- display: 'inline-flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- padding: `${theme.spacing.sm} ${theme.spacing.md}`,
- backgroundColor: '#ea433520',
- color: '#ea4335',
- borderRadius: theme.borderRadius.sm,
- border: `1px solid #ea433540`,
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.medium,
- textDecoration: 'none',
- cursor: 'pointer',
- }}
- >
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
- <polyline points="15 3 21 3 21 9"/>
- <line x1="10" y1="14" x2="21" y2="3"/>
- </svg>
- Open Map Preview
- </a>
- </div>
- </div>
- ) : mainResponse && typeof mainResponse === 'object' && (mainResponse as any).type === 'search_results' ? (
- /* Search Results Response (Brave, Serper, Perplexity, DuckDuckGo) */
- (() => {
- const sr = mainResponse as SearchResultsOutput;
- const providerColors: Record<string, string> = {
- brave_search: '#FB542B', serper: '#4285F4', perplexity: '#20808D', duckduckgo: '#DE5833',
- };
- const providerLabels: Record<string, string> = {
- brave_search: 'Brave Search', serper: 'Serper', perplexity: 'Perplexity', duckduckgo: 'DuckDuckGo',
- };
- const accent = providerColors[sr.provider] || theme.dracula.cyan;
- const hasRichResults = sr.results.some((r: any) => r.title || r.snippet);
- const showResultsList = !sr.answer || hasRichResults;
- return (
- <div style={{ marginBottom: theme.spacing.md }}>
- {/* Header card */}
- <Card
- size="small"
- style={{
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${accent}40`,
- borderLeft: `3px solid ${accent}`,
- borderRadius: `${theme.borderRadius.md} ${theme.borderRadius.md} 0 0`,
- }}
- bodyStyle={{ padding: `${theme.spacing.sm} ${theme.spacing.md}` }}
- >
- <Space direction="vertical" size={4} style={{ width: '100%' }}>
- <Space style={{ width: '100%', justifyContent: 'space-between' }}>
- <Space size="small">
- <SearchOutlined style={{ color: accent }} />
- <Text strong style={{ color: accent, fontSize: theme.fontSize.xs, textTransform: 'uppercase', letterSpacing: '0.1em' }}>
- Search Results
- </Text>
- <Tag color={accent} style={{ margin: 0 }}>
- {providerLabels[sr.provider] || sr.provider}
- </Tag>
- </Space>
- <Space size="middle">
- <Text type="secondary" style={{ fontSize: theme.fontSize.xs }}>
- <Text style={{ color: accent }}>{sr.resultCount}</Text> result{sr.resultCount !== 1 ? 's' : ''}
- </Text>
- {sr.searchType && sr.searchType !== 'search' && (
- <Tag>{sr.searchType}</Tag>
- )}
- </Space>
- </Space>
- <Text type="secondary" style={{ fontSize: theme.fontSize.sm }}>
- Query: <Text style={{ color: theme.colors.text }}>{sr.query}</Text>
- </Text>
- </Space>
- </Card>
-
- {/* Perplexity AI answer */}
- {sr.answer && (
- <Card
- size="small"
- style={{
- backgroundColor: theme.colors.backgroundElevated,
- borderLeft: `3px solid ${accent}`,
- border: `1px solid ${accent}40`,
- borderTop: 'none',
- borderRadius: !showResultsList && !sr.knowledgeGraph ? `0 0 ${theme.borderRadius.md} ${theme.borderRadius.md}` : 0,
- }}
- bodyStyle={{ padding: theme.spacing.md }}
- >
- <Space direction="vertical" size="small" style={{ width: '100%' }}>
- <Space size="small">
- <RobotOutlined style={{ color: accent }} />
- <Text strong style={{ color: accent, fontSize: theme.fontSize.xs, textTransform: 'uppercase', letterSpacing: '0.05em' }}>
- AI Answer
- </Text>
- </Space>
- <div
- className="search-answer-markdown"
- style={{ color: theme.colors.text, fontSize: theme.fontSize.sm, lineHeight: 1.6 }}
- >
- <style>{`
- .search-answer-markdown p { margin: 0 0 8px 0; }
- .search-answer-markdown p:last-child { margin-bottom: 0; }
- .search-answer-markdown h1, .search-answer-markdown h2, .search-answer-markdown h3 {
- margin: 12px 0 8px 0; font-weight: 600; color: ${theme.colors.text};
- }
- .search-answer-markdown h1:first-child, .search-answer-markdown h2:first-child, .search-answer-markdown h3:first-child { margin-top: 0; }
- .search-answer-markdown h1 { font-size: 1.2em; }
- .search-answer-markdown h2 { font-size: 1.1em; }
- .search-answer-markdown h3 { font-size: 1em; }
- .search-answer-markdown strong { font-weight: 600; color: ${theme.colors.text}; }
- .search-answer-markdown em { font-style: italic; }
- .search-answer-markdown ul, .search-answer-markdown ol { margin: 8px 0; padding-left: 20px; }
- .search-answer-markdown li { margin: 4px 0; }
- .search-answer-markdown code {
- background-color: ${theme.isDarkMode ? theme.dracula.currentLine : `${theme.colors.border}50`};
- padding: 2px 6px; border-radius: 4px;
- font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
- font-size: 0.9em;
- }
- .search-answer-markdown pre {
- background-color: ${theme.isDarkMode ? theme.dracula.currentLine : theme.colors.backgroundPanel};
- padding: 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0;
- }
- .search-answer-markdown pre code { background: none; padding: 0; }
- .search-answer-markdown table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 0.9em; }
- .search-answer-markdown th, .search-answer-markdown td {
- border: 1px solid ${theme.isDarkMode ? theme.dracula.selection : theme.colors.border};
- padding: 6px 10px; text-align: left;
- }
- .search-answer-markdown th {
- background-color: ${theme.isDarkMode ? theme.dracula.currentLine : theme.colors.backgroundPanel};
- font-weight: 600;
- }
- .search-answer-markdown blockquote {
- border-left: 3px solid ${accent};
- margin: 8px 0; padding: 4px 12px; color: ${theme.colors.textSecondary};
- }
- .search-answer-markdown a { color: ${accent}; text-decoration: none; }
- .search-answer-markdown a:hover { text-decoration: underline; }
- .search-answer-markdown hr {
- border: none;
- border-top: 1px solid ${theme.isDarkMode ? theme.dracula.selection : theme.colors.border};
- margin: 12px 0;
- }
- `}</style>
- <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
- {sr.answer}
- </ReactMarkdown>
- </div>
- {sr.citations && sr.citations.length > 0 && (
- <Space size={[4, 4]} wrap>
- {sr.citations.map((url: string, idx: number) => (
- <Tag
- key={idx}
- icon={<LinkOutlined />}
- color={accent}
- style={{ cursor: 'pointer', maxWidth: 200, overflow: 'hidden', textOverflow: 'ellipsis' }}
- onClick={() => window.open(url, '_blank')}
- title={url}
- >
- {(() => { try { return new URL(url).hostname; } catch { return url; } })()}
- </Tag>
- ))}
- </Space>
- )}
- </Space>
- </Card>
- )}
-
- {/* Knowledge graph (Serper) */}
- {sr.knowledgeGraph && (
- <Card
- size="small"
- style={{
- backgroundColor: theme.colors.backgroundElevated,
- borderLeft: `3px solid ${accent}`,
- border: `1px solid ${accent}40`,
- borderTop: 'none',
- borderRadius: 0,
- }}
- bodyStyle={{ padding: theme.spacing.md }}
- >
- <Space direction="vertical" size={2} style={{ width: '100%' }}>
- <Space size="small">
- <BookOutlined style={{ color: accent }} />
- <Text strong style={{ color: accent, fontSize: theme.fontSize.xs, textTransform: 'uppercase', letterSpacing: '0.05em' }}>
- Knowledge Graph
- </Text>
- </Space>
- {sr.knowledgeGraph.title && (
- <Text strong style={{ color: theme.colors.text }}>{sr.knowledgeGraph.title}</Text>
- )}
- {sr.knowledgeGraph.type && (
- <Text type="secondary" style={{ fontSize: theme.fontSize.xs }}>{sr.knowledgeGraph.type}</Text>
- )}
- {sr.knowledgeGraph.description && (
- <Paragraph style={{ color: theme.colors.textSecondary, fontSize: theme.fontSize.sm, lineHeight: 1.5, marginBottom: 0 }}>
- {sr.knowledgeGraph.description}
- </Paragraph>
- )}
- </Space>
- </Card>
- )}
-
- {/* Results list - skip when answer+citations already cover it (Perplexity returns url-only results) */}
- {showResultsList && (
- <List
- size="small"
- dataSource={sr.results}
- locale={{ emptyText: 'No results found' }}
- style={{
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${accent}40`,
- borderTop: 'none',
- borderRadius: `0 0 ${theme.borderRadius.md} ${theme.borderRadius.md}`,
- maxHeight: 400,
- overflow: 'auto',
- }}
- renderItem={(item: any, idx: number) => (
- <List.Item
- key={idx}
- style={{ padding: `${theme.spacing.sm} ${theme.spacing.md}`, alignItems: 'flex-start' }}
- >
- <Space direction="vertical" size={2} style={{ width: '100%' }}>
- <Space size="small" align="start">
- {item.position && (
- <Text type="secondary" style={{ fontSize: 10, minWidth: 18 }}>#{item.position}</Text>
- )}
- {item.title ? (
- <AntLink href={item.url || item.imageUrl} target="_blank" style={{ color: accent, fontSize: theme.fontSize.sm, fontWeight: theme.fontWeight.medium }}>
- {item.title}
- </AntLink>
- ) : item.url ? (
- <AntLink href={item.url} target="_blank" style={{ color: accent, fontSize: theme.fontSize.sm, wordBreak: 'break-all' }}>
- {item.url}
- </AntLink>
- ) : null}
- </Space>
- {item.snippet && (
- <Text type="secondary" style={{ fontSize: theme.fontSize.xs, lineHeight: 1.4 }}>
- {item.snippet}
- </Text>
- )}
- {item.url && item.title && (
- <Text type="secondary" style={{ fontSize: 11, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', display: 'block' }}>
- {item.url}
- </Text>
- )}
- {(item.date || item.source || item.address || item.rating != null) && (
- <Space size="small">
- {item.source && <Tag color="cyan">{item.source}</Tag>}
- {item.date && <Text type="secondary" style={{ fontSize: 10 }}>{item.date}</Text>}
- {item.address && <Text type="secondary" style={{ fontSize: 10 }}>{item.address}</Text>}
- {item.rating != null && (
- <Tag icon={<StarFilled />} color="gold">{item.rating}</Tag>
- )}
- </Space>
- )}
- </Space>
- </List.Item>
- )}
- />
- )}
+ {/* Thinking/Reasoning */}
+ {thinking && <ThinkingBlock thinking={thinking} provider={provider} theme={theme} />}
- {/* Related questions (Perplexity) */}
- {sr.relatedQuestions && sr.relatedQuestions.length > 0 && (
- <Card
- size="small"
- style={{
- marginTop: theme.spacing.sm,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${accent}30`,
- borderRadius: theme.borderRadius.md,
- }}
- bodyStyle={{ padding: theme.spacing.md }}
- >
- <Space direction="vertical" size="small" style={{ width: '100%' }}>
- <Space size="small">
- <QuestionCircleOutlined style={{ color: accent }} />
- <Text strong style={{ color: accent, fontSize: theme.fontSize.xs, textTransform: 'uppercase', letterSpacing: '0.05em' }}>
- Related Questions
- </Text>
- </Space>
- {sr.relatedQuestions.map((q: string, idx: number) => (
- <Tag key={idx} style={{ whiteSpace: 'normal', padding: `${theme.spacing.xs} ${theme.spacing.sm}` }}>
- {q}
- </Tag>
- ))}
- </Space>
- </Card>
- )}
- </div>
- );
- })()
- ) : mainResponse && (
- /* Standard Response (AI, etc) */
- <div style={{
- padding: theme.spacing.lg,
- marginBottom: theme.spacing.md,
- backgroundColor: theme.colors.backgroundElevated,
- border: `1px solid ${theme.dracula.cyan}40`,
- borderRadius: theme.borderRadius.md,
- borderLeft: `3px solid ${theme.dracula.cyan}`,
- }}>
- <div style={{
- fontSize: theme.fontSize.xs,
- fontWeight: theme.fontWeight.semibold,
- color: theme.dracula.cyan,
- marginBottom: theme.spacing.md,
- textTransform: 'uppercase',
- letterSpacing: '0.1em',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.sm,
- }}>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
- </svg>
- Response
- </div>
- <div style={{
- fontSize: theme.fontSize.base,
- color: theme.colors.text,
- lineHeight: 1.7,
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
- fontWeight: theme.fontWeight.normal,
- }}>
- {mainResponse as string}
- </div>
+ {/* Main Response (markdown via Tailwind Typography) */}
+ {mainResponse && (
+ <div className="prose prose-sm dark:prose-invert max-w-none">
+ <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
+ {mainResponse.replace(/\\n/g, '\n').replace(/\\t/g, '\t')}
+ </ReactMarkdown>
</div>
)}
- {/* Agent Execution Metadata */}
+ {/* Execution Metadata */}
{(() => {
const r = outputData?.result || outputData;
- if (!r?.provider && !r?.agent_type) return null;
- const tags: [string, string, string][] = [];
- if (r.provider) tags.push([r.provider, 'cyan', 'Provider']);
- if (r.model) tags.push([r.model, 'purple', 'Model']);
- if (r.agent_type) tags.push([r.agent_type.replace(/_/g, ' '), 'green', 'Type']);
- if (r.iterations > 1) tags.push([`${r.iterations} iterations`, 'orange', '']);
- if (r.messages_count) tags.push([`${r.messages_count} msgs`, 'default', '']);
- if (r.tools?.count) tags.push([`${r.tools.count} tool(s)`, 'magenta', '']);
- if (r.skills?.count) tags.push([`${r.skills.count} skill(s)`, 'blue', '']);
- if (r.memory?.session_id) tags.push([`${r.memory.history_loaded} history`, 'gold', '']);
+ if (!r?.provider && !r?.agent_type && !r?.model) return null;
+ const tags: [string, string][] = [];
+ if (r.provider) tags.push([r.provider, 'cyan']);
+ if (r.model) tags.push([r.model, 'purple']);
+ if (r.agent_type) tags.push([r.agent_type.replace(/_/g, ' '), 'green']);
+ if (r.iterations > 1) tags.push([`${r.iterations} iterations`, 'orange']);
+ if (r.messages_count) tags.push([`${r.messages_count} msgs`, 'default']);
return (
- <Space wrap size={[4, 4]} style={{ marginBottom: theme.spacing.md }}>
+ <Space wrap size={[4, 4]}>
{tags.map(([val, color], i) => <Tag key={i} color={color}>{val}</Tag>)}
</Space>
);
})()}
- {/* JSON Output Toggle */}
+ {/* Raw JSON (collapsible) */}
<div style={{
backgroundColor: theme.colors.backgroundElevated,
border: `1px solid ${theme.colors.border}`,
- borderRadius: theme.borderRadius.md,
- overflow: 'hidden',
+ borderRadius: theme.borderRadius.md, overflow: 'hidden',
+ display: 'flex', flexDirection: 'column',
+ flex: showRawJson ? 1 : undefined,
+ minHeight: showRawJson ? 0 : undefined,
}}>
<div
onClick={() => setShowRawJson(!showRawJson)}
style={{
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
- backgroundColor: theme.colors.backgroundAlt,
- cursor: 'pointer',
- transition: theme.transitions.fast,
+ backgroundColor: theme.colors.backgroundAlt, cursor: 'pointer',
borderBottom: showRawJson ? `1px solid ${theme.colors.border}` : 'none',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.sm }}>
- <svg
- width="12"
- height="12"
- viewBox="0 0 24 24"
- fill="none"
- stroke={theme.dracula.purple}
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- style={{
- transform: showRawJson ? 'rotate(90deg)' : 'rotate(0deg)',
- transition: 'transform 0.2s ease',
- }}
- >
+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ strokeWidth="2" style={{ transform: showRawJson ? 'rotate(90deg)' : 'rotate(0deg)', transition: '0.2s' }}>
<polyline points="9 18 15 12 9 6"/>
</svg>
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={theme.dracula.purple} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
- <polyline points="14 2 14 8 20 8"/>
- <line x1="16" y1="13" x2="8" y2="13"/>
- <line x1="16" y1="17" x2="8" y2="17"/>
- </svg>
- <span style={{
- fontSize: theme.fontSize.sm,
- fontWeight: theme.fontWeight.medium,
- color: theme.colors.text,
- }}>
+ <span style={{ fontSize: theme.fontSize.sm, fontWeight: theme.fontWeight.medium, color: theme.colors.text }}>
{showRawJson ? 'Hide' : 'Show'} Raw JSON
</span>
</div>
<button
- onClick={(e) => {
- e.stopPropagation();
- copyToClipboard(outputData, 'JSON copied to clipboard!');
- }}
+ onClick={(e) => { e.stopPropagation(); copyToClipboard(outputData, 'Copied!'); }}
style={{
- padding: `${theme.spacing.xs} ${theme.spacing.md}`,
- fontSize: theme.fontSize.xs,
- color: theme.dracula.cyan,
- backgroundColor: `${theme.dracula.cyan}15`,
- border: `1px solid ${theme.dracula.cyan}40`,
- borderRadius: theme.borderRadius.sm,
- cursor: 'pointer',
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing.xs,
- transition: theme.transitions.fast,
- fontWeight: theme.fontWeight.medium,
- }}
- onMouseEnter={(e) => {
- e.currentTarget.style.backgroundColor = `${theme.dracula.cyan}25`;
- }}
- onMouseLeave={(e) => {
- e.currentTarget.style.backgroundColor = `${theme.dracula.cyan}15`;
+ padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
+ fontSize: theme.fontSize.xs, cursor: 'pointer',
+ color: theme.dracula.cyan, backgroundColor: `${theme.dracula.cyan}15`,
+ border: `1px solid ${theme.dracula.cyan}40`, borderRadius: theme.borderRadius.sm,
}}
>
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
- </svg>
Copy
</button>
</div>
- {/* Expanded JSON with syntax highlighting */}
{showRawJson && (
<div style={{
- margin: 0,
- padding: theme.spacing.md,
- fontSize: theme.fontSize.sm,
- fontFamily: '"Fira Code", Monaco, Menlo, "Ubuntu Mono", monospace',
- lineHeight: 1.6,
- overflow: 'auto',
- maxHeight: '400px',
- backgroundColor: '#1a1a2e',
+ ...themeStyles.codeBlock.container,
+ padding: theme.spacing.md, flex: 1, minHeight: 0,
+ backgroundColor: theme.colors.backgroundAlt,
color: theme.dracula.foreground,
}}>
- {highlightJSON(JSON.stringify(outputData, null, 2), theme.dracula)}
+ <style>{getPrismTokenCSS(theme)}</style>
+ {highlightJSON(JSON.stringify(outputData, null, 2).replace(/\\n/g, '\n').replace(/\\t/g, '\t'))}
</div>
)}
</div>
</div>
- {/* Footer */}
+ {/* Footer (multi-result indicator) */}
{nodeResults.length > 1 && (
<div style={{
padding: `${theme.spacing.sm} ${theme.spacing.lg}`,
borderTop: `1px solid ${theme.colors.border}`,
backgroundColor: theme.colors.background,
- fontSize: theme.fontSize.xs,
- color: theme.colors.textMuted,
- textAlign: 'center',
- flexShrink: 0,
+ fontSize: theme.fontSize.xs, color: theme.colors.textMuted,
+ textAlign: 'center', flexShrink: 0,
}}>
Showing latest of {nodeResults.length} results
</div>
diff --git a/client/src/components/ui/OutputDisplayPanel.tsx b/client/src/components/ui/OutputDisplayPanel.tsx
index eb7542d0..7e6f3cc3 100644
--- a/client/src/components/ui/OutputDisplayPanel.tsx
+++ b/client/src/components/ui/OutputDisplayPanel.tsx
@@ -1,7 +1,10 @@
import React, { useState } from 'react';
+import Prism from 'prismjs';
+import 'prismjs/components/prism-json';
import { ExecutionResult } from '../../services/executionService';
import { copyToClipboard, formatTimestamp } from '../../utils/formatters';
import { useAppTheme } from '../../hooks/useAppTheme';
+import { styles as themeStyles, getPrismTokenCSS } from '../../styles/theme';
interface OutputDisplayPanelProps {
results: ExecutionResult[];
@@ -428,26 +431,30 @@ const OutputDisplayPanel: React.FC<OutputDisplayPanelProps> = ({ results, onClea
</button>
</div>
- {/* Expanded JSON */}
+ {/* Expanded JSON with prismjs highlighting (theme from styles/theme.ts) */}
{isExpanded && (
- <pre style={{
- margin: 0,
+ <div style={{
+ ...themeStyles.codeBlock.container,
marginTop: theme.spacing.sm,
padding: theme.spacing.md,
- fontSize: theme.fontSize.xs,
- fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
- lineHeight: 1.5,
- overflow: 'auto',
- whiteSpace: 'pre-wrap',
- wordBreak: 'break-word',
maxHeight: '300px',
- backgroundColor: theme.colors.backgroundElevated,
+ backgroundColor: theme.colors.backgroundAlt,
color: theme.dracula.foreground,
borderRadius: theme.borderRadius.sm,
border: `1px solid ${theme.colors.border}`,
}}>
- {JSON.stringify(executionData, null, 2)}
- </pre>
+ <style>{getPrismTokenCSS(theme)}</style>
+ <code
+ className="prism-code"
+ dangerouslySetInnerHTML={{
+ __html: Prism.highlight(
+ JSON.stringify(executionData, null, 2),
+ Prism.languages.json,
+ 'json',
+ ),
+ }}
+ />
+ </div>
)}
</div>
</div>
diff --git a/client/src/styles/theme.ts b/client/src/styles/theme.ts
index 3fdbdaed..8a9bdb0a 100644
--- a/client/src/styles/theme.ts
+++ b/client/src/styles/theme.ts
@@ -511,5 +511,53 @@ export const styles = {
height: '100%',
backgroundColor: theme.colors.background,
},
+
+ // Code block / syntax highlighted JSON (prismjs) — used by
+ // NodeOutputPanel, OutputDisplayPanel, and any future JSON display.
+ // Token colors use dracula palette for consistency with CodeEditor.
+ codeBlock: {
+ container: {
+ margin: 0,
+ fontFamily: theme.fontFamily.mono,
+ fontSize: theme.fontSize.sm,
+ lineHeight: 1.6,
+ overflow: 'auto' as const,
+ whiteSpace: 'pre-wrap' as const,
+ wordBreak: 'break-word' as const,
+ } as React.CSSProperties,
+ maxHeight: '400px',
+ },
};
+/**
+ * Generate prismjs token CSS for a given theme instance.
+ * Call via `getPrismTokenCSS(theme)` and inject once per component
+ * tree that uses `Prism.highlight`. Same dracula token mapping as
+ * CodeEditor.tsx — centralised here so every code display in the
+ * app shares one source of truth.
+ *
+ * @param selector CSS parent selector to scope the tokens (e.g.
+ * '.prism-json' or '.code-editor-container').
+ * Defaults to '.prism-code' which all prism output
+ * containers should use as a className.
+ */
+export function getPrismTokenCSS(
+ t: { dracula: typeof dracula; colors: { text?: string }; [k: string]: any },
+ selector: string = '.prism-code',
+): string {
+ return `
+ ${selector} .token.property { color: ${t.dracula.cyan}; }
+ ${selector} .token.string { color: ${t.dracula.yellow}; }
+ ${selector} .token.number { color: ${t.dracula.purple}; }
+ ${selector} .token.boolean { color: ${t.dracula.purple}; }
+ ${selector} .token.null { color: ${t.dracula.orange}; }
+ ${selector} .token.keyword { color: ${t.dracula.pink}; }
+ ${selector} .token.function { color: ${t.dracula.green}; }
+ ${selector} .token.operator { color: ${t.dracula.pink}; }
+ ${selector} .token.class-name { color: ${t.dracula.cyan}; }
+ ${selector} .token.builtin { color: ${t.dracula.cyan}; }
+ ${selector} .token.comment { color: ${t.dracula.comment}; }
+ ${selector} .token.punctuation { color: ${t.dracula.foreground}; }
+ `;
+}
+
diff --git a/client/tailwind.config.js b/client/tailwind.config.js
index 222e2b35..126cde97 100644
--- a/client/tailwind.config.js
+++ b/client/tailwind.config.js
@@ -56,5 +56,5 @@ export default {
},
},
},
- plugins: [],
+ plugins: [require('@tailwindcss/typography')],
}
\ No newline at end of file
diff --git a/docs-internal/ui_optimization/output_panel_architecture.md b/docs-internal/ui_optimization/output_panel_architecture.md
new file mode 100644
index 00000000..cfa97b3a
--- /dev/null
+++ b/docs-internal/ui_optimization/output_panel_architecture.md
@@ -0,0 +1,281 @@
+# Output Panel Architecture
+
+Modern renderer registry pattern for execution output display. Replaces the 1500-line monolith `NodeOutputPanel.tsx` with a pluggable, lazy-loaded renderer system.
+
+## Research basis
+
+Three parallel agents audited: n8n/Retool/Langflow/Vercel AI SDK/Open WebUI output patterns, Shadcn + Tailwind ecosystem components, and all MachinaOs backend handler response shapes.
+
+## Design decisions
+
+| Decision | Choice | Rationale |
+|---|---|---|
+| Dispatch model | Explicit `output_type` field from backend | Vercel AI SDK pattern. No client-side type guessing. Backend knows the node type and sets it. |
+| JSON viewer | `react-json-view-lite` (~3 KB) | Lightest maintained lib. Collapsible tree, dark mode via CSS vars. Replaces custom `highlightJSON`. |
+| Markdown | `ReactMarkdown` + `remarkGfm` + `remarkBreaks` + Tailwind `prose` | Already in use. Standard stack (ChatGPT, Perplexity use same). |
+| Code blocks | `prismjs` (already installed) | Good enough. `shiki` is better but adds 8 KB for marginal gain. |
+| Tabular data | `@tanstack/react-table` (already installed via TanStack Query) | Headless, Tailwind-friendly. For search results, filesystem listings. |
+| Composition | Shadcn-style slots (`OutputCard` with named children) | No class inheritance. Each section is an independent component. |
+| Lazy loading | `React.lazy` per renderer | Same pattern as credentials `PanelRenderer`. Only loaded on first encounter. |
+| Fallback | Raw JSON tree (`react-json-view-lite`) | Every output is valid JSON. If no typed renderer matches, show the tree. |
+
+## Backend contract
+
+Every handler MUST return `output_type` in the result so the frontend can dispatch without guessing:
+
+```python
+# server/services/handlers/ai.py
+return {
+ "success": True,
+ "result": {
+ "output_type": "markdown", # <-- renderer dispatch key
+ "response": "Hello!...",
+ "thinking": None,
+ "model": "gemini-3-flash",
+ "provider": "gemini",
+ ...
+ }
+}
+
+# server/services/handlers/search.py
+return {
+ "success": True,
+ "result": {
+ "output_type": "search_results",
+ "query": "...",
+ "results": [...],
+ ...
+ }
+}
+
+# server/services/handlers/filesystem.py
+return {
+ "success": True,
+ "result": {
+ "output_type": "shell",
+ "stdout": "...",
+ "exit_code": 0,
+ "command": "ls -la",
+ ...
+ }
+}
+```
+
+### Output types (from backend handler audit)
+
+| `output_type` | Source handlers | Response shape |
+|---|---|---|
+| `markdown` | `ai.py` (all agents), `text.py` | `{response, thinking?, model, provider, agent_type, iterations}` |
+| `search_results` | `search.py` (brave, serper, perplexity) | `{query, results[], result_count, provider, answer?, citations?}` |
+| `code_output` | `code.py` (python, js, ts) | `{output, console_output}` |
+| `shell` | `filesystem.py` (shell node) | `{stdout, exit_code, command, truncated}` |
+| `file_content` | `filesystem.py` (fileRead) | `{content, file_path}` |
+| `file_op` | `filesystem.py` (fileModify) | `{operation, file_path, occurrences}` |
+| `file_list` | `filesystem.py` (fsSearch) | `{path?, entries[]?, pattern?, matches[]?, count}` |
+| `document` | `document.py` (scraper, parser) | `{items[], item_count, errors}` |
+| `browser` | `browser.py` | `{operation, data, session}` |
+| `todo` | `todo_service.py` (writeTodos) | `{todos (JSON string), count}` |
+| `json` | Any handler without a specific type | Fallback — raw JSON tree |
+
+## Frontend architecture
+
+```
+client/src/components/output/
+├── OutputPanel.tsx # Main container — extracts output_type, dispatches
+├── OutputCard.tsx # Composition wrapper (header + content + raw toggle)
+├── ThinkingBlock.tsx # Collapsible thinking/reasoning (already exists)
+├── ExecutionMeta.tsx # Provider/model/agent_type tags
+├── registry.ts # output_type → React.lazy component map
+├── renderers/
+│ ├── MarkdownRenderer.tsx # prose + ReactMarkdown (AI responses)
+│ ├── JsonRenderer.tsx # react-json-view-lite wrapper
+│ ├── SearchRenderer.tsx # Card list with title/snippet/url
+│ ├── CodeRenderer.tsx # Prism + console output
+│ ├── ShellRenderer.tsx # Pre-formatted stdout + exit code badge
+│ ├── FileContentRenderer.tsx # Content with file path header
+│ ├── FileListRenderer.tsx # Directory listing / grep matches
+│ ├── TableRenderer.tsx # @tanstack/react-table for tabular data
+│ ├── TodoRenderer.tsx # Checklist with status icons
+│ └── ErrorRenderer.tsx # Styled error display
+└── utils/
+ ├── detect.ts # Fallback type detection if output_type missing
+ └── types.ts # OutputType enum + renderer props interfaces
+```
+
+### Registry pattern
+
+```tsx
+// registry.ts
+import { lazy, type ComponentType } from 'react';
+
+export type OutputType =
+ | 'markdown' | 'search_results' | 'code_output' | 'shell'
+ | 'file_content' | 'file_op' | 'file_list' | 'document'
+ | 'browser' | 'todo' | 'json';
+
+export interface RendererProps {
+ data: Record<string, any>;
+}
+
+const RENDERERS: Record<OutputType, () => Promise<{ default: ComponentType<RendererProps> }>> = {
+ markdown: () => import('./renderers/MarkdownRenderer'),
+ search_results: () => import('./renderers/SearchRenderer'),
+ code_output: () => import('./renderers/CodeRenderer'),
+ shell: () => import('./renderers/ShellRenderer'),
+ file_content: () => import('./renderers/FileContentRenderer'),
+ file_op: () => import('./renderers/FileContentRenderer'),
+ file_list: () => import('./renderers/FileListRenderer'),
+ document: () => import('./renderers/TableRenderer'),
+ browser: () => import('./renderers/JsonRenderer'),
+ todo: () => import('./renderers/TodoRenderer'),
+ json: () => import('./renderers/JsonRenderer'),
+};
+
+const cache = new Map<OutputType, ComponentType<RendererProps>>();
+
+export function getRenderer(type: OutputType): ComponentType<RendererProps> {
+ if (!cache.has(type)) {
+ cache.set(type, lazy(RENDERERS[type] ?? RENDERERS.json));
+ }
+ return cache.get(type)!;
+}
+```
+
+### OutputPanel (the dispatcher)
+
+```tsx
+// OutputPanel.tsx
+import { Suspense } from 'react';
+import { Spin } from 'antd';
+import { getRenderer, type OutputType } from './registry';
+import { detectOutputType } from './utils/detect';
+import OutputCard from './OutputCard';
+import ThinkingBlock from './ThinkingBlock';
+import ExecutionMeta from './ExecutionMeta';
+
+function OutputPanel({ result }: { result: ExecutionResult }) {
+ const data = result.outputs || result.data || result.nodeData?.[0]?.[0]?.json || {};
+ const inner = data.result || data;
+
+ // Backend sets output_type; fallback to client-side detection
+ const outputType: OutputType = inner.output_type || detectOutputType(inner);
+ const Renderer = getRenderer(outputType);
+
+ return (
+ <OutputCard result={result}>
+ {inner.thinking && <ThinkingBlock thinking={inner.thinking} provider={inner.provider} />}
+ <Suspense fallback={<Spin size="small" />}>
+ <Renderer data={inner} />
+ </Suspense>
+ <ExecutionMeta data={inner} />
+ </OutputCard>
+ );
+}
+```
+
+### Example renderer (MarkdownRenderer)
+
+```tsx
+// renderers/MarkdownRenderer.tsx
+import ReactMarkdown from 'react-markdown';
+import remarkGfm from 'remark-gfm';
+import remarkBreaks from 'remark-breaks';
+import type { RendererProps } from '../registry';
+
+export default function MarkdownRenderer({ data }: RendererProps) {
+ const text = data.response || data.text || data.content || data.message || '';
+ const formatted = typeof text === 'string'
+ ? text.replace(/\\n/g, '\n').replace(/\\t/g, '\t')
+ : JSON.stringify(text, null, 2);
+
+ return (
+ <div className="prose prose-sm dark:prose-invert max-w-none">
+ <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
+ {formatted}
+ </ReactMarkdown>
+ </div>
+ );
+}
+```
+
+### Example renderer (JsonRenderer)
+
+```tsx
+// renderers/JsonRenderer.tsx
+import { JsonView, darkTheme, defaultTheme } from 'react-json-view-lite';
+import 'react-json-view-lite/dist/index.css';
+import { useAppTheme } from '../../../hooks/useAppTheme';
+import type { RendererProps } from '../registry';
+
+export default function JsonRenderer({ data }: RendererProps) {
+ const theme = useAppTheme();
+ return (
+ <JsonView
+ data={data}
+ shouldExpandNode={(level) => level < 2}
+ style={theme.isDarkMode ? darkTheme : defaultTheme}
+ />
+ );
+}
+```
+
+## Fallback type detection (for backends that haven't added `output_type` yet)
+
+```ts
+// utils/detect.ts
+import type { OutputType } from '../registry';
+
+export function detectOutputType(data: any): OutputType {
+ if (!data || typeof data !== 'object') return 'json';
+ if (data.response || data.thinking) return 'markdown';
+ if (data.query && Array.isArray(data.results)) return 'search_results';
+ if (data.output !== undefined || data.console_output) return 'code_output';
+ if (data.stdout !== undefined && data.command !== undefined) return 'shell';
+ if (data.content && data.file_path) return 'file_content';
+ if (data.operation && data.file_path) return 'file_op';
+ if (data.entries || data.matches) return 'file_list';
+ if (Array.isArray(data.items) && data.item_count !== undefined) return 'document';
+ if (data.todos) return 'todo';
+ return 'json';
+}
+```
+
+## Migration plan
+
+| Phase | Work | Effort |
+|---|---|---|
+| **A** | Add `output_type` field to all backend handlers (11 handler files) | 1 hour |
+| **B** | Install `react-json-view-lite`, create `components/output/` directory structure, implement `registry.ts` + `OutputPanel.tsx` + `OutputCard.tsx` | 2 hours |
+| **C** | Implement `MarkdownRenderer` + `JsonRenderer` + `ErrorRenderer` (covers 80% of output) | 1 hour |
+| **D** | Implement `ShellRenderer` + `CodeRenderer` + `FileContentRenderer` + `FileListRenderer` | 2 hours |
+| **E** | Implement `SearchRenderer` + `TodoRenderer` + `TableRenderer` | 2 hours |
+| **F** | Replace `NodeOutputPanel` import in `OutputSection.tsx` with new `OutputPanel` | 30 min |
+| **G** | Delete old `NodeOutputPanel.tsx` + `OutputDisplayPanel.tsx` | 10 min |
+| **H** | Verify all node types render correctly | 1 hour |
+
+Total: ~10 hours across 8 phases. Each phase is independently shippable.
+
+## Dependencies to add
+
+```bash
+pnpm add react-json-view-lite # ~3 KB, JSON tree viewer with dark mode
+```
+
+Everything else (`ReactMarkdown`, `remarkGfm`, `remarkBreaks`, `prismjs`, `@tanstack/react-table`, `@tailwindcss/typography`) is already installed.
+
+## What NOT to build
+
+- Custom JSON syntax highlighter (use `react-json-view-lite`)
+- Custom markdown CSS (use Tailwind `prose`)
+- Custom type detection DSL (simple `if` chain in `detect.ts` is sufficient)
+- Server-side rendering of output HTML (keep it client-side, same as Vercel/OpenWebUI)
+- Per-node-type rendering logic in the dispatcher (renderers are per-OUTPUT-TYPE, not per-node-type)
+
+## References
+
+- Vercel AI SDK message parts: https://vercel.com/blog/ai-sdk-6
+- react-json-view-lite: https://www.npmjs.com/package/react-json-view-lite
+- Tailwind Typography: https://tailwindcss.com/docs/plugins/typography
+- Shadcn Collapsible: https://ui.shadcn.com/docs/components/collapsible
+- n8n binary data: https://ryanandmattdatascience.com/n8n-binary-data/
+- Open WebUI tool rendering: https://deepwiki.com/open-webui/open-webui/6.3-tool-execution-system
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b802579c..02079eec 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -44,6 +44,9 @@ importers:
'@radix-ui/react-dialog':
specifier: ^1.1.15
+ '@tailwindcss/typography':
+ specifier: ^0.5.19
+ version: 0.5.19([email protected])
'@tanstack/react-query':
specifier: ^5
version: 5.99.0([email protected])
@@ -116,6 +119,9 @@ importers:
react-js-cron:
specifier: ^5.2.0
+ react-json-view-lite:
+ specifier: ^2.5.0
+ version: 2.5.0([email protected])
react-markdown:
specifier: ^10.1.0
version: 10.1.0(@types/[email protected])([email protected])
@@ -1424,6 +1430,11 @@ packages:
peerDependencies:
react: '>= 16.3.0'
+ '@tailwindcss/[email protected]':
+ resolution: {integrity: sha512-w31dd8HOx3k9vPtcQh5QHP9GwKcgbMp87j58qi6xgiBnFFtKEAgCWnDw4qUT8aHwkCp8bKvb/KGKWWHedP0AAg==}
+ peerDependencies:
+ tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1'
+
'@tanstack/[email protected]':
resolution: {integrity: sha512-3Jv3WQG0BCcH7G+7lf/bP8QyBfJOXeY+T08Rin3GZ1bshvwlbPt7NrDHMEzGdKIOmOzvIQmxjk28YEQX60k7pQ==}
@@ -2070,6 +2081,11 @@ packages:
resolution: {integrity: sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==}
+ resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}
+ engines: {node: '>=4'}
+ hasBin: true
+
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
@@ -3493,6 +3509,10 @@ packages:
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}
@@ -3862,6 +3882,12 @@ packages:
react: '>=17.0.0'
react-dom: '>=17.0.0'
+ resolution: {integrity: sha512-tk7o7QG9oYyELWHL8xiMQ8x4WzjCzbWNyig3uexmkLb54r8jO0yH3WCWx8UZS0c49eSA4QUmG5caiRJ8fAn58g==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ react: ^18.0.0 || ^19.0.0
+
resolution: {integrity: sha512-fzmrwMBNGIAiDIrdFMV3NvJhUNl01QC9EMcI8SP7osg51N4j+z6w4tx9i2yWxEEXZ2armLV6EtkFd3KST8PYiA==}
peerDependencies:
@@ -6016,6 +6042,11 @@ snapshots:
dependencies:
react: 19.2.1
+ dependencies:
+ postcss-selector-parser: 6.0.10
+ tailwindcss: 4.1.17
+
'@tanstack/[email protected]': {}
@@ -6816,6 +6847,8 @@ snapshots:
css-color-keywords: 1.0.0
postcss-value-parser: 4.2.0
+
@@ -8696,6 +8729,11 @@ snapshots:
+ dependencies:
+ cssesc: 3.0.0
+ util-deprecate: 1.0.2
+
@@ -9157,6 +9195,10 @@ snapshots:
react: 19.2.1
react-dom: 19.2.1([email protected])
+ dependencies:
+ react: 19.2.1
+
dependencies:
'@babel/runtime': 7.28.4