From 4e445949538b725713b5d38368a208dc10027747 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 1 Feb 2025 13:15:11 -0800 Subject: [PATCH] Added envvar store, resolves values in short-input, long-input, code sub-blocks. Resolves value at execution time --- .../components/sub-block/components/code.tsx | 4 + .../sub-block/components/long-input.tsx | 20 +- .../sub-block/components/short-input.tsx | 20 +- .../settings-modal/settings-modal.tsx | 253 ++++++++++++------ app/w/hooks/use-workflow-execution.ts | 16 +- components/ui/formatted-text.tsx | 34 +++ executor/index.ts | 46 ++-- executor/types.ts | 24 +- stores/environment/store.ts | 42 +++ stores/environment/types.ts | 16 ++ 10 files changed, 331 insertions(+), 144 deletions(-) create mode 100644 components/ui/formatted-text.tsx create mode 100644 stores/environment/store.ts create mode 100644 stores/environment/types.ts diff --git a/app/w/[id]/components/workflow-block/components/sub-block/components/code.tsx b/app/w/[id]/components/workflow-block/components/sub-block/components/code.tsx index 94e5aadc7e..f428b4b063 100644 --- a/app/w/[id]/components/workflow-block/components/sub-block/components/code.tsx +++ b/app/w/[id]/components/workflow-block/components/sub-block/components/code.tsx @@ -1,6 +1,7 @@ import { useState, useRef, useEffect, useCallback, useMemo } from 'react' import { cn } from '@/lib/utils' import { useSubBlockValue } from '../hooks/use-sub-block-value' +import { formatDisplayText } from '@/components/ui/formatted-text' interface CodeLine { id: string @@ -714,6 +715,9 @@ export function Code({ blockId, subBlockId, isConnecting }: CodeProps) { wrap="off" onPaste={handlePaste} /> +
+ {formatDisplayText(line.content)} +
))} diff --git a/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx b/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx index ac925d314e..f8d191f9e0 100644 --- a/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx +++ b/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx @@ -3,6 +3,7 @@ import { useSubBlockValue } from '../hooks/use-sub-block-value' import { cn } from '@/lib/utils' import { useState, useRef, useEffect } from 'react' import { SubBlockConfig } from '@/blocks/types' +import { formatDisplayText } from '@/components/ui/formatted-text' interface LongInputProps { placeholder?: string @@ -63,25 +64,6 @@ export function LongInput({ e.preventDefault() } - const formatDisplayText = (text: string) => { - if (!text) return null - - // Split the text by tag pattern - const parts = text.split(/(<[^>]+>)/g) - - return parts.map((part, index) => { - // Check if the part matches tag pattern - if (part.match(/^<[^>]+>$/)) { - return ( - - {part} - - ) - } - return {part} - }) - } - return (