Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(automations): open the waiting run from Answer, the same run Cancel run stops
AdityaUmale3a3a7e75a33f
diff --git a/src/components/automations/automations.test.ts b/src/components/automations/automations.test.tsindex 71b7d0f745..77b508f11c 100644--- a/src/components/automations/automations.test.ts+++ b/src/components/automations/automations.test.ts@@ -354,6 +354,18 @@ describe("a run that waits on the person", () => {await vi.waitFor(() => expect(fixture.dispatch).toHaveBeenCalledWith({ type: "routineRunPatched", run: cancelled }));});+ it("opens and cancels the same waiting run when a newer run was cancelled", async () => {+ const newer = { ...run("cancelled"), id: "run-2", threadId: "exec-2", scheduledFor: now - 30_000, startedAt: now - 30_000, createdAt: now - 30_000, finishedAt: now };+ const [automation] = automationsFrom({ routines: [routine] as never, webhooks: [], runs: [newer, run("waiting")] as never });+ const container = mount(createElement(AutomationPanel, { automation: automation!, sentence: "s", onClose: vi.fn(), onEdit: vi.fn(), onDeleted: vi.fn() }));+ flushSync(() => button(container, "Answer")!.click());+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "bot-a", threadId: "exec-1" });+ expect(fixture.dispatch).not.toHaveBeenCalledWith(expect.objectContaining({ threadId: "exec-2" }));+ fixture.api.mockResolvedValue({ run: { ...run("cancelled"), finishedAt: now } });+ flushSync(() => cancel(container)!.click());+ await vi.waitFor(() => expect(fixture.api).toHaveBeenCalledWith("/api/routine-runs/run-1/cancel", { method: "POST" }));+ });+it("offers no Cancel run when nothing waits", () => {expect(cancel(panel("failed"))).toBeNull();root?.unmount(); root = null; document.body.innerHTML = "";diff --git a/src/components/automations/parts.tsx b/src/components/automations/parts.tsxindex f09365dea4..9434f42a09 100644--- a/src/components/automations/parts.tsx+++ b/src/components/automations/parts.tsx@@ -26,7 +26,8 @@ export function FixButton({ automation, status, actions, onEdit, className }: {const fix = status.fix;const waiting = fix === "answer" ? automation.runs.find((run) => run.status === "waiting") : undefined;const onClick = () => {- if (fix === "answer" || fix === "sign-in") actions.openRun(automation, automation.runs.find((run) => run.status !== "queued"));+ if (fix === "answer") actions.openRun(automation, waiting);+ else if (fix === "sign-in") actions.openRun(automation, automation.runs.find((run) => run.status !== "queued"));else if (fix === "usage") dispatch({ type: "toggleAppSettings", open: true, section: "usage" });else if (fix === "edit") onEdit();else if (fix === "reconnect") dispatch({ type: "togglePlugins", open: true, surface: "apps" });