feat: add agent delete command and bulk tab close operations

This commit is contained in:
Mohamed Boudra
2026-03-07 12:32:49 +07:00
parent 6b51088f39
commit 1d1c7058f1
21 changed files with 783 additions and 86 deletions
@@ -0,0 +1,82 @@
import { describe, expect, it } from "vitest";
import {
buildBulkCloseConfirmationMessage,
classifyBulkClosableTabs,
} from "@/screens/workspace/workspace-bulk-close";
import type { WorkspaceTabDescriptor } from "@/screens/workspace/workspace-tabs-types";
function makeAgentTab(id: string): WorkspaceTabDescriptor {
return {
key: `agent_${id}`,
tabId: `agent_${id}`,
kind: "agent",
agentId: id,
provider: "codex",
label: `Agent ${id}`,
subtitle: "",
titleState: "ready",
};
}
function makeTerminalTab(id: string): WorkspaceTabDescriptor {
return {
key: `terminal_${id}`,
tabId: `terminal_${id}`,
kind: "terminal",
terminalId: id,
label: `Terminal ${id}`,
subtitle: "",
};
}
function makeFileTab(path: string): WorkspaceTabDescriptor {
return {
key: `file_${path}`,
tabId: `file_${path}`,
kind: "file",
filePath: path,
label: path.split("/").pop() ?? path,
subtitle: path,
};
}
describe("workspace bulk close helpers", () => {
it("classifies agent, terminal, and passive tabs for shared bulk close handling", () => {
const groups = classifyBulkClosableTabs([
makeAgentTab("a1"),
makeTerminalTab("t1"),
makeFileTab("/repo/README.md"),
]);
expect(groups).toEqual({
agentTabs: [{ tabId: "agent_a1", agentId: "a1" }],
terminalTabs: [{ tabId: "terminal_t1", terminalId: "t1" }],
otherTabs: [{ tabId: "file_/repo/README.md" }],
});
});
it("describes mixed destructive bulk close operations in the confirmation copy", () => {
const message = buildBulkCloseConfirmationMessage(
classifyBulkClosableTabs([
makeAgentTab("a1"),
makeAgentTab("a2"),
makeTerminalTab("t1"),
makeFileTab("/repo/README.md"),
])
);
expect(message).toBe(
"This will archive 2 agent(s), close 1 terminal(s), and close 1 tab(s). Any running process in a closed terminal will be stopped immediately."
);
});
it("keeps terminal-only confirmations explicit about stopping running processes", () => {
const message = buildBulkCloseConfirmationMessage(
classifyBulkClosableTabs([makeTerminalTab("t1")])
);
expect(message).toBe(
"This will close 1 terminal(s). Any running process in a closed terminal will be stopped immediately."
);
});
});