From 7e07e502d44674292f526c6c5bf4420e0285f50e Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:31:09 +0000 Subject: [PATCH 01/17] feat: "results" exec var, abort on return value --- src/writer/workflows.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/writer/workflows.py b/src/writer/workflows.py index a7fe7a13..e3266edc 100644 --- a/src/writer/workflows.py +++ b/src/writer/workflows.py @@ -27,9 +27,9 @@ def run_workflow(session, component_id: str, execution_env: Dict): return_value = None try: for node in get_terminal_nodes(nodes): - tool = run_node(node, nodes, execution, session, execution_env) + run_node(node, nodes, execution, session, execution_env) for component_id, tool in execution.items(): - if tool and tool.return_value: + if tool and tool.return_value is not None: return_value = tool.return_value except BaseException as e: _generate_run_log(session, execution, "Failed workflow execution", "error") @@ -115,11 +115,17 @@ def run_node(target_node: "Component", nodes: List["Component"], execution: Dict if tool.outcome == out_id: matched_dependencies += 1 result = tool.result + if tool.return_value is not None: + return if len(dependencies) > 0 and matched_dependencies == 0: return - tool = tool_class(target_node, execution, session, execution_env | {"result": result}) + results = { + "result": result, + "results": { k:v.result for k,v in execution.items() } + } + tool = tool_class(target_node, execution, session, execution_env | results) try: start_time = time.time() From eea92367570f8f1e3f8f2f38815566d748466b9c Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:31:31 +0000 Subject: [PATCH 02/17] fix: Icons have a set font-weight 400 --- src/ui/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ui/index.html b/src/ui/index.html index 1e34d533..ba5bd974 100644 --- a/src/ui/index.html +++ b/src/ui/index.html @@ -23,6 +23,7 @@ font-family: 'Material Symbols Outlined Variable', sans-serif; font-size: 100%; font-style: normal; + font-weight: 400; } #app { From e56eb7868f2e4d94cea92c6b87115a15066b42d3 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:31:51 +0000 Subject: [PATCH 03/17] feat: Workflow blocks icons --- src/ui/public/components/workflows_addtostatelist.svg | 4 ++++ .../public/components/workflows_calleventhandler.svg | 9 +++++++++ src/ui/public/components/workflows_category_Logic.svg | 4 ++++ src/ui/public/components/workflows_category_Other.svg | 4 ++++ .../public/components/workflows_category_Writer.svg | 6 ++++++ src/ui/public/components/workflows_foreach.svg | 4 ++++ src/ui/public/components/workflows_httprequest.svg | 11 +++++++++++ src/ui/public/components/workflows_logmessage.svg | 4 ++++ src/ui/public/components/workflows_parsejson.svg | 4 ++++ src/ui/public/components/workflows_returnvalue.svg | 4 ++++ src/ui/public/components/workflows_runworkflow.svg | 4 ++++ src/ui/public/components/workflows_setstate.svg | 4 ++++ .../components/workflows_writeraddchatmessage.svg | 11 +++++++++++ src/ui/public/components/workflows_writerchat.svg | 11 +++++++++++ .../components/workflows_writerclassification.svg | 9 +++++++++ .../public/components/workflows_writercompletion.svg | 6 ++++++ src/ui/public/components/workflows_writerinitchat.svg | 11 +++++++++++ .../public/components/workflows_writernocodeapp.svg | 4 ++++ 18 files changed, 114 insertions(+) create mode 100644 src/ui/public/components/workflows_addtostatelist.svg create mode 100644 src/ui/public/components/workflows_calleventhandler.svg create mode 100644 src/ui/public/components/workflows_category_Logic.svg create mode 100644 src/ui/public/components/workflows_category_Other.svg create mode 100644 src/ui/public/components/workflows_category_Writer.svg create mode 100644 src/ui/public/components/workflows_foreach.svg create mode 100644 src/ui/public/components/workflows_httprequest.svg create mode 100644 src/ui/public/components/workflows_logmessage.svg create mode 100644 src/ui/public/components/workflows_parsejson.svg create mode 100644 src/ui/public/components/workflows_returnvalue.svg create mode 100644 src/ui/public/components/workflows_runworkflow.svg create mode 100644 src/ui/public/components/workflows_setstate.svg create mode 100644 src/ui/public/components/workflows_writeraddchatmessage.svg create mode 100644 src/ui/public/components/workflows_writerchat.svg create mode 100644 src/ui/public/components/workflows_writerclassification.svg create mode 100644 src/ui/public/components/workflows_writercompletion.svg create mode 100644 src/ui/public/components/workflows_writerinitchat.svg create mode 100644 src/ui/public/components/workflows_writernocodeapp.svg diff --git a/src/ui/public/components/workflows_addtostatelist.svg b/src/ui/public/components/workflows_addtostatelist.svg new file mode 100644 index 00000000..9daefb15 --- /dev/null +++ b/src/ui/public/components/workflows_addtostatelist.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_calleventhandler.svg b/src/ui/public/components/workflows_calleventhandler.svg new file mode 100644 index 00000000..1feed272 --- /dev/null +++ b/src/ui/public/components/workflows_calleventhandler.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/ui/public/components/workflows_category_Logic.svg b/src/ui/public/components/workflows_category_Logic.svg new file mode 100644 index 00000000..42db35e9 --- /dev/null +++ b/src/ui/public/components/workflows_category_Logic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_category_Other.svg b/src/ui/public/components/workflows_category_Other.svg new file mode 100644 index 00000000..74f6556e --- /dev/null +++ b/src/ui/public/components/workflows_category_Other.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_category_Writer.svg b/src/ui/public/components/workflows_category_Writer.svg new file mode 100644 index 00000000..7ceb43d5 --- /dev/null +++ b/src/ui/public/components/workflows_category_Writer.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ui/public/components/workflows_foreach.svg b/src/ui/public/components/workflows_foreach.svg new file mode 100644 index 00000000..08a7fd6b --- /dev/null +++ b/src/ui/public/components/workflows_foreach.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_httprequest.svg b/src/ui/public/components/workflows_httprequest.svg new file mode 100644 index 00000000..fac6d14c --- /dev/null +++ b/src/ui/public/components/workflows_httprequest.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ui/public/components/workflows_logmessage.svg b/src/ui/public/components/workflows_logmessage.svg new file mode 100644 index 00000000..dd768ee3 --- /dev/null +++ b/src/ui/public/components/workflows_logmessage.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_parsejson.svg b/src/ui/public/components/workflows_parsejson.svg new file mode 100644 index 00000000..71bef3da --- /dev/null +++ b/src/ui/public/components/workflows_parsejson.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_returnvalue.svg b/src/ui/public/components/workflows_returnvalue.svg new file mode 100644 index 00000000..9de340ce --- /dev/null +++ b/src/ui/public/components/workflows_returnvalue.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_runworkflow.svg b/src/ui/public/components/workflows_runworkflow.svg new file mode 100644 index 00000000..1d9a6337 --- /dev/null +++ b/src/ui/public/components/workflows_runworkflow.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_setstate.svg b/src/ui/public/components/workflows_setstate.svg new file mode 100644 index 00000000..29e796bd --- /dev/null +++ b/src/ui/public/components/workflows_setstate.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/ui/public/components/workflows_writeraddchatmessage.svg b/src/ui/public/components/workflows_writeraddchatmessage.svg new file mode 100644 index 00000000..616977e6 --- /dev/null +++ b/src/ui/public/components/workflows_writeraddchatmessage.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ui/public/components/workflows_writerchat.svg b/src/ui/public/components/workflows_writerchat.svg new file mode 100644 index 00000000..cb08dd06 --- /dev/null +++ b/src/ui/public/components/workflows_writerchat.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ui/public/components/workflows_writerclassification.svg b/src/ui/public/components/workflows_writerclassification.svg new file mode 100644 index 00000000..4668f999 --- /dev/null +++ b/src/ui/public/components/workflows_writerclassification.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/ui/public/components/workflows_writercompletion.svg b/src/ui/public/components/workflows_writercompletion.svg new file mode 100644 index 00000000..e4f62d6d --- /dev/null +++ b/src/ui/public/components/workflows_writercompletion.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ui/public/components/workflows_writerinitchat.svg b/src/ui/public/components/workflows_writerinitchat.svg new file mode 100644 index 00000000..096e1720 --- /dev/null +++ b/src/ui/public/components/workflows_writerinitchat.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ui/public/components/workflows_writernocodeapp.svg b/src/ui/public/components/workflows_writernocodeapp.svg new file mode 100644 index 00000000..3c2ad9c9 --- /dev/null +++ b/src/ui/public/components/workflows_writernocodeapp.svg @@ -0,0 +1,4 @@ + + + + From 374c1282df8983f7d969975d943da8608abc8f27 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:34:50 +0000 Subject: [PATCH 04/17] chore: Refactor directives --- src/ui/src/directives.ts | 18 ++++++++++++++++++ src/ui/src/main.ts | 20 ++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 src/ui/src/directives.ts diff --git a/src/ui/src/directives.ts b/src/ui/src/directives.ts new file mode 100644 index 00000000..ad06e836 --- /dev/null +++ b/src/ui/src/directives.ts @@ -0,0 +1,18 @@ +import { App } from "vue"; + +export function setCaptureTabsDirective(app: App) { + app.directive("capture-tabs", { + mounted: (el: HTMLTextAreaElement) => { + el.addEventListener("keydown", (ev) => { + if (ev.key != "Tab") return; + ev.preventDefault(); + el.setRangeText( + " ", + el.selectionStart, + el.selectionStart, + "end", + ); + }); + }, + }); +} \ No newline at end of file diff --git a/src/ui/src/main.ts b/src/ui/src/main.ts index 3c6ce47b..3a74f8ef 100644 --- a/src/ui/src/main.ts +++ b/src/ui/src/main.ts @@ -1,33 +1,17 @@ import * as vue from "vue"; -import { App, createApp } from "vue"; +import { createApp } from "vue"; import VueDOMPurifyHTML from "vue-dompurify-html"; import { generateBuilderManager } from "./builder/builderManager.js"; import { generateCore } from "./core"; import "./fonts"; import injectionKeys from "./injectionKeys"; +import { setCaptureTabsDirective } from "./directives.js"; /** * RemixIcon by remixicon.com */ import "remixicon/fonts/remixicon.css"; -function setCaptureTabsDirective(app: App) { - app.directive("capture-tabs", { - mounted: (el: HTMLTextAreaElement) => { - el.addEventListener("keydown", (ev) => { - if (ev.key != "Tab") return; - ev.preventDefault(); - el.setRangeText( - " ", - el.selectionStart, - el.selectionStart, - "end", - ); - }); - }, - }); -} - const wf = generateCore(); globalThis.vue = vue; From f68718c776251cffadbe2051a83560efe70f68ee Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:37:05 +0000 Subject: [PATCH 05/17] feat: New tooltip --- src/ui/src/builder/BuilderApp.vue | 20 +- src/ui/src/builder/BuilderCodePanel.vue | 2 +- .../src/builder/BuilderComponentShortcuts.vue | 28 +-- src/ui/src/builder/BuilderCopyText.vue | 67 ++----- src/ui/src/builder/BuilderLogPanel.vue | 2 +- src/ui/src/builder/BuilderPanel.vue | 7 +- .../src/builder/BuilderSidebarTitleSearch.vue | 6 +- src/ui/src/builder/BuilderSidebarToolbar.vue | 3 +- src/ui/src/builder/BuilderSidebarTree.vue | 6 +- src/ui/src/builder/BuilderTooltip.vue | 175 ++++++++++++++++++ 10 files changed, 236 insertions(+), 80 deletions(-) create mode 100644 src/ui/src/builder/BuilderTooltip.vue diff --git a/src/ui/src/builder/BuilderApp.vue b/src/ui/src/builder/BuilderApp.vue index 391cdc85..f491a99a 100644 --- a/src/ui/src/builder/BuilderApp.vue +++ b/src/ui/src/builder/BuilderApp.vue @@ -89,6 +89,10 @@ + + + + @@ -107,6 +111,7 @@ import BuilderInsertionOverlay from "./BuilderInsertionOverlay.vue"; import BuilderInsertionLabel from "./BuilderInsertionLabel.vue"; import BuilderCodePanel from "./BuilderCodePanel.vue"; import BuilderLogPanel from "./BuilderLogPanel.vue"; +import BuilderTooltip from "./BuilderTooltip.vue"; import { isPlatformMac } from "../core/detectPlatform"; const wf = inject(injectionKeys.core); @@ -261,13 +266,13 @@ const handleRendererDragStart = (ev: DragEvent) => { ); }; -const handleRendererDragEnd = (ev: DragEvent) => { +function handleRendererDragEnd(ev: DragEvent) { ssbm.setSelection(null); removeInsertionCandidacy(ev); -}; +} onMounted(() => { - document.addEventListener("keydown", (ev) => handleKeydown(ev)); + document.addEventListener("keydown", handleKeydown); }); @@ -371,11 +376,11 @@ onMounted(() => { .settingsBar { position: absolute; - right: 32px; + right: 24px; top: v-bind("ssbm.getMode() == 'workflows' ? '72px' : '20px'"); z-index: 4; width: var(--builderSettingsWidth); - bottom: 20px; + bottom: 24px; overflow: hidden; border: 1px solid var(--builderAreaSeparatorColor); background: var(--builderBackgroundColor); @@ -415,4 +420,9 @@ onMounted(() => { left: 0; z-index: 10; } + +#tooltip { + position: absolute; + z-index: 11; +} diff --git a/src/ui/src/builder/BuilderCodePanel.vue b/src/ui/src/builder/BuilderCodePanel.vue index 3b3c7784..78394bac 100644 --- a/src/ui/src/builder/BuilderCodePanel.vue +++ b/src/ui/src/builder/BuilderCodePanel.vue @@ -38,7 +38,7 @@ const actions = computed(() => [ name: "Save and run", keyboardShortcut: { modifierKey: true, - key: "s", + key: "S", }, callback: () => { save(); diff --git a/src/ui/src/builder/BuilderComponentShortcuts.vue b/src/ui/src/builder/BuilderComponentShortcuts.vue index a905dd51..fd0dc91d 100644 --- a/src/ui/src/builder/BuilderComponentShortcuts.vue +++ b/src/ui/src/builder/BuilderComponentShortcuts.vue @@ -11,7 +11,8 @@ + + + + From 5a16c69c537c9b376fd5e172b338d7e4d3e022c0 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:37:42 +0000 Subject: [PATCH 06/17] feat: Zoom and navigator --- .../workflows/WorkflowsWorkflow.vue | 303 +++++++++++++----- .../workflows/base/WorkflowMiniMap.vue | 86 +++-- .../workflows/base/WorkflowNavigator.vue | 225 +++++++++++++ 3 files changed, 500 insertions(+), 114 deletions(-) create mode 100644 src/ui/src/components/workflows/base/WorkflowNavigator.vue diff --git a/src/ui/src/components/workflows/WorkflowsWorkflow.vue b/src/ui/src/components/workflows/WorkflowsWorkflow.vue index 2e7cb623..103051de 100644 --- a/src/ui/src/components/workflows/WorkflowsWorkflow.vue +++ b/src/ui/src/components/workflows/WorkflowsWorkflow.vue @@ -23,7 +23,7 @@ wfbm.getSelectedId() == arrow.toNodeId " @click="handleArrowClick($event, arrowId)" - @delete="handleDeleteClick($event, arrow)" + @delete="handleArrowDeleteClick(arrow)" > - - play_arrow - {{ isRunning ? "Running..." : "Run workflow" }} - + + play_arrow + {{ isRunning ? "Running..." : "Run workflow" }} + + + + @change-zoom-level="handleChangeZoomLevel" + @reset-zoom="resetZoom" + > @@ -79,7 +83,8 @@ import { type Component, FieldType } from "@/writerTypes"; import WorkflowArrow from "./base/WorkflowArrow.vue"; import { watch } from "vue"; import WdsButton from "@/wds/WdsButton.vue"; -import WorkflowMiniMap from "./base/WorkflowMiniMap.vue"; +import WorkflowNavigator from "./base/WorkflowNavigator.vue"; +import { isModifierKeyActive } from "@/core/detectPlatform"; const description = "A container component representing a single workflow within the application."; @@ -114,13 +119,31 @@ export type WorkflowArrowData = { toNodeId?: Component["id"]; isEngaged?: boolean; }; + +export const ZOOM_SETTINGS = { + minLevel: 0.2, + maxLevel: 1, + step: 0.25, + initialLevel: 1, +}; @@ -517,9 +650,11 @@ onMounted(async () => { overflow: hidden; } -button.runButton { +.workflowsToolbar { position: absolute; - right: 32px; + display: flex; + gap: 8px; + right: 24px; top: 20px; } @@ -527,10 +662,12 @@ button.runButton { background: var(--builderSubtleSeparatorColor); } -.miniMap { +.navigator { position: absolute; - bottom: 32px; - left: 32px; + bottom: 24px; + left: 24px; + border-radius: 20px; + overflow: hidden; } .nodeContainer { @@ -538,8 +675,10 @@ button.runButton { top: 0; left: 0; overflow: hidden; - width: 100%; - height: 100%; + width: calc(100% * 1 / v-bind("zoomLevel")); + height: calc(100% * 1 / v-bind("zoomLevel")); + transform-origin: top left; + transform: scale(v-bind("zoomLevel")); } svg { diff --git a/src/ui/src/components/workflows/base/WorkflowMiniMap.vue b/src/ui/src/components/workflows/base/WorkflowMiniMap.vue index 7a968f09..bfc76612 100644 --- a/src/ui/src/components/workflows/base/WorkflowMiniMap.vue +++ b/src/ui/src/components/workflows/base/WorkflowMiniMap.vue @@ -2,7 +2,6 @@
(); const miniNodes = ref([]); @@ -86,42 +86,63 @@ function render() { props.nodeContainerEl.querySelectorAll("[data-writer-id]"), ) as HTMLElement[]; - const cbr = props.nodeContainerEl.getBoundingClientRect(); + const nodeContainerBCR = props.nodeContainerEl.getBoundingClientRect(); let maxX = 0, maxY = 0; miniNodes.value = nodeEls.map((nodeEl) => { - const nodeCbr = nodeEl.getBoundingClientRect(); - maxX = Math.max(maxX, nodeCbr.right + props.renderOffset.x - cbr.left); - maxY = Math.max(maxY, nodeCbr.bottom + props.renderOffset.y - cbr.top); + const nodeBCR = nodeEl.getBoundingClientRect(); + maxX = Math.max( + maxX, + nodeBCR.right + + props.renderOffset.x * props.zoomLevel - + nodeContainerBCR.left, + ); + maxY = Math.max( + maxY, + nodeBCR.bottom + + props.renderOffset.y * props.zoomLevel - + nodeContainerBCR.top, + ); return { id: nodeEl.dataset.writerId, - width: nodeCbr.width, - height: nodeCbr.height, - top: nodeCbr.top + props.renderOffset.y - cbr.top, - left: nodeCbr.left + props.renderOffset.x - cbr.left, + width: nodeBCR.width, + height: nodeBCR.height, + top: + nodeBCR.top + + props.renderOffset.y * props.zoomLevel - + nodeContainerBCR.top, + left: + nodeBCR.left + + props.renderOffset.x * props.zoomLevel - + nodeContainerBCR.left, }; }); miniMap.value = { - width: cbr.width / 7, - height: ((cbr.height / cbr.width) * cbr.width) / 7, + width: 230, + height: + ((nodeContainerBCR.height / nodeContainerBCR.width) * + nodeContainerBCR.width) / + 7, }; scale.value = Math.min( - miniMap.value.width / (cbr.width + 300), - miniMap.value.height / (cbr.height + 300), + miniMap.value.width / (nodeContainerBCR.width + 300), + miniMap.value.height / (nodeContainerBCR.height + 300), miniMap.value.width / (maxX + 300), miniMap.value.height / (maxY + 300), - miniMap.value.width / (props.renderOffset.x + cbr.width), - miniMap.value.height / (props.renderOffset.y + cbr.height), + miniMap.value.width / + (props.renderOffset.x * props.zoomLevel + nodeContainerBCR.width), + miniMap.value.height / + (props.renderOffset.y * props.zoomLevel + nodeContainerBCR.height), ); selectedArea.value = { - top: props.renderOffset.y, - left: props.renderOffset.x, - width: cbr.width, - height: cbr.height, + top: props.renderOffset.y * props.zoomLevel, + left: props.renderOffset.x * props.zoomLevel, + width: nodeContainerBCR.width, + height: nodeContainerBCR.height, }; selector.value = { @@ -131,23 +152,25 @@ function render() { } function handleMousemove(ev: MouseEvent) { - const cbr = props.nodeContainerEl.getBoundingClientRect(); - const rootElCbr = rootEl.value.getBoundingClientRect(); + const nodeContainerBCR = props.nodeContainerEl.getBoundingClientRect(); + const rootBCR = rootEl.value.getBoundingClientRect(); selector.value = { ...selector.value, top: Math.min( Math.max( 0, - (ev.pageY - rootElCbr.top) * (1 / scale.value) - cbr.height / 2, + (ev.pageY - rootBCR.top) * (1 / scale.value) - + nodeContainerBCR.height / 2, ), - rootElCbr.height * (1 / scale.value) - cbr.height, + rootBCR.height * (1 / scale.value) - nodeContainerBCR.height, ), left: Math.min( Math.max( 0, - (ev.pageX - rootElCbr.left) * (1 / scale.value) - cbr.width / 2, + (ev.pageX - rootBCR.left) * (1 / scale.value) - + nodeContainerBCR.width / 2, ), - rootElCbr.width * (1 / scale.value) - cbr.width, + rootBCR.width * (1 / scale.value) - nodeContainerBCR.width, ), }; } @@ -164,8 +187,8 @@ function handleClick(ev: MouseEvent) { ev.stopPropagation(); wfbm.setSelection(null); emit("changeRenderOffset", { - x: selector.value.left, - y: selector.value.top, + x: selector.value.left * (1 / props.zoomLevel), + y: selector.value.top * (1 / props.zoomLevel), }); } @@ -195,7 +218,6 @@ onUnmounted(() => { height: v-bind("`${miniMap.height}px`"); background: var(--builderSeparatorColor); position: relative; - border-radius: 4px; overflow: hidden; } diff --git a/src/ui/src/components/workflows/base/WorkflowNavigator.vue b/src/ui/src/components/workflows/base/WorkflowNavigator.vue new file mode 100644 index 00000000..07fc5e0a --- /dev/null +++ b/src/ui/src/components/workflows/base/WorkflowNavigator.vue @@ -0,0 +1,225 @@ + + + + + From f76eff4a0ebed877621d028f54a214c6c3a7b472 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:38:11 +0000 Subject: [PATCH 07/17] fix: Set result to None for unknown types (non list or dict) --- src/writer/workflows_blocks/foreach.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer/workflows_blocks/foreach.py b/src/writer/workflows_blocks/foreach.py index 6fdf4932..183064ab 100644 --- a/src/writer/workflows_blocks/foreach.py +++ b/src/writer/workflows_blocks/foreach.py @@ -61,7 +61,7 @@ def run(self): items = self._get_field("items", as_json=True) base_execution_env = self._get_field("executionEnv", as_json=True) std_items = items - + result = None if isinstance(items, list): std_items = enumerate(std_items, 0) result = [self._run_workflow_for_item(workflow_key, base_execution_env, item_id, item) for item_id, item in std_items] From 53cf67605015526951a4d6e2a5a5f3e00d059f0e Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:38:25 +0000 Subject: [PATCH 08/17] feat: Node namer --- .../workflows/abstract/WorkflowsNode.vue | 60 ++++++-- .../workflows/base/WorkflowsNodeNamer.vue | 141 ++++++++++++++++++ 2 files changed, 189 insertions(+), 12 deletions(-) create mode 100644 src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue diff --git a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue index ac3752e1..45c97972 100644 --- a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue +++ b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue @@ -2,9 +2,17 @@
- {{ def.name }} +
@@ -55,26 +63,39 @@ export default { description: "A Workflows node.", toolkit: "workflows", category: "Other", - fields: {}, + fields: { + alias: { + name: "Alias", + type: FieldType.Text, + }, + }, allowedParentTypes: ["workflows_workflow"], previewField: "text", }, }; + + From 57d7085af4107ad0e5592d67e284851853385286 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:38:46 +0000 Subject: [PATCH 09/17] chore: Support mouse event --- src/ui/src/core/detectPlatform.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/src/core/detectPlatform.ts b/src/ui/src/core/detectPlatform.ts index c33f5732..f47f41e9 100644 --- a/src/ui/src/core/detectPlatform.ts +++ b/src/ui/src/core/detectPlatform.ts @@ -5,10 +5,10 @@ function getPlatform() { } export function getModifierKeyName() { - return isPlatformMac() ? "⌘ Cmd" : "Ctrl"; + return isPlatformMac() ? "⌘ " : "Ctrl+"; } -export function isModifierKeyActive(ev: KeyboardEvent) { +export function isModifierKeyActive(ev: KeyboardEvent | MouseEvent) { return isPlatformMac() ? ev.metaKey : ev.ctrlKey; } From f234c92b87d9b702ba28d94f05d1d3691d0bb374 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:39:01 +0000 Subject: [PATCH 10/17] chore: Neutral button has a hover --- src/ui/src/wds/WdsButton.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/src/wds/WdsButton.vue b/src/ui/src/wds/WdsButton.vue index f57d721d..c2f3fec9 100644 --- a/src/ui/src/wds/WdsButton.vue +++ b/src/ui/src/wds/WdsButton.vue @@ -106,6 +106,7 @@ const className = computed(() => [ .WdsButton--neutral { border: none; box-shadow: none; + height: fit-content; background: unset; margin: 0; padding: 0; @@ -116,7 +117,7 @@ const className = computed(() => [ color: unset; border: none; box-shadow: none; - background: unset; + background: var(--builderSeparatorColor); } .WdsButton--neutral:disabled { From 1a7af561b9e354e87347de6b023f9a985eeef315 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:39:13 +0000 Subject: [PATCH 11/17] feat: Auto parse JSON --- src/writer/workflows_blocks/httprequest.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/writer/workflows_blocks/httprequest.py b/src/writer/workflows_blocks/httprequest.py index b61b6c4c..9b91f831 100644 --- a/src/writer/workflows_blocks/httprequest.py +++ b/src/writer/workflows_blocks/httprequest.py @@ -4,7 +4,6 @@ from writer.ss_types import AbstractTemplate from writer.workflows_blocks.blocks import WorkflowBlock - class HTTPRequest(WorkflowBlock): @classmethod @@ -52,7 +51,7 @@ def register(cls, type: str): }, "responseError": { "name": "Response error", - "description": "The connection was established successfully but an error response code was received.", + "description": "The connection was established successfully but an error response code was received or the response was invalid.", "style": "error", }, "connectionError": { @@ -65,22 +64,31 @@ def register(cls, type: str): )) def run(self): + import json + try: method = self._get_field("method", False, "get") url = self._get_field("url") headers = self._get_field("headers", True) body = self._get_field("body") req = requests.request(method, url, headers=headers, data=body) + + content_type = req.headers.get("Content-Type") + is_json = content_type and "application/json" in content_type + self.result = { "headers": dict(req.headers), "status_code": req.status_code, - "body": req.text + "body": req.json() if is_json else req.text } if req.ok: self.outcome = "success" else: self.outcome = "responseError" raise RuntimeError("HTTP response with code " + str(req.status_code)) + except json.JSONDecodeError as e: + self.result = "JSON decode error. The response contains invalid JSON." + self.outcome = "responseError" except BaseException as e: self.outcome = "connectionError" raise e \ No newline at end of file From 8f946cc363707b0e6f155a2ff62662aa4c47bafb Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:39:25 +0000 Subject: [PATCH 12/17] fix: No empty return value --- src/writer/workflows_blocks/returnvalue.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/writer/workflows_blocks/returnvalue.py b/src/writer/workflows_blocks/returnvalue.py index 9ccf318e..6770565c 100644 --- a/src/writer/workflows_blocks/returnvalue.py +++ b/src/writer/workflows_blocks/returnvalue.py @@ -40,6 +40,8 @@ def register(cls, type: str): def run(self): try: value = self._get_field("value") + if value is None: + raise ValueError("Return value cannot be empty or None.") self.result = value self.return_value = value self.outcome = "success" From 2c95ea91df1c189bd339a93b9aec85fa43a03346 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:39:44 +0000 Subject: [PATCH 13/17] fix: Add content separator --- src/writer/workflows_blocks/writerclassification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer/workflows_blocks/writerclassification.py b/src/writer/workflows_blocks/writerclassification.py index 6bd2c406..b9f9f782 100644 --- a/src/writer/workflows_blocks/writerclassification.py +++ b/src/writer/workflows_blocks/writerclassification.py @@ -70,7 +70,7 @@ def run(self): { additional_context } CONTENT: - +------ { text } """ result = writer.ai.complete(prompt, config).strip() From e88a8ee56622619aed2a139450e47ee57db59662 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:56:20 +0000 Subject: [PATCH 14/17] fix: Linter fixes --- src/ui/src/components/workflows/abstract/WorkflowsNode.vue | 6 ------ src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue | 2 +- src/writer/workflows_blocks/httprequest.py | 3 ++- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue index 45c97972..06e7f222 100644 --- a/src/ui/src/components/workflows/abstract/WorkflowsNode.vue +++ b/src/ui/src/components/workflows/abstract/WorkflowsNode.vue @@ -92,8 +92,6 @@ const component = computed(() => { return component; }); -const alias = ref(component.value.content["alias"]); - const def = computed(() => { return wf?.getComponentDefinition(component.value?.type); }); @@ -156,10 +154,6 @@ function handleOutMousedown(ev: DragEvent, outId: string) { emit("outMousedown", outId); } -watch(alias, () => { - setContent; -}); - watch(isEngaged, () => { emit("engaged"); }); diff --git a/src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue b/src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue index 6351228a..6ac5426c 100644 --- a/src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue +++ b/src/ui/src/components/workflows/base/WorkflowsNodeNamer.vue @@ -29,7 +29,7 @@