Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e1cab5c
feat: Implement utility functions for managing component aliases with…
ogabrielluiz Sep 10, 2025
2de3451
feat: Add migration support for existing flows to handle duplicate co…
ogabrielluiz Sep 10, 2025
08694dc
feat: Enhance alias handling in NodeName and TweakComponent, add util…
ogabrielluiz Sep 10, 2025
a7c0e27
feat: Implement alias conversion for tweaks in API code generation fu…
ogabrielluiz Sep 10, 2025
bcc40ac
feat: Add alias assignment for new components in useAddComponent hook
ogabrielluiz Sep 10, 2025
ded8e08
feat: Enhance alias validation functions to improve safety checks for…
ogabrielluiz Sep 10, 2025
0918d53
feat: Refactor alias utility tests to enhance pattern detection and i…
ogabrielluiz Sep 10, 2025
c5feac7
feat: Implement alias update on display name change in NodeName compo…
ogabrielluiz Sep 10, 2025
ed582ef
feat: Enhance renumbering logic for auto-generated aliases and update…
ogabrielluiz Sep 10, 2025
d8bde89
feat: Refactor alias detection and update logic for improved clarity …
ogabrielluiz Sep 10, 2025
f6f88c5
feat: Add dynamic alias assignment for duplicate components in graph …
ogabrielluiz Sep 10, 2025
0ff5cee
fix: Update alias formatting for consistency in graph dump tests
ogabrielluiz Sep 10, 2025
98b63f7
fix: Preserve existing alias for duplicate components in graph dump test
ogabrielluiz Sep 10, 2025
0f00c71
feat: Update documentation for Tweaks class to clarify alias usage an…
ogabrielluiz Sep 10, 2025
87f5261
feat: Enhance process_tweaks function to support alias and display na…
ogabrielluiz Sep 10, 2025
d952ca5
feat: Add unit tests for alias-enabled tweak processing functionality
ogabrielluiz Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import ShadTooltip from "@/components/common/shadTooltipComponent";
import { Input } from "@/components/ui/input";
import useFlowStore from "@/stores/flowStore";
import useFlowsManagerStore from "@/stores/flowsManagerStore";
import { getEffectiveAliasFromAnyNode } from "@/types/flow";
import { updateAliasesForDisplayNameChange } from "@/utils/aliasUtils";
import { cn } from "@/utils/utils";

export default function NodeName({
Expand All @@ -25,9 +27,15 @@ export default function NodeName({
toggleEditNameDescription: () => void;
setHasChangedNodeDescription: (hasChanged: boolean) => void;
}) {
const [nodeName, setNodeName] = useState<string>(display_name ?? "");
const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot);
const setNode = useFlowStore((state) => state.setNode);
const node = useFlowStore((state) => state.getNode(nodeId));

// Get alias for badge display
const componentAlias = node ? getEffectiveAliasFromAnyNode(node) : null;
const aliasNumber = componentAlias?.match(/#(\d+)$/)?.[1];

const [nodeName, setNodeName] = useState<string>(display_name ?? "");

useEffect(() => {
if (selected && editNameDescription) {
Expand All @@ -41,6 +49,9 @@ export default function NodeName({

const handleBlur = () => {
if (nodeName?.trim() !== "") {
const oldDisplayName = display_name;
const newDisplayName = nodeName;

setNodeName(nodeName);
setNode(nodeId, (old) => ({
...old,
Expand All @@ -52,6 +63,18 @@ export default function NodeName({
},
},
}));

// Update aliases when display name changes
if (oldDisplayName && newDisplayName !== oldDisplayName) {
const allNodes = useFlowStore.getState().nodes;
const updatedNodes = updateAliasesForDisplayNameChange(
nodeId,
oldDisplayName,
newDisplayName,
allNodes,
);
useFlowStore.getState().setNodes(updatedNodes);
}
Comment on lines +67 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify alias update produces a new nodes array

If updateAliasesForDisplayNameChange mutates and returns the same array reference, some subscribers may not re-render. Ensure it returns a new array instance.

Run:

Expected: It returns a new array (e.g., return [...allNodes]). If it returns allNodes directly, consider cloning before setNodes.


🏁 Script executed:

#!/bin/bash
# Inspect implementation to confirm immutable return
rg -nC2 'export function updateAliasesForDisplayNameChange' src/frontend/src/utils/aliasUtils.ts
rg -n 'return\s+\[\.{3}allNodes\]|\ballNodes\.slice\(\)|return\s+allNodes;' src/frontend/src/utils/aliasUtils.ts

Length of output: 262


Ensure updateAliasesForDisplayNameChange always returns a new array instance
In src/frontend/src/utils/aliasUtils.ts the function currently does:

  • Early-return at line 153: return allNodes;
  • Final return at line 177: return allNodes;

Both return the original array reference, which can prevent subscribers from re-rendering. Change these to return a clone (e.g. return [...allNodes]) or otherwise produce a new array before calling setNodes.

🤖 Prompt for AI Agents
In src/frontend/src/CustomNodes/GenericNode/components/NodeName/index.tsx around
lines 67 to 77, the call site uses updateAliasesForDisplayNameChange but that
utility sometimes returns the original allNodes array reference (early return at
line 153 and final return at line 177 in src/frontend/src/utils/aliasUtils.ts),
which prevents subscribers from detecting changes; update the utility so that
every return produces a new array instance (for example clone before returning
with [...allNodes] or map/other immutable update) so setNodes receives a new
reference and triggers re-renders.

} else {
setNodeName(display_name ?? "");
}
Expand Down Expand Up @@ -98,6 +121,13 @@ export default function NodeName({
<span className={cn("cursor-grab truncate text-sm")}>
{display_name}
</span>
{aliasNumber && (
<ShadTooltip content={`Alias: ${componentAlias}`}>
<div className="flex h-5 w-auto min-w-[18px] items-center justify-center rounded border border-border bg-background px-1.5 text-xs font-semibold text-foreground">
#{aliasNumber}
</div>
</ShadTooltip>
)}
</div>
</div>
{beta && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ShadTooltip from "@/components/common/shadTooltipComponent";
import { EditNodeComponent } from "@/modals/editNodeModal/components/editNodeComponent";
import type { APIClassType } from "@/types/api";
import type { AllNodeType } from "@/types/flow";
import { getEffectiveAliasFromAnyNode } from "@/types/flow";
import { customStringify } from "@/utils/reactflowUtils";

export function TweakComponent({
Expand All @@ -25,11 +26,24 @@ export function TweakComponent({
return;
setNodeClass(node.data?.node);
}, [node.data?.node]);

// Get alias info for badge display
const effectiveAlias = getEffectiveAliasFromAnyNode(node);
const aliasNumber = effectiveAlias?.match(/#(\d+)$/)?.[1];
const displayName = node.data.node?.display_name || "";

Comment on lines +30 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Derive badge number from the actual alias field to avoid false positives.
Using effectiveAlias risks matching trailing numbers in display_name for non-generic nodes. Read from node.data.node.alias instead.

-  const effectiveAlias = getEffectiveAliasFromAnyNode(node);
-  const aliasNumber = effectiveAlias?.match(/#(\d+)$/)?.[1];
-  const displayName = node.data.node?.display_name || "";
+  const effectiveAlias = getEffectiveAliasFromAnyNode(node);
+  const rawAlias =
+    node.type === "genericNode" ? node.data.node?.alias ?? "" : "";
+  const aliasNumber = rawAlias.match(/#(\d+)$/)?.[1];
+  const displayName = node.data.node?.display_name || "";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Get alias info for badge display
const effectiveAlias = getEffectiveAliasFromAnyNode(node);
const aliasNumber = effectiveAlias?.match(/#(\d+)$/)?.[1];
const displayName = node.data.node?.display_name || "";
// Get alias info for badge display
const effectiveAlias = getEffectiveAliasFromAnyNode(node);
const rawAlias =
node.type === "genericNode" ? node.data.node?.alias ?? "" : "";
const aliasNumber = rawAlias.match(/#(\d+)$/)?.[1];
const displayName = node.data.node?.display_name || "";
🤖 Prompt for AI Agents
In
src/frontend/src/components/core/codeTabsComponent/components/tweakComponent/index.tsx
around lines 30 to 34, the badge number is currently derived from effectiveAlias
which can accidentally match numbers in display_name; instead read the alias
directly from node.data.node?.alias, safely extract the badge number with
alias?.match(/#(\d+)$/)?.[1] (handle undefined/null), and keep displayName as
node.data.node?.display_name || ""; replace the effectiveAlias usage with this
direct alias extraction to avoid false positives.

return node && node.data && nodeClass ? (
<AccordionComponent
trigger={
<ShadTooltip side="top" styleClasses="z-50" content={node.data.id}>
<div className="text-primary">{node.data.node?.display_name}</div>
<div className="flex items-center gap-2 text-primary">
<span>{displayName}</span>
{aliasNumber && (
<div className="flex h-5 w-auto min-w-[18px] items-center justify-center rounded border border-border bg-background px-1.5 text-xs font-semibold text-foreground">
#{aliasNumber}
</div>
)}
</div>
</ShadTooltip>
}
keyValue={node.data.id}
Expand Down
30 changes: 28 additions & 2 deletions src/frontend/src/hooks/use-add-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { track } from "@/customization/utils/analytics";
import useFlowStore from "@/stores/flowStore";
import type { APIClassType } from "@/types/api";
import type { AllNodeType } from "@/types/flow";
import { assignAliasToNewComponent } from "@/utils/aliasUtils";
import { getNodeId } from "@/utils/reactflowUtils";
import { getNodeRenderType } from "@/utils/utils";

export function useAddComponent() {
const store = useStoreApi();
const paste = useFlowStore((state) => state.paste);
const nodes = useFlowStore((state) => state.nodes);
const setNodes = useFlowStore((state) => state.setNodes);

const addComponent = useCallback(
(
Expand Down Expand Up @@ -55,16 +58,39 @@ export function useAddComponent() {
type: getNodeRenderType("genericnode"),
position: { x: 0, y: 0 },
data: {
node: component,
node: { ...component }, // Clone component to avoid mutation
showNode: !component.minimized,
type: type,
id: newId,
},
};

// Generate alias for the new component and update existing ones if needed
assignAliasToNewComponent(newNode, nodes);

// Check if we need to update existing nodes (when adding second component of same type)
const displayName = newNode.data.node.display_name;
const sameTypeNodes = nodes.filter(
(n) =>
n.type === "genericNode" && n.data.node.display_name === displayName,
);

if (sameTypeNodes.length === 1 && !sameTypeNodes[0].data.node.alias) {
// This is the second component - need to assign aliases to both
const firstNode = sameTypeNodes[0];
if (firstNode.type === "genericNode") {
firstNode.data.node.alias = `${displayName}#1`;
}

// Update the first node in the store
setNodes((currentNodes) =>
currentNodes.map((n) => (n.id === firstNode.id ? firstNode : n)),
);
}

Comment on lines +68 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix: store mutation via utility is not persisted; reorder logic to ensure setNodes runs

assignAliasToNewComponent mutates the existing nodes array by reference. Because the zustand store isn’t updated unless setNodes is called, your subsequent condition can be skipped (alias already set in-memory), leading to no store update and missing re-render. Compute the “second-of-its-type” condition before calling the utility, then always persist the first node’s alias immutably when needed.

Apply:

-      // Generate alias for the new component and update existing ones if needed
-      assignAliasToNewComponent(newNode, nodes);
-
-      // Check if we need to update existing nodes (when adding second component of same type)
-      const displayName = newNode.data.node.display_name;
-      const sameTypeNodes = nodes.filter(
-        (n) =>
-          n.type === "genericNode" && n.data.node.display_name === displayName,
-      );
-
-      if (sameTypeNodes.length === 1 && !sameTypeNodes[0].data.node.alias) {
-        // This is the second component - need to assign aliases to both
-        const firstNode = sameTypeNodes[0];
-        if (firstNode.type === "genericNode") {
-          firstNode.data.node.alias = `${displayName}#1`;
-        }
-
-        // Update the first node in the store
-        setNodes((currentNodes) =>
-          currentNodes.map((n) => (n.id === firstNode.id ? firstNode : n)),
-        );
-      }
+      // Precompute if we are adding the second component of this display_name with no existing alias
+      const displayName = newNode.data.node.display_name;
+      const sameTypeNodesBefore = nodes.filter(
+        (n) => n.type === "genericNode" && n.data.node.display_name === displayName,
+      );
+      const needsPromoteFirst =
+        sameTypeNodesBefore.length === 1 &&
+        !sameTypeNodesBefore[0].data.node.alias;
+
+      // Assign alias to the new node (the utility will also compute target aliases)
+      assignAliasToNewComponent(newNode, nodes);
+
+      // Persist alias on the first existing node immutably so subscribers re-render
+      if (needsPromoteFirst) {
+        const firstId = sameTypeNodesBefore[0].id;
+        setNodes((currentNodes) =>
+          currentNodes.map((n) =>
+            n.id === firstId && n.type === "genericNode"
+              ? {
+                  ...n,
+                  data: {
+                    ...n.data,
+                    node: {
+                      ...n.data.node,
+                      alias: `${displayName}#1`,
+                    },
+                  },
+                }
+              : n,
+          ),
+        );
+      }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Generate alias for the new component and update existing ones if needed
assignAliasToNewComponent(newNode, nodes);
// Check if we need to update existing nodes (when adding second component of same type)
const displayName = newNode.data.node.display_name;
const sameTypeNodes = nodes.filter(
(n) =>
n.type === "genericNode" && n.data.node.display_name === displayName,
);
if (sameTypeNodes.length === 1 && !sameTypeNodes[0].data.node.alias) {
// This is the second component - need to assign aliases to both
const firstNode = sameTypeNodes[0];
if (firstNode.type === "genericNode") {
firstNode.data.node.alias = `${displayName}#1`;
}
// Update the first node in the store
setNodes((currentNodes) =>
currentNodes.map((n) => (n.id === firstNode.id ? firstNode : n)),
);
}
// Precompute if we are adding the second component of this display_name with no existing alias
const displayName = newNode.data.node.display_name;
const sameTypeNodesBefore = nodes.filter(
(n) => n.type === "genericNode" && n.data.node.display_name === displayName,
);
const needsPromoteFirst =
sameTypeNodesBefore.length === 1 &&
!sameTypeNodesBefore[0].data.node.alias;
// Assign alias to the new node (the utility will also compute target aliases)
assignAliasToNewComponent(newNode, nodes);
// Persist alias on the first existing node immutably so subscribers re-render
if (needsPromoteFirst) {
const firstId = sameTypeNodesBefore[0].id;
setNodes((currentNodes) =>
currentNodes.map((n) =>
n.id === firstId && n.type === "genericNode"
? {
...n,
data: {
...n.data,
node: {
...n.data.node,
alias: `${displayName}#1`,
},
},
}
: n,
),
);
}

paste({ nodes: [newNode], edges: [] }, pos);
},
[store, paste],
[store, paste, nodes, setNodes],
);

return addComponent;
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/modals/apiModal/codeTabs/code-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default function APITabsComponent() {
streaming: streaming,
flowId: flowId || "",
processedPayload: processedPayload,
nodes: nodes,
};

// Platform selection for cURL
Expand Down
55 changes: 33 additions & 22 deletions src/frontend/src/modals/apiModal/utils/get-curl-code.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ENABLE_DATASTAX_LANGFLOW } from "@/customization/feature-flags";
import { customGetHostProtocol } from "@/customization/utils/custom-get-host-protocol";
import { GetCodeType } from "@/types/tweaks";
import { convertTweaksToAliases } from "@/utils/aliasUtils";
import {
getAllChatInputNodeIds,
getAllFileNodeIds,
Expand Down Expand Up @@ -56,12 +57,14 @@ export function getNewCurlCode({
processedPayload,
platform,
shouldDisplayApiKey,
nodes,
}: {
flowId: string;
endpointName: string;
processedPayload: any;
platform?: "unix" | "powershell";
shouldDisplayApiKey: boolean;
nodes?: any[];
}): { steps: { title: string; code: string }[] } | string {
const { protocol, host } = customGetHostProtocol();
const baseUrl = `${protocol}//${host}`;
Expand All @@ -75,14 +78,21 @@ export function getNewCurlCode({
: "unix");

// Check if there are file uploads
const tweaks = processedPayload.tweaks || {};
const hasFiles = hasFileTweaks(tweaks);
const originalTweaks = processedPayload.tweaks || {};
const tweaks = convertTweaksToAliases(originalTweaks, nodes);
const hasFiles = hasFileTweaks(originalTweaks); // Use original tweaks for file detection

// Create payload with aliased tweaks
const payloadWithAliases = {
...processedPayload,
tweaks: tweaks,
};

// If no file uploads, use existing logic
if (!hasFiles) {
if (detectedPlatform === "powershell") {
const payloadWithSession = {
...processedPayload,
...payloadWithAliases,
session_id: "YOUR_SESSION_ID_HERE",
};
const singleLinePayload = JSON.stringify(payloadWithSession);
Expand All @@ -103,7 +113,7 @@ curl.exe --request POST \`
--data $jsonData`;
} else {
const payloadWithSession = {
...processedPayload,
...payloadWithAliases,
session_id: "YOUR_SESSION_ID_HERE",
};
// Unix-like systems (Linux, Mac, WSL2)
Expand All @@ -126,9 +136,9 @@ curl.exe --request POST \`
}

// File upload logic - handle multiple file types additively
const chatInputNodeIds = getAllChatInputNodeIds(tweaks);
const fileNodeIds = getAllFileNodeIds(tweaks);
const nonFileTweaks = getNonFileTypeTweaks(tweaks);
const chatInputNodeIds = getAllChatInputNodeIds(originalTweaks); // Use original tweaks for detection
const fileNodeIds = getAllFileNodeIds(originalTweaks); // Use original tweaks for detection
const nonFileTweaks = getNonFileTypeTweaks(tweaks); // Use aliased tweaks for display

// Build upload commands and tweak entries
const uploadCommands: string[] = [];
Expand All @@ -152,16 +162,17 @@ curl.exe --request POST \`
--form "file=@your_image_${uploadCounter}.jpg"`,
);
}
const originalTweak = tweaks[nodeId];

// Get alias for this node
const node = nodes?.find((n) => n.id === nodeId);
const alias = node ? getEffectiveAliasFromAnyNode(node) : nodeId;

Comment on lines +166 to +169
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing import for getEffectiveAliasFromAnyNode causes build error

Function is used but not imported.

Apply:

 import { GetCodeType } from "@/types/tweaks";
+import { getEffectiveAliasFromAnyNode } from "@/types/flow";

Also applies to: 199-202

🤖 Prompt for AI Agents
In src/frontend/src/modals/apiModal/utils/get-curl-code.tsx around lines 166-169
(and also at 199-202) the function getEffectiveAliasFromAnyNode is used but not
imported; add a named import for getEffectiveAliasFromAnyNode from the module
that exports it at the top of the file (the same module where other node-alias
helper functions are exported), then rebuild to confirm the missing-import error
is resolved.

const originalTweak = originalTweaks[nodeId];
const modifiedTweak = { ...originalTweak };
modifiedTweak.files = [
`REPLACE_WITH_FILE_PATH_FROM_UPLOAD_${uploadCounter}`,
];
const tweakEntry = ` "${nodeId}": ${JSON.stringify(
modifiedTweak,
null,
6,
)
const tweakEntry = ` "${alias}": ${JSON.stringify(modifiedTweak, null, 6)
.split("\n")
.join("\n ")}`;
tweakEntries.push(tweakEntry);
Expand All @@ -185,7 +196,11 @@ curl.exe --request POST \`
--form "file=@your_file_${uploadCounter}.pdf"`,
);
}
const originalTweak = tweaks[nodeId];
// Get alias for this node
const node = nodes?.find((n) => n.id === nodeId);
const alias = node ? getEffectiveAliasFromAnyNode(node) : nodeId;

const originalTweak = originalTweaks[nodeId];
const modifiedTweak = { ...originalTweak };
if ("path" in originalTweak) {
modifiedTweak.path = [
Expand All @@ -194,21 +209,17 @@ curl.exe --request POST \`
} else if ("file_path" in originalTweak) {
modifiedTweak.file_path = `REPLACE_WITH_FILE_PATH_FROM_UPLOAD_${uploadCounter}`;
}
const tweakEntry = ` "${nodeId}": ${JSON.stringify(
modifiedTweak,
null,
6,
)
const tweakEntry = ` "${alias}": ${JSON.stringify(modifiedTweak, null, 6)
.split("\n")
.join("\n ")}`;
tweakEntries.push(tweakEntry);
uploadCounter++;
});

// Add non-file tweaks
Object.entries(nonFileTweaks).forEach(([nodeId, tweak]) => {
// Add non-file tweaks (already aliased)
Object.entries(nonFileTweaks).forEach(([aliasOrNodeId, tweak]) => {
tweakEntries.push(
` "${nodeId}": ${JSON.stringify(tweak, null, 6)
` "${aliasOrNodeId}": ${JSON.stringify(tweak, null, 6)
.split("\n")
.join("\n ")}`,
);
Expand Down
16 changes: 13 additions & 3 deletions src/frontend/src/modals/apiModal/utils/get-js-api-code.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customGetHostProtocol } from "@/customization/utils/custom-get-host-protocol";
import { convertTweaksToAliases } from "@/utils/aliasUtils";
import {
getAllChatInputNodeIds,
getAllFileNodeIds,
Expand All @@ -15,11 +16,13 @@ export function getNewJsApiCode({
endpointName,
processedPayload,
shouldDisplayApiKey,
nodes,
}: {
flowId: string;
endpointName: string;
processedPayload: any;
shouldDisplayApiKey: boolean;
nodes?: any[];
}): string {
const { protocol, host } = customGetHostProtocol();
const baseUrl = `${protocol}//${host}`;
Expand All @@ -31,14 +34,21 @@ export function getNewJsApiCode({
parsedUrl.port || (parsedUrl.protocol === "https:" ? "443" : "80");

// Check if there are file uploads
const tweaks = processedPayload.tweaks || {};
const hasFiles = hasFileTweaks(tweaks);
const originalTweaks = processedPayload.tweaks || {};
const tweaks = convertTweaksToAliases(originalTweaks, nodes);
const hasFiles = hasFileTweaks(originalTweaks); // Use original tweaks for file detection

// Create payload with aliased tweaks
const payloadWithAliases = {
...processedPayload,
tweaks: tweaks,
};

// If no file uploads, use existing logic
if (!hasFiles) {
const apiUrl = `${baseUrl}/api/v1/run/${endpointName || flowId}`;

const payloadString = JSON.stringify(processedPayload, null, 4);
const payloadString = JSON.stringify(payloadWithAliases, null, 4);

const authSection = shouldDisplayApiKey
? `const crypto = require('crypto');
Expand Down
16 changes: 13 additions & 3 deletions src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customGetHostProtocol } from "@/customization/utils/custom-get-host-protocol";
import { convertTweaksToAliases } from "@/utils/aliasUtils";
import {
getAllChatInputNodeIds,
getAllFileNodeIds,
Expand All @@ -15,23 +16,32 @@ export function getNewPythonApiCode({
endpointName,
processedPayload,
shouldDisplayApiKey,
nodes,
}: {
flowId: string;
endpointName: string;
processedPayload: any;
shouldDisplayApiKey: boolean;
nodes?: any[];
}): string {
const { protocol, host } = customGetHostProtocol();
const baseUrl = `${protocol}//${host}`;

// Check if there are file uploads
const tweaks = processedPayload.tweaks || {};
const hasFiles = hasFileTweaks(tweaks);
const originalTweaks = processedPayload.tweaks || {};
const tweaks = convertTweaksToAliases(originalTweaks, nodes);
const hasFiles = hasFileTweaks(originalTweaks); // Use original tweaks for file detection

// Create payload with aliased tweaks
const payloadWithAliases = {
...processedPayload,
tweaks: tweaks,
};

// If no file uploads, use existing logic
if (!hasFiles) {
const apiUrl = `${baseUrl}/api/v1/run/${endpointName || flowId}`;
const payloadString = JSON.stringify(processedPayload, null, 4)
const payloadString = JSON.stringify(payloadWithAliases, null, 4)
.replace(/true/g, "True")
.replace(/false/g, "False")
.replace(/null/g, "None");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ export function FlowSidebarComponent({ isLoading }: FlowSidebarComponentProps) {
const hasMcpServers = Boolean(mcpServers && mcpServers.length > 0);

const hasSearchInput = search !== "" || filterType !== undefined;
console.log("hasSearchInput", hasSearchInput);

const showComponents =
(ENABLE_NEW_SIDEBAR &&
Expand Down
Loading
Loading