Skip to content

Commit 3436e14

Browse files
committed
fix(web): Run now stays available while a scheduled turn is running
A dispatched scheduled run now stays 'running' until its turn ends, and the thread automations panel disabled Run now for that whole time while Settings still allowed it. A maintainer asked on the PR whether the longer block was intended or whether the existing manual-run behavior could be kept. The panel now enables Run now like Settings and mobile do: only a missing permission or an action already in progress disables it. The running status dot stays. A Run now while the previous turn is still running dispatches another run, as before this change.
1 parent 7886e61 commit 3436e14

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎apps/web/src/components/chat/ThreadAutomationsPanel.permissions.test.tsx‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ vi.mock("../ui/toast", () => ({
3939
import { ThreadAutomationsPanel } from "./ThreadAutomationsPanel";
4040
const environmentId = EnvironmentId.make("remote");
4141
const threadId = ThreadId.make("thread");
42-
const task = {
42+
let task = {
4343
id: ScheduledTaskId.make("task"),
4444
threadId,
4545
title: "Daily review",
4646
enabled: true,
4747
schedule: { type: "interval", everyMs: 60000 },
4848
lastRunStatus: "never",
4949
} as ScheduledTask;
50+
const idleTask = task;
5051
let renderer: ReactTestRenderer;
5152
beforeEach(() => {
53+
task = idleTask;
5254
state.allowed = true;
5355
state.toggle.mockReset().mockResolvedValue({ _tag: "Success" });
5456
state.run.mockReset().mockResolvedValue({ _tag: "Success" });
@@ -82,3 +84,16 @@ it("rejects a retained toggle after task permission is revoked", async () => {
8284
});
8385
expect(state.toggle).not.toHaveBeenCalled();
8486
});
87+
88+
it("keeps Run now available while the last run's turn is still running", async () => {
89+
task = { ...idleTask, lastRunStatus: "running" };
90+
await act(async () => {
91+
renderer = create(<ThreadAutomationsPanel environmentId={environmentId} threadId={threadId} />);
92+
});
93+
const run = renderer.root.findAllByProps({ "aria-label": "Run Daily review now" })[0]!;
94+
expect(run.props.disabled).toBe(false);
95+
await act(async () => {
96+
await run.props.onClick();
97+
});
98+
expect(state.run).toHaveBeenCalledTimes(1);
99+
});

‎apps/web/src/components/chat/ThreadAutomationsPanel.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ export function ThreadAutomationsPanel(props: {
214214
variant="ghost"
215215
part="icon"
216216
aria-label={`Run ${task.title} now`}
217-
disabled={
218-
!canOperate || busyTaskId !== null || task.lastRunStatus === "running"
219-
}
217+
// Like Settings, a turn still running from the last run
218+
// does not block a manual run.
219+
disabled={!canOperate || busyTaskId !== null}
220220
onClick={() => void runNow(task)}
221221
>
222222
<PlayIcon className="size-3.5" />

0 commit comments

Comments
 (0)