Skip to content
Merged
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,11 +6,10 @@ import { Icon } from "@/components/ui/icon";
import { BlockStack } from "@/components/ui/layout";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Text } from "@/components/ui/typography";
import { serializeComponentSpec } from "@/models/componentSpec";
import { getTaskYamlText } from "@/routes/v2/pages/Editor/nodes/TaskNode/context/TaskDetails/components/actions/getTaskYamlText";
import { CodeBlock } from "@/routes/v2/shared/components/CodeBlock";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { tracking } from "@/utils/tracking";
import { componentSpecToText } from "@/utils/yaml";

interface PinnedTaskContentProps {
entityId: string;
Expand All @@ -35,19 +34,9 @@ export const PinnedTaskContent = observer(function PinnedTaskContent({
return <NotFoundState entityId={entityId} />;
}

const componentRef = task.componentRef;
const componentRef = task.resolvedComponentRef;
const componentSpec = task.resolvedComponentSpec;
const code = (() => {
if (componentRef.text) return componentRef.text;
if (task.subgraphSpec) {
return componentSpecToText(serializeComponentSpec(task.subgraphSpec));
}
return componentRef.spec
? componentSpecToText(
componentRef.spec as Parameters<typeof componentSpecToText>[0],
)
: "";
})();
const code = getTaskYamlText(task);

return (
<BlockStack className="h-full w-full bg-card overflow-hidden">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ export const TaskDetails = observer(function TaskDetails({
</InlineStack>

<ComponentRefBar
componentRef={
task.subgraphSpec
? { ...task.componentRef, spec: componentSpec }
: task.componentRef
}
componentRef={task.resolvedComponentRef}
yamlText={yamlText}
taskName={task.name}
pythonCode={pythonCode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import useToastNotification from "@/hooks/useToastNotification";
import { useTask } from "@/routes/v2/pages/Editor/nodes/TaskNode/context/TaskDetails/hooks/useTask";
import { useTaskActions } from "@/routes/v2/pages/Editor/store/actions/useTaskActions";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { isGraphImplementation } from "@/utils/componentSpec";
import { getErrorMessage } from "@/utils/string";

interface UnpackSubgraphButtonProps {
Expand All @@ -29,8 +28,7 @@ export function UnpackSubgraphButton({ entityId }: UnpackSubgraphButtonProps) {
});

if (!task) return null;
if (!isGraphImplementation(task.componentRef.spec?.implementation))
return null;
if (!task.subgraphSpec) return null;

return (
<ActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ export const taskManifest: NodeTypeManifest = {
const clonedArguments = deepClone(snapshot.data.arguments);
const reset = resetAggregatorOnClone(clonedComponentRef, clonedArguments);

const pastedComponentRef = reset?.componentRef ?? clonedComponentRef;

const task = new Task({
$id: idGen.next("task"),
name: uniqueName,
componentRef: reset?.componentRef ?? clonedComponentRef,
componentRef: pastedComponentRef,
isEnabled: snapshot.data.isEnabled
? deepClone(snapshot.data.isEnabled)
: undefined,
Expand All @@ -73,6 +75,8 @@ export const taskManifest: NodeTypeManifest = {
: undefined,
});

task.setComponentRef(pastedComponentRef);

spec.addTask(task);
return task.$id;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ const serializeTask = (task: Task): AiTaskSpec =>
pickDefined({
$id: task.$id,
name: task.name,
componentRef: serializeComponentRef(task.componentRef),
componentRef: serializeComponentRef(task.resolvedComponentRef),
Comment thread
camielvs marked this conversation as resolved.
arguments: task.arguments.map(serializeArgument),
isSubgraph: isGraphImplementation(task.componentRef.spec?.implementation)
isSubgraph: isGraphImplementation(
task.resolvedComponentRef.spec?.implementation,
)
? true
: undefined,
});
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v2/shared/nodes/TaskNode/taskManifestBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function snapshotTask(
name: task.name,
position: task.annotations.get(EDITOR_POSITION_ANNOTATION),
data: {
componentRef: deepClone(task.componentRef),
componentRef: deepClone(task.resolvedComponentRef),
isEnabled: task.isEnabled ? deepClone(task.isEnabled) : undefined,
arguments: task.arguments.map((a) => deepClone(a)),
executionOptions: task.executionOptions
Expand Down
23 changes: 23 additions & 0 deletions src/services/componentService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,35 @@ describe("componentService", () => {
vi.mocked(localforage.componentExistsByUrl).mockResolvedValue(false);
mockFetch.mockResolvedValue({
ok: false,
status: 404,
headers: new Headers(),
statusText: "Not Found",
} as Response);

const result = await fetchAndStoreComponentByUrl(url);

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
`Component at URL ${url} is unavailable: Not Found`,
);
});

it("should keep swallowing retryable fetch errors", async () => {
const url = "https://example.com/component.yaml";
const consoleSpy = vi
.spyOn(console, "error")
.mockImplementation(() => {});

vi.mocked(localforage.componentExistsByUrl).mockResolvedValue(false);
mockFetch.mockResolvedValue({
ok: false,
status: 503,
headers: new Headers(),
statusText: "Service Unavailable",
} as Response);

const result = await fetchAndStoreComponentByUrl(url);

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
`Error fetching component from URL ${url}:`,
Expand Down
Loading
Loading