Skip to content

Self-improving AI Employees for everyone

feat(panels): live Context/Memory viewing, themed transcript, success-glow fade

trohitg9abb1ea84cf6
diff --git a/client/src/components/parameterPanel/ContextPanel.tsx b/client/src/components/parameterPanel/ContextPanel.tsx
index 96726e9b..9cdade74 100644
--- a/client/src/components/parameterPanel/ContextPanel.tsx
+++ b/client/src/components/parameterPanel/ContextPanel.tsx
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import JsonView from '@uiw/react-json-view';
-import { Loader2, RefreshCw, ShieldCheck, Trash2 } from 'lucide-react';
+import { Loader2, RefreshCw, ShieldCheck, Trash2, Wrench } from 'lucide-react';
import { toast } from 'sonner';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
@@ -14,14 +14,27 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { useWebSocket } from '@/contexts/WebSocketContext';
+import { cn } from '@/lib/utils';
+import { formatTimestamp, tryParseJson } from '@/utils/formatters';
+
+interface ToolCallView {
+ id?: string;
+ name?: string;
+ args?: unknown;
+ raw_arguments?: string;
+ parse_error?: string;
+}
interface ConversationMessage {
role?: string;
content?: unknown;
- tool_calls?: unknown[];
+ tool_calls?: ToolCallView[];
tool_call_id?: string;
name?: string;
+ /** Stamped by the store when the message first persisted. */
+ ts?: string;
}
interface ConversationMeta {
@@ -52,45 +65,107 @@ interface ContextPanelProps {
workflowId?: string;
}
-const conversationValue = (meta: {
- generation?: number | null;
- agent_node_id?: string | null;
-}) => `${meta.generation ?? ''}:${meta.agent_node_id ?? ''}`;
-
const contextQueryKey = (
workflowId: string | undefined,
nodeId: string,
- selected: string,
-) => ['agentContext', workflowId ?? '', nodeId, selected] as const;
+ agent: string,
+) => ['agentContext', workflowId ?? '', nodeId, agent] as const;
+
+/** Per-role card treatment — same tokens the chat surface uses
+ * (ConsolePanel: user bubbles on `bg-node-agent-soft`, bot bubbles on
+ * `bg-bg-elevated`), so every theme's palette carries over. */
+const ROLE_CARD: Record<string, string> = {
+ user: 'bg-node-agent-soft border-border',
+ assistant: 'bg-bg-elevated border-border-default',
+ tool: 'bg-card border-border',
+ system: 'bg-card border-border',
+};
+
+/** Route a value to the themed JSON tree when it is (or parses to) an
+ * object; fall back to readable text. Tool payloads arrive as serialized
+ * JSON strings, which read as noise without the tree. The tree paints on
+ * the per-theme `--code-*` surface via the global `--w-rjv-*` mapping. */
+const JsonOrText: React.FC<{
+ value: unknown;
+ collapsed?: number;
+ mono?: boolean;
+}> = ({ value, collapsed = 2, mono = false }) => {
+ if (typeof value === 'string') {
+ const parsed = tryParseJson(value);
+ if (parsed) {
+ return (
+ <div className="overflow-x-auto rounded-md border border-[var(--code-border)] bg-[var(--code-bg)] p-2">
+ <JsonView value={parsed} collapsed={collapsed} displayDataTypes={false} />
+ </div>
+ );
+ }
+ return (
+ <div
+ className={cn(
+ 'text-sm whitespace-pre-wrap',
+ mono
+ ? 'font-mono rounded-md border border-[var(--code-border)] bg-[var(--code-bg)] p-2 text-[var(--code-text)]'
+ : 'text-foreground',
+ )}
+ >
+ {value}
+ </div>
+ );
+ }
+ if (value != null && typeof value === 'object') {
+ return (
+ <div className="overflow-x-auto rounded-md border border-[var(--code-border)] bg-[var(--code-bg)] p-2">
+ <JsonView
+ value={value as object}
+ collapsed={collapsed}
+ displayDataTypes={false}
+ />
+ </div>
+ );
+ }
+ if (value == null) return null;
+ return (
+ <div className="text-sm whitespace-pre-wrap text-foreground">
+ {String(value)}
+ </div>
+ );
+};
-/** Authorized, query-backed viewer for the plain conversation store.
+/** Authorized, query-backed viewer for the agent's live conversation.
*
- * One conversation per (workflow, generation, agent node); this panel lists
- * the stored conversations and renders the selected transcript. It never
- * reads transcript data from workflow params, node status, or websocket
- * broadcasts — `context.updated` broadcasts only trigger a refetch through
- * the authorized `get_agent_context` handler.
+ * Shows the CURRENT context only — the newest workflow generation, exactly
+ * what the agent loads on its next firing. It never reads transcript data
+ * from workflow params, node status, or websocket broadcasts —
+ * `context.updated` broadcasts only trigger a refetch through the
+ * authorized `get_agent_context` handler.
*/
const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
const { sendRequest } = useWebSocket();
const queryClient = useQueryClient();
- // '' = server default (the newest stored conversation).
- const [selected, setSelected] = useState<string>('');
- const [selectedGeneration, selectedAgent] = selected
- ? selected.split(/:(.*)/s, 2)
- : ['', ''];
+ // '' = server default (the newest stored conversation). Only meaningful
+ // when several agents share this Context node.
+ const [selectedAgent, setSelectedAgent] = useState<string>('');
+ // 'formatted' renders role cards; 'raw' shows the stored wire messages
+ // verbatim — the exact JSON the agent's next firing loads.
+ const [view, setView] = useState<'formatted' | 'raw'>('formatted');
- const queryKey = contextQueryKey(workflowId, nodeId, selected);
+ const queryKey = contextQueryKey(workflowId, nodeId, selectedAgent);
const contextQuery = useQuery<ContextResponse, Error>({
queryKey,
queryFn: () =>
sendRequest<ContextResponse>('get_agent_context', {
workflow_id: workflowId,
context_node_id: nodeId,
- ...(selectedGeneration ? { generation: Number(selectedGeneration) } : {}),
...(selectedAgent ? { agent_node_id: selectedAgent } : {}),
}),
enabled: !!workflowId && !!nodeId,
+ // The global default is refetchOnMount: false ("trust the cache; the
+ // broadcast bridge keeps it in sync"), but a conversation grows while
+ // this panel is CLOSED — the `context.updated` invalidation has no
+ // active observer then, so a remount must always fetch fresh or the
+ // panel opens on stale data until a manual Refresh.
+ refetchOnMount: 'always',
+ staleTime: 0,
});
const snapshot = contextQuery.data?.context ?? {};
const conversations = snapshot.conversations ?? [];
@@ -110,7 +185,7 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
...(snapshot.agent_node_id ? { agent_node_id: snapshot.agent_node_id } : {}),
}),
onSuccess: async () => {
- setSelected('');
+ setSelectedAgent('');
await invalidateContext();
toast.success('Conversation cleared');
},
@@ -133,12 +208,23 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
<div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-6">
<div className="flex flex-wrap items-start justify-between gap-3">
<div>
- <h3 className="text-base font-semibold text-foreground">Agent Conversation</h3>
+ <h3 className="font-display tracking-[var(--type-tracking-display)] [text-transform:var(--type-uppercase)] text-base font-semibold text-fg-default">
+ Agent Conversation
+ </h3>
<p className="text-xs text-muted-foreground">
- Stored conversation for each connected agent, one per workflow generation.
+ The connected agent's live context — exactly what it loads on its next turn.
</p>
</div>
- <div className="flex flex-wrap gap-2">
+ <div className="flex flex-wrap items-center gap-2">
+ <Tabs
+ value={view}
+ onValueChange={(next) => setView(next as 'formatted' | 'raw')}
+ >
+ <TabsList>
+ <TabsTrigger value="formatted">Formatted</TabsTrigger>
+ <TabsTrigger value="raw">Raw</TabsTrigger>
+ </TabsList>
+ </Tabs>
<Button
variant="outline"
size="sm"
@@ -162,17 +248,17 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
{conversations.length > 1 && (
<Select
- value={selected || conversationValue(snapshot)}
- onValueChange={setSelected}
+ value={selectedAgent || (snapshot.agent_node_id ?? '')}
+ onValueChange={setSelectedAgent}
>
<SelectTrigger className="w-full max-w-md">
- <SelectValue placeholder="Select a conversation" />
+ <SelectValue placeholder="Select an agent" />
</SelectTrigger>
<SelectContent>
{conversations.map((meta) => (
- <SelectItem key={conversationValue(meta)} value={conversationValue(meta)}>
- Generation {meta.generation} · {meta.agent_node_id} ·{' '}
- {meta.message_count} message{meta.message_count === 1 ? '' : 's'}
+ <SelectItem key={meta.agent_node_id} value={meta.agent_node_id}>
+ {meta.agent_node_id} · {meta.message_count} message
+ {meta.message_count === 1 ? '' : 's'}
</SelectItem>
))}
</SelectContent>
@@ -181,13 +267,16 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
{snapshot.agent_node_id && (
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
- <Badge variant="outline">Generation {snapshot.generation ?? '—'}</Badge>
<Badge variant="outline">{snapshot.agent_node_id}</Badge>
<span>
{snapshot.message_count ?? 0} message
{(snapshot.message_count ?? 0) === 1 ? '' : 's'}
</span>
- {snapshot.updated_at && <span>updated {snapshot.updated_at}</span>}
+ {snapshot.updated_at && (
+ <span className="font-mono text-[11px] tabular-nums">
+ updated {formatTimestamp(snapshot.updated_at)}
+ </span>
+ )}
</div>
)}
@@ -202,12 +291,21 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
<div className="rounded-md border border-dashed border-border p-8 text-center text-sm text-muted-foreground">
No stored conversation yet.
</div>
+ ) : view === 'raw' ? (
+ // The stored wire messages verbatim, on the per-theme code surface —
+ // the exact JSON the agent's next firing loads.
+ <div className="overflow-x-auto rounded-md border border-[var(--code-border)] bg-[var(--code-bg)] p-2">
+ <JsonView value={messages} collapsed={2} displayDataTypes={false} />
+ </div>
) : (
<div className="flex flex-col gap-2">
{messages.map((message, index) => (
<div
key={index}
- className="rounded-md border border-border bg-card p-3"
+ className={cn(
+ 'rounded-md border p-3',
+ ROLE_CARD[message.role || ''] || 'bg-card border-border',
+ )}
>
<div className="mb-1 flex flex-wrap items-center gap-2">
<Badge variant="outline">{message.role || 'message'}</Badge>
@@ -216,26 +314,40 @@ const ContextPanel: React.FC<ContextPanelProps> = ({ nodeId, workflowId }) => {
{message.name}
</span>
)}
+ {message.ts && (
+ <span className="ml-auto font-mono text-[11px] tabular-nums text-muted-foreground">
+ {formatTimestamp(message.ts)}
+ </span>
+ )}
</div>
- {typeof message.content === 'string' && message.content ? (
- <div className="whitespace-pre-wrap text-sm text-foreground">
- {message.content}
- </div>
- ) : message.content != null ? (
- <JsonView
- value={message.content as object}
- collapsed={2}
- displayDataTypes={false}
- />
- ) : null}
+ <JsonOrText value={message.content} mono={message.role === 'tool'} />
{(message.tool_calls?.length ?? 0) > 0 && (
- <div className="mt-2">
- <div className="mb-1 text-xs text-muted-foreground">Tool calls</div>
- <JsonView
- value={message.tool_calls as object}
- collapsed={1}
- displayDataTypes={false}
- />
+ <div className="mt-2 flex flex-col gap-2">
+ {message.tool_calls!.map((call, callIndex) => (
+ <div
+ key={call.id || callIndex}
+ className="rounded-md border border-[var(--code-border)] bg-[var(--code-bg)] p-2"
+ >
+ <div className="mb-1 flex flex-wrap items-center gap-2">
+ <Wrench className="h-3.5 w-3.5 text-[var(--code-comment)]" />
+ <span className="font-mono text-xs font-medium text-[var(--code-text)]">
+ {call.name || 'tool call'}
+ </span>
+ {call.parse_error && (
+ <Badge variant="warning">invalid arguments</Badge>
+ )}
+ </div>
+ <JsonOrText
+ value={
+ call.args && Object.keys(call.args as object).length > 0
+ ? call.args
+ : call.raw_arguments
+ }
+ collapsed={1}
+ mono
+ />
+ </div>
+ ))}
</div>
)}
</div>
diff --git a/client/src/components/parameterPanel/MemoryToolPanel.tsx b/client/src/components/parameterPanel/MemoryToolPanel.tsx
index 5f371a84..de8d792b 100644
--- a/client/src/components/parameterPanel/MemoryToolPanel.tsx
+++ b/client/src/components/parameterPanel/MemoryToolPanel.tsx
@@ -122,6 +122,11 @@ const MemoryToolPanel: React.FC<MemoryToolPanelProps> = ({
limit: PAGE_SIZE,
}),
enabled: !!workflowId && !!nodeId,
+ // Same contract as ContextPanel: the agent mutates memory while this
+ // panel is CLOSED, so the `memory.updated` invalidation has no active
+ // observer then — a remount must always fetch fresh.
+ refetchOnMount: 'always',
+ staleTime: 0,
});
const itemQuery = useQuery<MemoryItemResponse, Error>({
queryKey: ['memoryItem', workflowId ?? '', nodeId, selectedId ?? 'new'],
@@ -132,6 +137,8 @@ const MemoryToolPanel: React.FC<MemoryToolPanelProps> = ({
memory_id: selectedId,
}),
enabled: !!workflowId && !!selectedId,
+ refetchOnMount: 'always',
+ staleTime: 0,
});
const selected = itemQuery.data?.item ?? itemQuery.data?.memory;
diff --git a/client/src/components/parameterPanel/__tests__/ContextMemoryPanels.test.tsx b/client/src/components/parameterPanel/__tests__/ContextMemoryPanels.test.tsx
index 9ba31795..6a4129b2 100644
--- a/client/src/components/parameterPanel/__tests__/ContextMemoryPanels.test.tsx
+++ b/client/src/components/parameterPanel/__tests__/ContextMemoryPanels.test.tsx
@@ -17,7 +17,7 @@ beforeEach(() => {
});
describe('ContextPanel', () => {
- it('loads the stored conversation through get_agent_context', async () => {
+ it('loads the live conversation through get_agent_context', async () => {
sendRequest.mockImplementation(async (operation: string) => {
if (operation === 'get_agent_context') {
return {
@@ -27,17 +27,33 @@ describe('ContextPanel', () => {
workflow_id: 'wf-1',
generation: 2,
agent_node_id: 'agent-1',
- message_count: 2,
+ message_count: 3,
updated_at: '2026-08-18T00:00:00Z',
},
],
generation: 2,
agent_node_id: 'agent-1',
updated_at: '2026-08-18T00:00:00Z',
- message_count: 2,
+ message_count: 3,
messages: [
{ role: 'user', content: 'hello agent' },
- { role: 'assistant', content: 'hello operator' },
+ {
+ role: 'assistant',
+ content: '',
+ tool_calls: [
+ {
+ id: 'call-1',
+ name: 'memory',
+ args: { operation: 'remember', content: 'launch Tuesday' },
+ },
+ ],
+ },
+ {
+ role: 'tool',
+ name: 'memory',
+ tool_call_id: 'call-1',
+ content: '{"operation": "remember", "memory": {"id": "m1"}}',
+ },
],
},
};
@@ -48,8 +64,16 @@ describe('ContextPanel', () => {
render(<ContextPanel nodeId="ctx-1" workflowId="wf-1" />);
expect(await screen.findByText('hello agent')).toBeInTheDocument();
- expect(screen.getByText('hello operator')).toBeInTheDocument();
- expect(screen.getByText('Generation 2')).toBeInTheDocument();
+ // The panel shows the live context only — no generation selector or
+ // generation label anywhere.
+ expect(screen.queryByText(/Generation/)).not.toBeInTheDocument();
+ // Tool calls render as structured entries, not raw dumped text.
+ expect(screen.getAllByText('memory').length).toBeGreaterThan(0);
+ // The JSON-string tool result routes through the tree viewer: its keys
+ // render as tree nodes rather than one messy serialized string.
+ expect(
+ screen.queryByText('{"operation": "remember", "memory": {"id": "m1"}}'),
+ ).not.toBeInTheDocument();
expect(sendRequest).toHaveBeenCalledWith(
'get_agent_context',
expect.objectContaining({
@@ -100,6 +124,48 @@ describe('ContextPanel', () => {
);
});
+ it('offers a raw view of the stored wire messages', async () => {
+ sendRequest.mockImplementation(async (operation: string) => {
+ if (operation === 'get_agent_context') {
+ return {
+ context: {
+ conversations: [
+ {
+ workflow_id: 'wf-1',
+ generation: 2,
+ agent_node_id: 'agent-1',
+ message_count: 1,
+ updated_at: null,
+ },
+ ],
+ generation: 2,
+ agent_node_id: 'agent-1',
+ updated_at: null,
+ message_count: 1,
+ messages: [{ role: 'user', content: 'plain prose message' }],
+ },
+ };
+ }
+ return {};
+ });
+ const user = userEvent.setup();
+ render(<ContextPanel nodeId="ctx-1" workflowId="wf-1" />);
+
+ await screen.findByText('plain prose message');
+ // Formatted view renders role cards (the chat-token surface class).
+ expect(document.querySelector('.bg-node-agent-soft')).not.toBeNull();
+
+ await user.click(screen.getByRole('tab', { name: 'Raw' }));
+
+ // The formatted cards are gone; the stored wire dicts render verbatim
+ // in the themed JSON tree (the message content becomes a tree value).
+ expect(document.querySelector('.bg-node-agent-soft')).toBeNull();
+ const treeValues = Array.from(
+ document.querySelectorAll('.w-rjv-value'),
+ ).map((node) => node.textContent);
+ expect(treeValues).toContain('plain prose message');
+ });
+
it('shows the empty state when nothing is stored', async () => {
sendRequest.mockImplementation(async (operation: string) => {
if (operation === 'get_agent_context') {
diff --git a/client/src/contexts/WebSocketContext.tsx b/client/src/contexts/WebSocketContext.tsx
index e6d05530..43c1d38f 100644
--- a/client/src/contexts/WebSocketContext.tsx
+++ b/client/src/contexts/WebSocketContext.tsx
@@ -1076,6 +1076,17 @@ export const WebSocketProvider: React.FC<{ children: React.ReactNode }> = ({ chi
break;
}
+ case 'memory.updated': {
+ // CloudEvents-typed memory mutation from
+ // server/nodes/tool/simple_memory/_events.py — fired after a
+ // durable remember/update/forget/clear from either writer (agent
+ // tool call or panel action). Identity-only payload; the panel
+ // refetches through the authorized `list_memory_items` handler.
+ void queryClient.invalidateQueries({ queryKey: ['memoryItems'] });
+ void queryClient.invalidateQueries({ queryKey: ['memoryItem'] });
+ break;
+ }
+
case 'todos_updated': {
// CloudEvents-typed todo-list change from
// server/nodes/tool/write_todos/_events.py, emitted via the
diff --git a/client/src/styles/canvasAnimations.ts b/client/src/styles/canvasAnimations.ts
index 78b3cf62..fb4b59da 100644
--- a/client/src/styles/canvasAnimations.ts
+++ b/client/src/styles/canvasAnimations.ts
@@ -35,6 +35,15 @@ const KEYFRAMES = `
0% { stroke-dashoffset: 24; }
100% { stroke-dashoffset: 0; }
}
+
+ /* One-shot success confirmation, mirroring the node-completed-fade in
+ themes/animations.css: terminal statuses persist in the store, so a
+ static success stroke left every traversed edge green until the next
+ run. Hold briefly, then settle back to the resting stroke. */
+ @keyframes edgeCompletedFade {
+ 0%, 45% { stroke: var(--success); }
+ 100% { stroke: var(--edge-stroke); }
+ }
`;
const EDGE_STATUS_STYLES = `
@@ -59,8 +68,15 @@ const EDGE_STATUS_STYLES = `
}
.react-flow__edge.completed path {
- stroke: var(--success) !important;
stroke-width: var(--edge-stroke-width-done) !important;
+ animation: edgeCompletedFade 2.8s ease-out forwards;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .react-flow__edge.completed path {
+ animation: none;
+ stroke: var(--success) !important;
+ }
}
.react-flow__edge.error path {
diff --git a/client/src/themes/animations.css b/client/src/themes/animations.css
index 6811e450..201f4d4a 100644
--- a/client/src/themes/animations.css
+++ b/client/src/themes/animations.css
@@ -124,6 +124,23 @@
* a gentle, slower heartbeat distinct from the one-shot execution pulse. Uses
* --node-pulse-color so it reads on any theme background.
* ========================================================================== */
+/* One-shot success confirmation for canvas nodes (base.css `.completed`
+ rule). Holds the success ring briefly, then fades to nothing — terminal
+ statuses persist in the store, so without the fade every completed
+ agent/tool node kept its green ring until the next run. */
+@keyframes node-completed-fade {
+ 0%, 45% {
+ box-shadow:
+ 0 0 0 1px var(--success),
+ 0 0 14px color-mix(in srgb, var(--success) var(--tint-glow), transparent);
+ }
+ 100% {
+ box-shadow:
+ 0 0 0 1px transparent,
+ 0 0 14px transparent;
+ }
+}
+
@keyframes trigger-listening {
0%, 100% {
box-shadow:
diff --git a/client/src/themes/base.css b/client/src/themes/base.css
index 8d7093af..e10969c1 100644
--- a/client/src/themes/base.css
+++ b/client/src/themes/base.css
@@ -456,13 +456,30 @@ html[data-page-hidden] *::after {
* selectors when they want a material-specific outcome glow.
* ============================================================================ */
+/* Success is a moment, not a state. Terminal statuses persist in the
+ * nodeStatusStore until the next run, so a static ring here left every
+ * agent/tool node glowing success-green indefinitely after completion.
+ * The one-shot fade (keyframes in animations.css) confirms the outcome,
+ * then returns the node to its normal border. Errors below stay painted —
+ * a failure must remain visible until acted on. */
.sq-node[data-status="success"] .sq-node-box,
.react-flow__node[data-status="success"] .node,
.react-flow__node.completed .sq-node-box,
.react-flow__node.completed .node {
- box-shadow:
- 0 0 0 1px var(--success),
- 0 0 14px color-mix(in srgb, var(--success) var(--tint-glow), transparent);
+ animation: node-completed-fade 2.8s ease-out forwards;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .sq-node[data-status="success"] .sq-node-box,
+ .react-flow__node[data-status="success"] .node,
+ .react-flow__node.completed .sq-node-box,
+ .react-flow__node.completed .node {
+ /* No fade motion: keep the static ring so the outcome stays legible. */
+ animation: none;
+ box-shadow:
+ 0 0 0 1px var(--success),
+ 0 0 14px color-mix(in srgb, var(--success) var(--tint-glow), transparent);
+ }
}
.sq-node[data-status="error"] .sq-node-box,