Skip to content

Commit 522fd98

Browse files
committed
feat(web): enhance workflow components with output expansion toggle and code rendering support
1 parent ed7441c commit 522fd98

6 files changed

Lines changed: 309 additions & 101 deletions

File tree

apps/web/src/components/docs/code-block.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
33
import { codeToHtml } from "shiki";
44

55
import { Button } from "@/components/ui/button";
6+
import { cn } from "@/utils/utils";
67

78
interface CodeBlockProps {
89
children: React.ReactNode;
@@ -52,7 +53,12 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
5253

5354
if (isInline) {
5455
return (
55-
<code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold">
56+
<code
57+
className={cn(
58+
"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
59+
className
60+
)}
61+
>
5662
{children}
5763
</code>
5864
);
@@ -71,7 +77,12 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
7177
if (isLoading) {
7278
return (
7379
<div className="relative group">
74-
<pre className="mb-4 mt-6 overflow-x-auto rounded-lg border bg-zinc-950 text-white p-4">
80+
<pre
81+
className={cn(
82+
"mb-4 mt-6 overflow-x-auto rounded-lg border bg-zinc-950 text-white p-4",
83+
className
84+
)}
85+
>
7586
<div className="flex items-center justify-center h-20">
7687
<div className="text-zinc-400 text-sm">
7788
Loading syntax highlighting...
@@ -93,7 +104,10 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
93104
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
94105
</Button>
95106
<div
96-
className="mb-4 mt-2 overflow-x-auto rounded-md text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre-wrap"
107+
className={cn(
108+
"mb-4 mt-2 overflow-x-auto rounded-md text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre-wrap",
109+
className
110+
)}
97111
dangerouslySetInnerHTML={{ __html: highlightedCode }}
98112
/>
99113
</div>

apps/web/src/components/workflow/workflow-builder.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export function WorkflowBuilder({
6868
const [workflowStatus, setWorkflowStatus] = useState<WorkflowExecutionStatus>(
6969
initialWorkflowExecution?.status || "idle"
7070
);
71+
const [currentExpandedOutputs, setCurrentExpandedOutputs] =
72+
useState(expandedOutputs);
7173
const [errorDialogState, setErrorDialogState] = useState<{
7274
open: boolean;
7375
message: string;
@@ -333,13 +335,19 @@ export function WorkflowBuilder({
333335
setIsSidebarVisible((prev) => !prev);
334336
}, []);
335337

338+
const toggleExpandedOutputs = useCallback((e: React.MouseEvent) => {
339+
e.preventDefault();
340+
e.stopPropagation();
341+
setCurrentExpandedOutputs((prev) => !prev);
342+
}, []);
343+
336344
return (
337345
<ReactFlowProvider>
338346
<WorkflowProvider
339347
updateNodeData={readonly ? undefined : updateNodeData}
340348
updateEdgeData={readonly ? undefined : updateEdgeData}
341349
readonly={readonly}
342-
expandedOutputs={expandedOutputs}
350+
expandedOutputs={currentExpandedOutputs}
343351
>
344352
<div className="w-full h-full flex">
345353
<div
@@ -372,6 +380,10 @@ export function WorkflowBuilder({
372380
isSidebarVisible={isSidebarVisible}
373381
isValidConnection={isValidConnection}
374382
readonly={readonly}
383+
expandedOutputs={currentExpandedOutputs}
384+
onToggleExpandedOutputs={
385+
readonly ? undefined : toggleExpandedOutputs
386+
}
375387
/>
376388
</div>
377389

0 commit comments

Comments
 (0)