mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 04:29:01 +01:00
fix(ui): keep Pause available for errored agents
Show Pause alongside Clear error in the inline actions and profile menu. Operators can disable an errored agent without clearing its error first. Verify both layouts and assert that Pause invokes neither Clear error nor Run. All 45 AgentActionButtons component tests pass. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
784bc06276
commit
d13a3ad330
2 files changed
+35
-8
No files matched your search
@@ -262,14 +262,22 @@ describe("AgentActionButtons", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("replaces the pause slot with Clear error for error agents", async () => {
|
||||
it("keeps Pause alongside Clear error for error agents", async () => {
|
||||
render(makeAgent({ status: "error" }));
|
||||
await flushReact();
|
||||
|
||||
expect(container.textContent).toContain("Clear error");
|
||||
expect(container.textContent).not.toContain("Pause");
|
||||
const pause = [...container.querySelectorAll("button")].find(button => button.textContent === "Pause");
|
||||
expect(pause).toBeDefined();
|
||||
expect(pause!.disabled).toBe(false);
|
||||
expect(container.textContent).toContain("Run Heartbeat");
|
||||
|
||||
await act(async () => pause!.click());
|
||||
await flushReact();
|
||||
expect(mockAgentsApi.pause).toHaveBeenCalledWith("agent-1", "company-1");
|
||||
expect(mockAgentsApi.clearError).not.toHaveBeenCalled();
|
||||
expect(mockAgentsApi.invoke).not.toHaveBeenCalled();
|
||||
|
||||
await act(async () => {
|
||||
container.querySelector<HTMLButtonElement>('[aria-label="Open actions for Alpha Agent"]')?.click();
|
||||
});
|
||||
@@ -294,7 +302,7 @@ describe("AgentActionButtons", () => {
|
||||
});
|
||||
await flushReact();
|
||||
const items = [...document.body.querySelectorAll("[data-slot='popover-content'] button, [data-radix-popper-content-wrapper] button")].map((button) => button.textContent?.trim());
|
||||
expect(items).toEqual(["Run Heartbeat", "Clear error", "Agent history", "Duplicate agent", "Copy agent ID", "Reset sessions", "Terminate"]);
|
||||
expect(items).toEqual(["Run Heartbeat", "Clear error", "Pause", "Agent history", "Duplicate agent", "Copy agent ID", "Reset sessions", "Terminate"]);
|
||||
|
||||
await act(async () => {
|
||||
[...document.body.querySelectorAll("button")].find((button) => button.textContent?.trim() === "Agent history")?.click();
|
||||
@@ -312,6 +320,23 @@ describe("AgentActionButtons", () => {
|
||||
expect(mockAgentsApi.clearError).toHaveBeenCalledWith("agent-1", "company-1");
|
||||
});
|
||||
|
||||
it("pauses an errored agent directly from the profile menu", async () => {
|
||||
render(makeAgent({ status: "error" }), { workActionsInMenu: true });
|
||||
await flushReact();
|
||||
await act(async () => {
|
||||
container.querySelector<HTMLButtonElement>('[aria-label="Open actions for Alpha Agent"]')!.click();
|
||||
});
|
||||
await flushReact();
|
||||
const pause = [...document.body.querySelectorAll("button")].find(button => button.textContent?.trim() === "Pause");
|
||||
expect(pause).toBeDefined();
|
||||
expect(pause!.disabled).toBe(false);
|
||||
await act(async () => pause!.click());
|
||||
await flushReact();
|
||||
expect(mockAgentsApi.pause).toHaveBeenCalledWith("agent-1", "company-1");
|
||||
expect(mockAgentsApi.clearError).not.toHaveBeenCalled();
|
||||
expect(mockAgentsApi.invoke).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps Finish setup as the one button while setup is pending in menu mode", async () => {
|
||||
render(makeAgent({ status: "paused", lifecycleState: "paused", pauseReason: "setup" }), {
|
||||
assignLabel: "Assign task",
|
||||
|
||||
@@ -454,7 +454,7 @@ export function AgentActionButtons({
|
||||
{runLabel}
|
||||
</button>
|
||||
) : null}
|
||||
{needsSetup ? null : isAgentError ? (
|
||||
{!needsSetup && isAgentError && (
|
||||
<button
|
||||
type="button"
|
||||
className={cn(item, "text-destructive")}
|
||||
@@ -465,7 +465,8 @@ export function AgentActionButtons({
|
||||
<CheckCircle2 className={cn(icon, "text-destructive")} />
|
||||
Clear error
|
||||
</button>
|
||||
) : isPaused ? (
|
||||
)}
|
||||
{needsSetup ? null : isPaused ? (
|
||||
<button type="button" className={item} disabled={pauseResumeDisabled} onClick={select(() => agentAction.mutate("resume"))}>
|
||||
<Play className={icon} />
|
||||
Resume
|
||||
@@ -592,13 +593,14 @@ export function AgentActionButtons({
|
||||
label={runLabel}
|
||||
size={size}
|
||||
/>}
|
||||
{!needsSetup && (agent.status === "error" ? (
|
||||
{!needsSetup && agent.status === "error" && (
|
||||
<ClearErrorButton
|
||||
onClick={() => agentAction.mutate("clear_error")}
|
||||
disabled={clearErrorDisabled}
|
||||
size={size}
|
||||
/>
|
||||
) : (
|
||||
)}
|
||||
{!needsSetup && (
|
||||
<PauseResumeButton
|
||||
isPaused={isPaused}
|
||||
onPause={() => (pauseConfirm ? setPauseConfirmOpen(true) : agentAction.mutate("pause"))}
|
||||
@@ -606,7 +608,7 @@ export function AgentActionButtons({
|
||||
disabled={pauseResumeDisabled}
|
||||
size={size}
|
||||
/>
|
||||
))}
|
||||
)}
|
||||
{pauseConfirm && (
|
||||
<AlertDialog open={pauseConfirmOpen} onOpenChange={setPauseConfirmOpen}>
|
||||
<AlertDialogContent>
|
||||
|
||||
Reference in new issue
Block a user