fix(compound-engineering): clear artifact project scope drift
This commit is contained in:
7
.changeset/fix-compound-artifact-project-scope.md
Normal file
7
.changeset/fix-compound-artifact-project-scope.md
Normal file
@@ -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.
|
||||
@@ -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
|
||||
</button>
|
||||
|
||||
@@ -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<DiscoveryResult> => {
|
||||
const listArtifacts = vi.fn(async (_projectId?: string): Promise<DiscoveryResult> => {
|
||||
throw new Error("listArtifacts mock not configured");
|
||||
});
|
||||
const listSessions = vi.fn(async (): Promise<CeSession[]> => []);
|
||||
@@ -15,7 +15,7 @@ const getSession = vi.fn(async (_id: string, _projectId?: string): Promise<CeSes
|
||||
throw new Error("getSession mock not configured");
|
||||
});
|
||||
vi.mock("../hooks/api.js", () => ({
|
||||
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(<CompoundEngineeringView projectId="p1" enabledOverride />);
|
||||
|
||||
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 () => {
|
||||
|
||||
@@ -57,6 +57,9 @@ export function useArtifacts({
|
||||
return;
|
||||
}
|
||||
|
||||
setResult(undefined);
|
||||
setError(undefined);
|
||||
|
||||
const controller = new AbortController();
|
||||
setLoading(true);
|
||||
listArtifacts(projectId)
|
||||
|
||||
Reference in New Issue
Block a user