fix(agents): replace send with stop and simplify header (#7526)

While a session is running and there is nothing to send, the Send/Queue button becomes Stop; with a draft, Queue stays and Stop moves into the message actions menu. The Automations clock leaves the Agents header (Automations stays in the Options menu), and the gear opens Agent Settings instead of MCP Connections.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-02 21:35:18 +08:00
1 джерело b7bacc8ff5
коміт 4466a059b3
9 files changed
+125 -47

No files matched your search

+42 -2
Переглянути файл
@@ -442,13 +442,17 @@ test("creates, validates cron, runs, inspects provenance, exports/imports .autom
await page.setViewportSize({ width: 1320, height: 860 });
await installAutomationDesktopHarness(page);
// Open Agents tool window and click the Automations header button
// Open Agents tool window and use the existing Automations options entry
await page.evaluate(async () => {
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
await executeAction("agents.showToolWindow");
});
await page.getByRole("button", { name: "Agent Automations" }).click();
const header = page.locator('[data-toolwindow="agents"] header');
await expect(header.getByRole("button", { name: "Agent Automations", exact: true })).toHaveCount(0);
await expect(header.getByRole("button", { name: "Agent Settings", exact: true })).toBeVisible();
await header.getByRole("button", { name: "Options", exact: true }).click();
await page.getByRole("menuitem", { name: "Automations…", exact: true }).click();
const editor = page.getByTestId("automations-editor");
await expect(editor).toBeVisible();
@@ -614,6 +618,42 @@ test("supports SameTask rolling continuity, NeedsInput approval flow, and sideba
await expect(taskTree).not.toContainText("Quiet Clean Sweep (#1)");
});
test("running composer replaces Send with Stop and keeps the Agents header focused", async ({
workbench: page,
}, testInfo) => {
await page.setViewportSize({ width: 1280, height: 840 });
await installAutomationDesktopHarness(page);
await page.evaluate(async () => {
const storeModule = "/src/features/agents/store.ts";
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
const store = await import(/* @vite-ignore */ storeModule);
await executeAction("agents.showToolWindow");
const task = store.useAgents.getState().tasks.get("manual-session-1");
store.useAgents.setState((s: { tasks: Map<string, AgentTask> }) => ({
tasks: new Map(s.tasks).set(task.id, { ...task, status: "running" }),
}));
store.openTask(task.id);
});
await expect(page.getByRole("button", { name: "Agent Settings", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Agent Automations", exact: true })).toHaveCount(0);
const stop = page.getByRole("button", { name: "Stop", exact: true });
await expect(stop).toBeEnabled();
await expect(page.getByRole("button", { name: "Queue", exact: true })).toHaveCount(0);
await page.locator('[data-toolwindow="agents"] header').hover();
await page.screenshot({ path: testInfo.outputPath("running-composer.png"), animations: "disabled" });
const before = (await stop.boundingBox())!;
await page.getByRole("textbox", { name: "Message" }).fill("Follow up");
const queue = page.getByRole("button", { name: "Queue", exact: true });
await expect(queue).toBeEnabled();
await expect(stop).toHaveCount(0);
const after = (await queue.boundingBox())!;
expect(after.x).toBeCloseTo(before.x, 0);
expect(after.width).toBeCloseTo(before.width, 0);
await page.getByRole("button", { name: "Message Actions" }).click();
await expect(page.getByRole("menuitem", { name: "Stop", exact: true })).toBeVisible();
});
test("schedules in-session Send Later, /loop recurring prompts, and /automate from SessionComposer", async ({
workbench: page,
}) => {
+16 -1
Переглянути файл
@@ -8,7 +8,7 @@ import { confirm, confirmChecked, showError } from "@/workbench/messages";
import { promptInput } from "@/workbench/inputDialogs";
import { ContextMenuHost, dragSession, hideContextMenu } from "@/ui";
import { AgentsHeaderActions, AgentsView } from "./AgentsView";
import { GROUP_DRAG, SESSION_KIND, TASK_DRAG } from "./model";
import { GROUP_DRAG, REGISTRY_PAGE, SESSION_KIND, TASK_DRAG } from "./model";
import { usePlatform } from "@/platform/platformInfo";
import { archiveTask, unarchiveTask, deleteTask, dockTask, openTask, useAgents } from "./store";
import { taskActions, taskMenu, useAgentsHeaderMenu } from "./taskActions";
@@ -143,6 +143,21 @@ function setup() {
);
}
it("removes the redundant Automations header button and opens Agent Settings from the gear", () => {
const settings = vi.fn();
const unregister = registerActions([{ id: "file.settings", title: "Settings…", run: settings }]);
try {
const { container } = render(<AgentsHeaderActions />);
expect(container.querySelectorAll("button")).toHaveLength(2);
const gear = screen.getByRole("button", { name: "Agent Settings" });
expect(gear).toHaveAttribute("data-tooltip", "Agent Settings");
fireEvent.click(gear);
expect(actions.executeAction).toHaveBeenCalledWith("file.settings", REGISTRY_PAGE);
} finally {
unregister();
}
});
describe("Agents selection", () => {
it.each([SESSION_KIND, "file"])("right-clicking a task keeps the current %s view open", (kind) => {
editor.active = { kind, key: "current", data: { task: "one" } };
+2 -8
Переглянути файл
@@ -20,6 +20,7 @@ import {
} from "@/ui";
import {
GROUP_DRAG,
REGISTRY_PAGE,
SESSION_KIND,
TASK_DRAG,
age,
@@ -64,22 +65,15 @@ import { SessionEditor } from "./SessionEditor";
import { HomeEditor } from "./HomeEditor";
import { automatedTaskVisible, useAutomations, useAutomationsSync } from "./automationsModel";
import styles from "./Agents.module.css";
import autoStyles from "./Automations.module.css";
import { basename, useProject } from "@/platform/project";
import { useTx } from "@/platform/i18n";
import { executeAction } from "@/platform/actions";
export function AgentsHeaderActions() {
const host = useAutomations((s) => s.snapshot.host);
const hasAttention = host.unreadRuns > 0 || host.needsInputRuns > 0;
return (
<>
<IconButton icon="plus" action="agents.newTask" />
<span className={autoStyles.headerBadgeWrap}>
<IconButton icon="clock" action="agents.automations" />
{hasAttention && <span className={autoStyles.headerBadgeDot} aria-hidden="true" />}
</span>
<IconButton icon="settings" action="agents.mcpServers" />
<IconButton icon="settings" title="Agent Settings" action="file.settings" actionArg={REGISTRY_PAGE} />
</>
);
}
-17
Переглянути файл
@@ -584,23 +584,6 @@
font-size: var(--fs-small);
}
/* Sidebar tool window header badge dot for unread/attention runs. */
.headerBadgeWrap {
position: relative;
display: inline-flex;
}
.headerBadgeDot {
position: absolute;
top: 4px;
right: 4px;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
pointer-events: none;
}
/* Session provenance banner & schedule strip */
.provenanceBanner {
display: flex;
+2 -2
Переглянути файл
@@ -8,7 +8,7 @@ export function SubmitButton({
variant = "primary",
...props
}: Pick<ButtonProps, "disabled" | "onClick" | "variant"> & {
label: "Start" | "Starting…" | "Send" | "Queue";
label: "Start" | "Starting…" | "Send" | "Queue" | "Stop";
pending?: boolean;
}) {
const tx = useTx();
@@ -22,7 +22,7 @@ export function SubmitButton({
aria-label={name}
{...tooltipAttrs(name)}
>
{pending ? <Spinner size={12} /> : <Icon name="arrow-up" size={14} />}
{pending ? <Spinner size={12} /> : <Icon name={label === "Stop" ? "stop" : "arrow-up"} size={14} />}
</Button>
);
}
+26 -7
Переглянути файл
@@ -43,6 +43,7 @@ vi.mock("@tauri-apps/api/webview", () => ({
}),
}));
import { ContextMenuHost } from "@/ui";
import { SessionEditor } from "./SessionEditor";
import styles from "./Session.module.css";
import { textOf, typeIn } from "./composerTesting";
@@ -521,16 +522,34 @@ describe("session composer submission", () => {
expect(textOf(box)).toBe("");
});
it("keeps Queue named and shows icon-only Stop actions while the agent works", async () => {
it("replaces disabled Send with Stop while working and switches the same button to Queue for a draft", async () => {
useAgents.setState({
tasks: new Map([[task.id, { ...task, status: "running" }]]),
});
render(<SessionEditor input={{ kind: "agent-session", key: task.id, data: { task: task.id } }} />);
const queue = screen.getByRole("button", { name: "Queue" });
expect(queue.textContent).toBe("");
expect(queue).toHaveAttribute("data-tooltip", "Queue");
expect(queue).toBeDisabled();
expect(screen.getAllByRole("button", { name: "Stop" }).every((button) => button.textContent === "")).toBe(true);
render(
<>
<SessionEditor input={{ kind: "agent-session", key: task.id, data: { task: task.id } }} />
<ContextMenuHost />
</>,
);
const stop = screen.getByRole("button", { name: "Stop" });
expect(stop.textContent).toBe("");
expect(stop).toHaveAttribute("data-tooltip", "Stop");
expect(stop).toBeEnabled();
expect(screen.queryByRole("button", { name: "Queue" })).toBeNull();
fireEvent.click(stop);
await waitFor(() => expect(ipc.cancel).toHaveBeenCalledWith(task.id, null));
const box = screen.getByRole("textbox", { name: "Message" });
typeIn(box, "Follow up");
expect(screen.getByRole("button", { name: "Queue" })).toBe(stop);
expect(stop).toHaveAttribute("data-tooltip", "Queue");
expect(stop).toBeEnabled();
expect(screen.queryByRole("button", { name: "Stop" })).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Message Actions" }));
fireEvent.click(screen.getByRole("menuitem", { name: "Stop" }));
await waitFor(() => expect(ipc.cancel).toHaveBeenCalledTimes(2));
expect(textOf(box)).toBe("Follow up");
await screen.findByText("Original message");
});
});
+33 -10
Переглянути файл
@@ -387,6 +387,9 @@ export function SessionComposer({
}, [rawAgentCommands]);
const busy = isBusy(task.status);
const shellRunning = useAgents((s) => s.shellRunning.has(task.id));
const canStop = busy || shellRunning;
const submitDisabled = !canSend(composer) || sending || configuring !== null || task.status === "archived";
const showStop = canStop && submitDisabled;
// ↑ recalls this conversation's messages, newest first (excluding synthetic recovery turns).
const history = useMemo(
() => (entries ?? []).flatMap((e) => (e.type === "user" && !e.recovery && e.text ? [e.text] : [])).reverse(),
@@ -604,14 +607,18 @@ export function SessionComposer({
}
actions={
<>
{(busy || shellRunning) && <IconButton icon="stop" title="Stop" onClick={() => void stopTask(task.id)} />}
<ScheduleSendButton task={task} draftText={composer.text} disabled={task.status === "archived"} />
<ScheduleSendButton
task={task}
draftText={composer.text}
stopInMenu={canStop && !showStop}
disabled={task.status === "archived"}
/>
<SubmitButton
label={busy ? "Queue" : "Send"}
pending={sending}
variant={busy ? "secondary" : "primary"}
disabled={!canSend(composer) || sending || configuring !== null || task.status === "archived"}
onClick={() => send(false)}
label={showStop ? "Stop" : busy ? "Queue" : "Send"}
pending={!showStop && sending}
variant={canStop ? "secondary" : "primary"}
disabled={!showStop && submitDisabled}
onClick={() => (showStop ? void stopTask(task.id) : send(false))}
/>
</>
}
@@ -707,7 +714,17 @@ function QueueRow({ task, item }: { task: string; item: AgentQueued }) {
);
}
function ScheduleSendButton({ task, draftText, disabled }: { task: AgentTask; draftText: string; disabled?: boolean }) {
function ScheduleSendButton({
task,
draftText,
disabled,
stopInMenu,
}: {
task: AgentTask;
draftText: string;
disabled?: boolean;
stopInMenu: boolean;
}) {
const tx = useTx();
const hasDraft = !!draftText.trim();
@@ -752,6 +769,12 @@ function ScheduleSendButton({ task, draftText, disabled }: { task: AgentTask; dr
};
const items: MenuItem[] = [
...(stopInMenu
? [
{ kind: "item" as const, id: "stop", label: "Stop", icon: "stop", run: () => void stopTask(task.id) },
{ kind: "separator" as const },
]
: []),
{
kind: "item",
id: "later-15m",
@@ -817,8 +840,8 @@ function ScheduleSendButton({ task, draftText, disabled }: { task: AgentTask; dr
<IconButton
icon="clock"
size="small"
title={tx("Schedule or Loop Message")}
aria-label={tx("Schedule or Loop Message")}
title={tx(stopInMenu ? "Message Actions" : "Schedule or Loop Message")}
aria-label={tx(stopInMenu ? "Message Actions" : "Schedule or Loop Message")}
disabled={disabled}
onClick={(e) => showContextMenu(e, items)}
/>
+2
Переглянути файл
@@ -2189,6 +2189,8 @@
"sse (Server-Sent Events)": "sse (Server-Sent Events)",
"One KEY=VALUE entry per line.": "One KEY=VALUE entry per line.",
"One Header=Value entry per line.": "One Header=Value entry per line.",
"Agent Settings": "Agent Settings",
"Message Actions": "Message Actions",
"MCP Connections…": "MCP Connections…",
"Configure the MCP servers that agents can use.": "Configure the MCP servers that agents can use.",
"No matching remote branches": "No matching remote branches",
+2
Переглянути файл
@@ -9023,6 +9023,8 @@
"One KEY=VALUE entry per line.": "每行一个 KEY=VALUE 条目。",
"One Header=Value entry per line.": "每行一个 Header=Value 条目。",
"Maven project could not be configured": "无法配置 Maven 项目",
"Agent Settings": "智能体设置",
"Message Actions": "消息操作",
"MCP Connections…": "MCP 连接…",
"Configure the MCP servers that agents can use.": "配置智能体可以使用的 MCP 服务器。",
"Type:": "类型:",