Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -6,6 +6,8 @@ import { CopyText } from "@/components/shared/CopyText/CopyText";
import { Icon } from "@/components/ui/icon";
import { BlockStack, InlineStack } from "@/components/ui/layout";
import { Text } from "@/components/ui/typography";
import { useExecutionData } from "@/providers/ExecutionDataProvider";
import { resolveInputValue } from "@/routes/v2/shared/nodes/IONode/resolveInputValue";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { tracking } from "@/utils/tracking";

Expand All @@ -17,6 +19,7 @@ export const RunViewInputDetails = observer(function RunViewInputDetails({
entityId,
}: RunViewInputDetailsProps) {
const spec = useSpec();
const { details } = useExecutionData();
const input = spec?.inputs.find((i) => i.$id === entityId);

if (!input) {
Expand All @@ -30,6 +33,7 @@ export const RunViewInputDetails = observer(function RunViewInputDetails({
}

const type = input.type ? String(input.type) : undefined;
const value = resolveInputValue(input, details?.task_spec.arguments);

return (
<BlockStack
Expand Down Expand Up @@ -75,7 +79,18 @@ export const RunViewInputDetails = observer(function RunViewInputDetails({
</BlockStack>
)}

{input.defaultValue && (
{value !== undefined && (
<BlockStack gap="1">
<Text size="xs" tone="subdued" weight="semibold">
Value
</Text>
<CopyText size="sm" className="font-mono whitespace-pre-wrap">
{value}
</CopyText>
</BlockStack>
)}

{input.defaultValue !== undefined && (
<BlockStack gap="1">
<Text size="xs" tone="subdued" weight="semibold">
Default Value
Expand Down
11 changes: 7 additions & 4 deletions src/routes/v2/shared/nodes/IONode/IONode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type Node, type NodeProps } from "@xyflow/react";
import { observer } from "mobx-react-lite";
import { type MouseEvent } from "react";

import { useExecutionDataOptional } from "@/providers/ExecutionDataProvider";
import { useIsDetailedView } from "@/routes/v2/shared/hooks/useIsDetailedView";
import type { IONodeData } from "@/routes/v2/shared/nodes/types";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
Expand All @@ -10,6 +11,7 @@ import { useSharedStores } from "@/routes/v2/shared/store/SharedStoreContext";

import { IONodeCard } from "./IONodeCard";
import { IONodeSimplified } from "./IONodeSimplified";
import { resolveInputValue } from "./resolveInputValue";

type IONodeType = Node<IONodeData, "input" | "output">;
type IONodeProps = NodeProps<IONodeType>;
Expand All @@ -19,7 +21,7 @@ export interface IONodeViewProps {
name: string;
type?: string;
description?: string;
defaultValue?: string;
value?: string;
connectedValue: string | null;
isInput: boolean;
selected: boolean;
Expand All @@ -43,6 +45,7 @@ export const IONode = observer(function IONode({
const showContent = useIsDetailedView();

const spec = useSpec();
const executionData = useExecutionDataOptional();
const isInput = ioType === "input";

const entity = isInput
Expand Down Expand Up @@ -76,9 +79,9 @@ export const IONode = observer(function IONode({
}
}

const defaultValue =
const value =
isInput && entity && "defaultValue" in entity
? (entity.defaultValue ?? undefined)
? resolveInputValue(entity, executionData?.details?.task_spec.arguments)
: undefined;

const isSelected = isEditorVisualNodeSelected(editor, id, !!selected);
Expand All @@ -88,7 +91,7 @@ export const IONode = observer(function IONode({
name,
type,
description,
defaultValue,
value,
connectedValue,
isInput,
selected: isSelected,
Expand Down
6 changes: 2 additions & 4 deletions src/routes/v2/shared/nodes/IONode/IONodeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function IONodeCard({
name,
type,
description,
defaultValue,
value,
connectedValue,
isInput,
selected,
Expand Down Expand Up @@ -75,9 +75,7 @@ export function IONodeCard({
font="mono"
className="truncate text-ink-fixed/70"
>
{isInput
? (defaultValue ?? "No value")
: (connectedValue ?? "No value")}
{isInput ? (value ?? "No value") : (connectedValue ?? "No value")}
</Paragraph>
</InlineStack>
</BlockStack>
Expand Down
39 changes: 39 additions & 0 deletions src/routes/v2/shared/nodes/IONode/resolveInputValue.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { describe, expect, it } from "vitest";

import { Input } from "@/models/componentSpec/entities/input";

import { resolveInputValue } from "./resolveInputValue";

function createInput() {
return new Input({
$id: "input-template-params",
name: "template_params",
value: "configured value",
defaultValue: "default value",
});
}

describe("resolveInputValue", () => {
it("prefers the run argument over the configured and default values", () => {
const input = createInput();

expect(resolveInputValue(input, { template_params: "run value" })).toBe(
"run value",
);
});

it("preserves an empty run argument instead of showing the default", () => {
const input = createInput();

expect(resolveInputValue(input, { template_params: "" })).toBe("");
});

it("falls back to the configured value and then the default", () => {
const input = createInput();

expect(resolveInputValue(input)).toBe("configured value");

input.setValue(undefined);
expect(resolveInputValue(input)).toBe("default value");
});
});
14 changes: 14 additions & 0 deletions src/routes/v2/shared/nodes/IONode/resolveInputValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TaskSpecOutput } from "@/api/types.gen";
import type { Input } from "@/models/componentSpec/entities/input";
import { getArgumentValue } from "@/utils/nodes/taskArguments";

export function resolveInputValue(
input: Input,
taskArguments?: TaskSpecOutput["arguments"] | null,
): string | undefined {
return (
getArgumentValue(taskArguments ?? undefined, input.name) ??
input.value ??
input.defaultValue
);
}
Loading