From 3f4b3a7ddbd09ada65987e842db1959930c1ed48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebubekir=20Y=C4=B1lmaz?= Date: Tue, 17 Nov 2026 10:53:31 +0300 Subject: [PATCH 1/2] Add mock output support for pinned blueprint steps --- api/src/functions/task.ts | 39 +++++++++++++++++++++++++++++++++++ api/src/lib/blueprintNodes.ts | 10 +++++++++ api/src/schemas/Blueprint.ts | 2 ++ api/src/schemas/Node.ts | 10 +++++++++ 4 files changed, 61 insertions(+) diff --git a/api/src/functions/task.ts b/api/src/functions/task.ts index 867da617..50cc50a8 100644 --- a/api/src/functions/task.ts +++ b/api/src/functions/task.ts @@ -1,10 +1,12 @@ import Agent from "../models/Agent"; +import Blueprint from "../models/Blueprint"; import LLMLog from "../models/LLMLog"; import Step from "../models/Step"; import Supervising from "../models/Supervising"; import Task from "../models/Task"; import { Op, col, fn } from "sequelize"; import { event } from "@canmingir/link-express/event/client"; +import { pinMockOutputOf, pinOutputModeOf } from "../lib/blueprintNodes"; import llmLog from "./llmLog"; async function create({ @@ -432,6 +434,43 @@ async function resumePinnedStep({ throw new Error(`Pinned step not found: ${stepId}`); } + const task = await Task.findOne({ where: { id: taskId } }); + const blueprint = task?.blueprintId + ? await Blueprint.findByPk(task.blueprintId) + : null; + const node = blueprint?.nodes?.find( + (n: { id: string }) => n.id === step.nodeId, + ); + + if (pinOutputModeOf(node) === "MOCK") { + const mockOutput = pinMockOutputOf(node) ?? ""; + const comment = "Resumed: using mock output."; + + const [updated] = await Step.update( + { status: "COMPLETED", result: mockOutput, comment }, + { where: { id: stepId, status: "PINNED" } }, + ); + + if (updated === 0) { + throw new Error(`Pinned step not found: ${stepId}`); + } + + await event.publish("STEP_COMPLETED", { + taskId, + stepId, + action: step.action, + parameters: step.parameters, + result: mockOutput, + }); + + return { + ...step.toJSON(), + status: "COMPLETED", + result: mockOutput, + comment, + }; + } + const comment = "Resumed: dispatching the real request."; const [updated] = await Step.update( diff --git a/api/src/lib/blueprintNodes.ts b/api/src/lib/blueprintNodes.ts index d58c5f56..c2ba0b13 100644 --- a/api/src/lib/blueprintNodes.ts +++ b/api/src/lib/blueprintNodes.ts @@ -87,6 +87,16 @@ export function isPinnedNode(node: any) { return node?.properties?.pinned === true; } +export function pinOutputModeOf(node: any): "DEFAULT" | "MOCK" { + return node?.properties?.pinOutputMode === "MOCK" ? "MOCK" : "DEFAULT"; +} + +export function pinMockOutputOf(node: any): string | undefined { + return typeof node?.properties?.pinMockOutput === "string" + ? node.properties.pinMockOutput + : undefined; +} + export function forceAllNodes(nodes: T[]) { return nodes.map((node) => ({ ...node, diff --git a/api/src/schemas/Blueprint.ts b/api/src/schemas/Blueprint.ts index 246b23ae..e9158485 100644 --- a/api/src/schemas/Blueprint.ts +++ b/api/src/schemas/Blueprint.ts @@ -65,6 +65,8 @@ const Blueprint = { targetBlueprintId: z.string().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), fields: ApiFieldsSchema.optional(), strict: z.boolean().optional(), timeout: ApiTimeout.optional(), diff --git a/api/src/schemas/Node.ts b/api/src/schemas/Node.ts index 67315e4a..1764dce3 100644 --- a/api/src/schemas/Node.ts +++ b/api/src/schemas/Node.ts @@ -14,6 +14,8 @@ const ConditionNode = z.object({ pseudocodeEnabled: z.boolean().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), }), }); @@ -29,6 +31,8 @@ const NormalNode = z.object({ pseudocodeEnabled: z.boolean().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), parameters: z.record(z.string(), z.unknown()).optional(), }), }); @@ -45,6 +49,8 @@ const SwitchNode = z.object({ pseudocodeEnabled: z.boolean().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), cases: z .array( z.object({ @@ -70,6 +76,8 @@ const HandoffNode = z.object({ pseudocodeEnabled: z.boolean().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), }), }); @@ -87,6 +95,8 @@ const ApprovalNode = z.object({ pseudocodeEnabled: z.boolean().optional(), force: z.boolean().optional(), pinned: z.boolean().optional(), + pinOutputMode: z.enum(["DEFAULT", "MOCK"]).optional(), + pinMockOutput: z.string().optional(), }), }); From 78619b62ad1cbab14039517250360934a3348402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebubekir=20Y=C4=B1lmaz?= Date: Tue, 17 Nov 2026 10:53:56 +0300 Subject: [PATCH 2/2] Add PinNodeDialog for configuring pinned step mock output --- .../BlueprintFlow/PinNodeDialog.tsx | 178 ++++++++++++++++++ .../SettingsDialog/SettingsDialog.tsx | 34 ++++ .../src/layouts/BlueprintDrawerLayout.tsx | 11 ++ .../AgentDevToolWidget/AgentDevToolWidget.tsx | 4 +- .../BlueprintFlowWidget.tsx | 78 +++++++- 5 files changed, 294 insertions(+), 11 deletions(-) create mode 100644 dashboard/src/components/BlueprintFlow/PinNodeDialog.tsx diff --git a/dashboard/src/components/BlueprintFlow/PinNodeDialog.tsx b/dashboard/src/components/BlueprintFlow/PinNodeDialog.tsx new file mode 100644 index 00000000..22a7b263 --- /dev/null +++ b/dashboard/src/components/BlueprintFlow/PinNodeDialog.tsx @@ -0,0 +1,178 @@ +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + FormControl, + FormControlLabel, + Radio, + RadioGroup, + TextField, + Typography, +} from "@mui/material"; +import { useEffect, useState } from "react"; + +const FALLBACK_MOCK_OUTPUT = `{ + "result": "" +}`; + +export type PinOutputMode = "DEFAULT" | "MOCK"; + +export type PinNodeProperties = { + pinned: true; + pinOutputMode: PinOutputMode; + pinMockOutput?: string; +}; + +function blankMockOutput(outputFields?: string[]) { + if (!outputFields?.length) return FALLBACK_MOCK_OUTPUT; + + const skeleton = Object.fromEntries(outputFields.map((field) => [field, ""])); + return JSON.stringify(skeleton, null, 2); +} + +export default function PinNodeDialog({ + open, + node, + outputFields, + onClose, + onSave, + onUnpin, +}: { + open: boolean; + node?: { + id: string; + label: string; + raw?: { properties?: Record }; + }; + outputFields?: string[]; + onClose: () => void; + onSave: (properties: PinNodeProperties) => void; + onUnpin: () => void; +}) { + const [mode, setMode] = useState("DEFAULT"); + const [mockDraft, setMockDraft] = useState(""); + + useEffect(() => { + if (!open || !node) return; + const properties = node.raw?.properties ?? {}; + setMode(properties.pinOutputMode === "MOCK" ? "MOCK" : "DEFAULT"); + setMockDraft( + typeof properties.pinMockOutput === "string" && properties.pinMockOutput + ? properties.pinMockOutput + : blankMockOutput(outputFields) + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [open, node]); + + const isMock = mode === "MOCK"; + let jsonError: string | undefined; + if (isMock) { + try { + JSON.parse(mockDraft); + } catch { + jsonError = "Invalid JSON"; + } + } + + const isPinned = Boolean(node?.raw?.properties?.pinned); + + const handleSave = () => { + onSave({ + pinned: true, + pinOutputMode: mode, + ...(isMock ? { pinMockOutput: mockDraft } : {}), + }); + }; + + return ( + theme.zIndex.modal + 3 }} + slotProps={{ + paper: { sx: { borderRadius: 2 } }, + }} + > + Pin node: {node?.label} + + + Test runs skip this step and return your mock JSON. Production + execution is not affected. + + + + Output source + + + setMode(e.target.value as PinOutputMode)} + > + } + label="Default" + /> + } + label="Mock output" + /> + + + + {isMock && ( + + + Mock output (JSON) + + setMockDraft(e.target.value)} + error={Boolean(jsonError)} + helperText={jsonError} + inputProps={{ + "aria-label": "Mock output JSON", + style: { + fontFamily: + '"JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace', + fontSize: 13, + }, + }} + /> + + )} + + + {isPinned ? ( + + ) : ( + + )} + + + + + + + ); +} diff --git a/dashboard/src/components/SettingsDialog/SettingsDialog.tsx b/dashboard/src/components/SettingsDialog/SettingsDialog.tsx index ff6f0153..fd4ac9a1 100644 --- a/dashboard/src/components/SettingsDialog/SettingsDialog.tsx +++ b/dashboard/src/components/SettingsDialog/SettingsDialog.tsx @@ -27,6 +27,8 @@ const SettingsDialog = ({ api = false, setApi, blueprintId, + debugMode = false, + setDebugMode, }: { showSettings: boolean; setShowSettings: (value: boolean) => void; @@ -39,6 +41,8 @@ const SettingsDialog = ({ api?: boolean; setApi?: (value: boolean) => void; blueprintId?: string; + debugMode?: boolean; + setDebugMode?: (value: boolean) => void; }) => { const theme = useTheme(); @@ -197,6 +201,36 @@ const SettingsDialog = ({ )} + + {setDebugMode && ( + <> + + Debug Mode + + + Shows developer-only controls on the canvas, such as pin + buttons on nodes. + + + + )} )} diff --git a/dashboard/src/layouts/BlueprintDrawerLayout.tsx b/dashboard/src/layouts/BlueprintDrawerLayout.tsx index e2ca7214..df6d3ee7 100644 --- a/dashboard/src/layouts/BlueprintDrawerLayout.tsx +++ b/dashboard/src/layouts/BlueprintDrawerLayout.tsx @@ -114,6 +114,14 @@ const BlueprintDrawerLayout = ({ "showconnections", false ); + const [debugMode] = useStorage( + "nuc", + "blueprintdrawerlayout", + "debugmode", + false + ); + const setDebugMode = (value: boolean) => + storage.set("nuc", "blueprintdrawerlayout", "debugmode", value); const [superviseChatOpen, setSuperviseChatOpen] = useState( !!supervise ); @@ -287,6 +295,7 @@ const BlueprintDrawerLayout = ({ liteMode={liteMode} api={api} showConnections={showConnections} + debugMode={debugMode} onSkillChange={setSkill} onSkillLoadingChange={setSkillLoading} onNodesChange={setLiveNodes} @@ -439,6 +448,8 @@ const BlueprintDrawerLayout = ({ api={api} setApi={setApi} blueprintId={selectedItem?.id} + debugMode={debugMode} + setDebugMode={setDebugMode} /> ); diff --git a/dashboard/src/widgets/AgentDevToolWidget/AgentDevToolWidget.tsx b/dashboard/src/widgets/AgentDevToolWidget/AgentDevToolWidget.tsx index 55f4698d..5ca445a5 100644 --- a/dashboard/src/widgets/AgentDevToolWidget/AgentDevToolWidget.tsx +++ b/dashboard/src/widgets/AgentDevToolWidget/AgentDevToolWidget.tsx @@ -127,11 +127,11 @@ const AgentDevToolWidget = ({ }, [conversations]); useEffect(() => { - if (open && sessionId) { + if (sessionId) { getSession(sessionId); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [open, sessionId]); + }, [sessionId]); useEffect(() => { if (!context) setContextOpen(false); diff --git a/dashboard/src/widgets/BlueprintFlowWidget/BlueprintFlowWidget.tsx b/dashboard/src/widgets/BlueprintFlowWidget/BlueprintFlowWidget.tsx index b9225d28..ebb374fa 100644 --- a/dashboard/src/widgets/BlueprintFlowWidget/BlueprintFlowWidget.tsx +++ b/dashboard/src/widgets/BlueprintFlowWidget/BlueprintFlowWidget.tsx @@ -3,6 +3,8 @@ import BlueprintFlow from "../../components/BlueprintFlow/BlueprintFlow"; import BlueprintFlowSkeleton from "../../components/Skeletons/BlueprintFlowSkeleton"; import NodeEditorWidget from "../NodeEditorWidget/NodeEditorWidget"; import type { ParameterBinding } from "../../components/BlueprintFlow/NodeConnectionOverlay"; +import PinNodeDialog from "../../components/BlueprintFlow/PinNodeDialog"; +import type { PinNodeProperties } from "../../components/BlueprintFlow/PinNodeDialog"; import StartNode from "../../components/BlueprintFlow/StartNode/StartNode"; import type { SwitchCase } from "../../components/BlueprintFlow/helper"; import { publish } from "@nucleoidai/react-event"; @@ -65,6 +67,10 @@ function graphToNodes(graphData: DefinitionGraph) { ...(node.raw?.properties?.pinned && { pinned: true, }), + ...(node.raw?.properties?.pinOutputMode === "MOCK" && { + pinOutputMode: "MOCK", + pinMockOutput: node.raw?.properties?.pinMockOutput, + }), ...(node.nodeType === "NORMAL" && node.raw?.properties?.parameters && Object.keys(node.raw.properties.parameters).length > 0 && { @@ -142,6 +148,7 @@ function BlueprintFlowWidget({ liteMode = false, api, showConnections: showConnectionsProp, + debugMode = false, onDescriptionChange, onDescriptionLoadingChange, onSkillChange, @@ -176,6 +183,7 @@ function BlueprintFlowWidget({ liteMode?: boolean; api?: boolean; showConnections?: boolean; + debugMode?: boolean; onSave?: () => void; }) { const [graphData, setGraphData] = useState(null); @@ -667,29 +675,72 @@ function BlueprintFlowWidget({ setApiNodeId(null); }; + const [pinNodeId, setPinNodeId] = useState(null); + const handlePinNodeClick = (node: { id: string }) => { + setPinNodeId(node.id); + }; + + const pinNodeOutputFields = useMemo(() => { + const action = pinNodeId + ? graphData?.nodes?.[pinNodeId]?.action + : undefined; + if (!action) return undefined; + + const integration = allIntegrations.find((i) => i.action === action); + const outputProperties = integration?.outputSchema?.properties; + if (!outputProperties || Object.keys(outputProperties).length === 0) { + return undefined; + } + + return Object.keys(outputProperties); + }, [pinNodeId, graphData, allIntegrations]); + + const handlePinNodeSave = (properties: PinNodeProperties) => { setGraphData((prev) => { - if (!prev) return prev; - const targetNode = prev.nodes[node.id]; + if (!prev || !pinNodeId) return prev; + const targetNode = prev.nodes[pinNodeId]; if (!targetNode) return prev; - const wasPinned = Boolean(targetNode.raw?.properties?.pinned); + const rest = { ...targetNode.raw?.properties }; + delete rest.pinMockOutput; const currentNodes = { ...prev.nodes }; - currentNodes[node.id] = { + currentNodes[pinNodeId] = { ...targetNode, raw: { ...targetNode.raw, - properties: { - ...targetNode.raw?.properties, - pinned: !wasPinned, - }, + properties: { ...rest, ...properties }, }, }; return { ...prev, nodes: currentNodes }; }); setHasLocalChanges(true); + setPinNodeId(null); + }; + + const handleUnpinNode = () => { + setGraphData((prev) => { + if (!prev || !pinNodeId) return prev; + const targetNode = prev.nodes[pinNodeId]; + if (!targetNode) return prev; + + const rest = { ...targetNode.raw?.properties }; + delete rest.pinned; + delete rest.pinOutputMode; + delete rest.pinMockOutput; + + const currentNodes = { ...prev.nodes }; + currentNodes[pinNodeId] = { + ...targetNode, + raw: { ...targetNode.raw, properties: rest }, + }; + + return { ...prev, nodes: currentNodes }; + }); + setHasLocalChanges(true); + setPinNodeId(null); }; const handleEditNodeClick = (node) => { @@ -2130,7 +2181,7 @@ function BlueprintFlowWidget({ onFlowChange={handleFlowChange} onAddNodeClick={handleAddNodeClick} onEditNodeClick={handleEditNodeClick} - onPinNodeClick={handlePinNodeClick} + onPinNodeClick={debugMode ? handlePinNodeClick : undefined} onSwapBranchClick={handleSwapBranch} onDeleteNodeClick={handleDeleteNode} onSave={handleSaveFlow} @@ -2158,6 +2209,15 @@ function BlueprintFlowWidget({ onSave={handleApiNodeSave} /> + setPinNodeId(null)} + onSave={handlePinNodeSave} + onUnpin={handleUnpinNode} + /> +