feat(FN-2501): merge fusion/fn-2501

This commit is contained in:
gsxdsm
2026-04-25 14:24:35 -07:00
parent 633644a665
commit 1a8058f334
10 changed files with 231 additions and 40 deletions

View File

@@ -444,13 +444,6 @@ export function AgentsView({ addToast, projectId }: AgentsViewProps) {
try {
await updateAgentState(agentId, newState, projectId);
addToast(`Agent state updated to ${newState}`, "success");
if (newState === "active") {
try {
await startAgentRun(agentId, projectId);
} catch (runErr) {
addToast(`Agent activated, but failed to start run: ${getErrorMessage(runErr)}`, "error");
}
}
void loadAgents();
} catch (err) {
addToast(`Failed to update state: ${getErrorMessage(err)}`, "error");

View File

@@ -1078,9 +1078,9 @@ describe("AgentsView", () => {
await waitFor(() => {
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-001", "active", undefined);
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-001", undefined);
});
expect(mockStartAgentRun).not.toHaveBeenCalled();
expect(mockAddToast).toHaveBeenCalledWith(
expect.stringContaining("active"),
"success"
@@ -1114,7 +1114,7 @@ describe("AgentsView", () => {
});
});
it("can resume paused agent", async () => {
it("can resume paused agent without manual run trigger", async () => {
render(<AgentsView addToast={mockAddToast} />);
await waitFor(() => {
@@ -1125,8 +1125,9 @@ describe("AgentsView", () => {
await waitFor(() => {
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-003", "active", undefined);
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-003", undefined);
});
expect(mockStartAgentRun).not.toHaveBeenCalled();
});
it("handles state change error gracefully", async () => {
@@ -1148,27 +1149,6 @@ describe("AgentsView", () => {
});
});
it("shows error toast when startAgentRun fails but still updates state", async () => {
mockStartAgentRun.mockRejectedValue(new Error("Run failed"));
render(<AgentsView addToast={mockAddToast} />);
await waitFor(() => {
expect(screen.getByTitle("Activate")).toBeTruthy();
});
fireEvent.click(screen.getByTitle("Activate"));
await waitFor(() => {
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-001", "active", undefined);
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-001", undefined);
expect(mockAddToast).toHaveBeenCalledWith(
expect.stringContaining("failed to start run"),
"error"
);
});
});
it("does not start run when pausing agent", async () => {
render(<AgentsView addToast={mockAddToast} />);