From 228554d1251f18313719d147ec2bdbde3a4ec2d5 Mon Sep 17 00:00:00 2001 From: Phil Larson Date: Tue, 30 Jun 2026 22:03:41 -0700 Subject: [PATCH] fix(compound-engineering): clear artifact project scope drift --- .changeset/fix-compound-artifact-project-scope.md | 7 +++++++ .../src/dashboard/CompoundEngineeringView.tsx | 2 +- .../dashboard/__tests__/CompoundEngineeringView.test.tsx | 7 ++++--- .../src/dashboard/hooks/useArtifacts.ts | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/fix-compound-artifact-project-scope.md diff --git a/.changeset/fix-compound-artifact-project-scope.md b/.changeset/fix-compound-artifact-project-scope.md new file mode 100644 index 0000000000..49ca2de774 --- /dev/null +++ b/.changeset/fix-compound-artifact-project-scope.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Prevent Compound Engineering artifacts from showing stale project files after project switches. +category: fix +dev: Clears cached artifact discovery on project changes and opens CE artifacts through the project workspace. diff --git a/plugins/fusion-plugin-compound-engineering/src/dashboard/CompoundEngineeringView.tsx b/plugins/fusion-plugin-compound-engineering/src/dashboard/CompoundEngineeringView.tsx index 5b0af194cb..d7014c4258 100644 --- a/plugins/fusion-plugin-compound-engineering/src/dashboard/CompoundEngineeringView.tsx +++ b/plugins/fusion-plugin-compound-engineering/src/dashboard/CompoundEngineeringView.tsx @@ -223,7 +223,7 @@ function ArtifactRow({ type="button" className="ce-artifact-open" data-testid="ce-artifact-open" - onClick={() => openFile?.(entry.path)} + onClick={() => openFile?.(entry.path, { workspace: "project" })} > Open diff --git a/plugins/fusion-plugin-compound-engineering/src/dashboard/__tests__/CompoundEngineeringView.test.tsx b/plugins/fusion-plugin-compound-engineering/src/dashboard/__tests__/CompoundEngineeringView.test.tsx index 015e8bfff6..97589a521c 100644 --- a/plugins/fusion-plugin-compound-engineering/src/dashboard/__tests__/CompoundEngineeringView.test.tsx +++ b/plugins/fusion-plugin-compound-engineering/src/dashboard/__tests__/CompoundEngineeringView.test.tsx @@ -3,7 +3,7 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import type { DiscoveryResult } from "../../artifacts/discovery.js"; // Mock the network layer so the view renders from seeded discovery results. -const listArtifacts = vi.fn(async (): Promise => { +const listArtifacts = vi.fn(async (_projectId?: string): Promise => { throw new Error("listArtifacts mock not configured"); }); const listSessions = vi.fn(async (): Promise => []); @@ -15,7 +15,7 @@ const getSession = vi.fn(async (_id: string, _projectId?: string): Promise ({ - listArtifacts: () => listArtifacts(), + listArtifacts: (projectId?: string) => listArtifacts(projectId), getArtifactPreviewUrl: (id: string) => `/preview/${id}`, listSessions: () => listSessions(), deleteSession: (id: string, projectId?: string) => deleteSession(id, projectId), @@ -95,6 +95,7 @@ describe("CompoundEngineeringView", () => { render(); await screen.findByTestId("ce-empty-state"); + expect(listArtifacts).toHaveBeenCalledWith("p1"); expect(screen.getByText(/Start your compounding pipeline/i)).toBeInTheDocument(); const start = screen.getByTestId("ce-start-action"); expect(start).toBeInTheDocument(); @@ -144,7 +145,7 @@ describe("CompoundEngineeringView", () => { await screen.findByTestId("ce-artifact"); fireEvent.click(screen.getByTestId("ce-artifact-open")); - expect(openFile).toHaveBeenCalledWith("STRATEGY.md"); + expect(openFile).toHaveBeenCalledWith("STRATEGY.md", { workspace: "project" }); }); it("renders artifact open button without crashing when openFile is not in context", async () => { diff --git a/plugins/fusion-plugin-compound-engineering/src/dashboard/hooks/useArtifacts.ts b/plugins/fusion-plugin-compound-engineering/src/dashboard/hooks/useArtifacts.ts index b223bb2a6d..49bab05466 100644 --- a/plugins/fusion-plugin-compound-engineering/src/dashboard/hooks/useArtifacts.ts +++ b/plugins/fusion-plugin-compound-engineering/src/dashboard/hooks/useArtifacts.ts @@ -57,6 +57,9 @@ export function useArtifacts({ return; } + setResult(undefined); + setError(undefined); + const controller = new AbortController(); setLoading(true); listArtifacts(projectId)