Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(society): make ungrouping explicit in team chat

rubenluetke10-beepdb82ce390d4e
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.test.tsx
index 25278a0020..14663e3f41 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.test.tsx
@@ -1,10 +1,12 @@
-import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, expect, it, vi } from "vitest";
import type { SocietyAgent } from "../data";
import { ChatGroupPanel } from "./ChatGroupPanel";
+const groupApi = vi.hoisted(() => ({ remove: vi.fn(async () => undefined) }));
vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));
+vi.mock("@/lib/societyChatGroups", () => ({ deleteSocietyChatGroup: groupApi.remove }));
vi.mock("../roster/RosterRail", () => ({ RosterRail: () => <aside /> }));
vi.mock("./AgentChatPanel", () => ({
AgentChatPanel: ({ agent, chatStore }: { agent: SocietyAgent; chatStore: any }) => {
@@ -17,7 +19,7 @@ vi.mock("./AgentChatPanel", () => ({
},
}));
-afterEach(cleanup);
+afterEach(() => { cleanup(); groupApi.remove.mockClear(); });
it("opens two existing agent chats in separate stores and keeps each pane independent", () => {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
@@ -43,3 +45,28 @@ it("opens two existing agent chats in separate stores and keeps each pane indepe
expect(within(right).getByTestId("chat-test").getAttribute("data-session")).toBe("society:test");
expect(within(left).getByTestId("chat-other").getAttribute("data-session")).toBe("society:other");
});
+
+it("shows an explicit ungroup confirmation and restores individual chats on confirmation", async () => {
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ const onDeleted = vi.fn();
+ const scout = { agentId: "scout", name: "Scout", tier: "specialist", chatSessionId: "society:scout" } as SocietyAgent;
+ const writer = { agentId: "writer", name: "Writer", tier: "specialist", chatSessionId: "society:writer" } as SocietyAgent;
+ render(<QueryClientProvider client={client}><ChatGroupPanel
+ group={{ group_id: "team", name: "Team", members: ["scout", "writer"], created_ms: 1, updated_ms: 1 }}
+ groups={[]} roster={[scout, writer]} onOpenAgent={() => undefined} onOpenGroup={() => undefined}
+ onCreateAgent={() => undefined} onDeleted={onDeleted}
+ onGroupAgents={() => undefined} onAddAgentToGroup={() => undefined}
+ /></QueryClientProvider>);
+
+ fireEvent.click(screen.getByRole("button", { name: "society.groups.delete" }));
+ expect(groupApi.remove).not.toHaveBeenCalled();
+ const confirmation = screen.getByRole("alertdialog", { name: "society.groups.delete" });
+ expect(within(confirmation).getByText("society.groups.delete_confirm")).toBeTruthy();
+ fireEvent.click(within(confirmation).getByRole("button", { name: "society.groups.cancel" }));
+ expect(screen.queryByRole("alertdialog")).toBeNull();
+
+ fireEvent.click(screen.getByRole("button", { name: "society.groups.delete" }));
+ fireEvent.click(within(screen.getByRole("alertdialog")).getByRole("button", { name: "society.groups.delete" }));
+ await waitFor(() => expect(groupApi.remove).toHaveBeenCalledWith("team"));
+ await waitFor(() => expect(onDeleted).toHaveBeenCalledOnce());
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.tsx
index 05bd100e63..ccb5196abe 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatGroupPanel.tsx
@@ -31,6 +31,8 @@ export function ChatGroupPanel({
const [leftId, setLeftId] = useState(group.members[0] ?? "");
const [rightId, setRightId] = useState(group.members[1] ?? "");
const [editing, setEditing] = useState(false);
+ const [confirmUngroup, setConfirmUngroup] = useState(false);
+ const [removing, setRemoving] = useState(false);
const [error, setError] = useState("");
const leftStore = useMemo(() => createAgentChatStore("society", `group:${group.group_id}:left`), [group.group_id]);
const rightStore = useMemo(() => createAgentChatStore("society", `group:${group.group_id}:right`), [group.group_id]);
@@ -48,7 +50,7 @@ export function ChatGroupPanel({
?? members.find((agent) => agent.agentId !== left?.agentId);
const remove = async () => {
- if (!window.confirm(t("society.groups.delete_confirm"))) return;
+ setRemoving(true);
setError("");
try {
await deleteSocietyChatGroup(group.group_id);
@@ -56,6 +58,7 @@ export function ChatGroupPanel({
onDeleted();
} catch (cause) {
setError(cause instanceof Error ? cause.message : String(cause));
+ setRemoving(false);
}
};
@@ -102,9 +105,25 @@ export function ChatGroupPanel({
</div>
<button type="button" onClick={() => setEditing(true)} aria-label={t("society.groups.edit")}
className="rounded-md p-2 text-muted-foreground hover:bg-secondary hover:text-foreground"><Pencil className="h-4 w-4" /></button>
- <button type="button" onClick={() => void remove()} aria-label={t("society.groups.delete")}
- className="rounded-md p-2 text-muted-foreground hover:bg-destructive/10 hover:text-destructive"><Trash2 className="h-4 w-4" /></button>
+ <button type="button" onClick={() => setConfirmUngroup(true)}
+ className="inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-muted-foreground hover:bg-destructive/10 hover:text-destructive">
+ <Trash2 className="h-4 w-4" aria-hidden />{t("society.groups.delete")}
+ </button>
</header>
+ {confirmUngroup && <div role="alertdialog" aria-label={t("society.groups.delete")}
+ className="flex flex-wrap items-center justify-between gap-3 border-b border-border bg-secondary/50 px-5 py-3 text-sm text-foreground">
+ <p>{t("society.groups.delete_confirm")}</p>
+ <div className="flex gap-2">
+ <button type="button" onClick={() => setConfirmUngroup(false)} disabled={removing}
+ className="rounded-md px-3 py-1.5 text-muted-foreground hover:bg-secondary hover:text-foreground">
+ {t("society.groups.cancel")}
+ </button>
+ <button type="button" onClick={() => void remove()} disabled={removing}
+ className="rounded-md bg-destructive px-3 py-1.5 font-medium text-destructive-foreground disabled:opacity-50">
+ {t("society.groups.delete")}
+ </button>
+ </div>
+ </div>}
{error && <p role="alert" className="px-5 py-1 text-sm text-destructive">{error}</p>}
<div className="grid min-h-0 flex-1 grid-cols-2 divide-x divide-border" data-testid="society-group-split">
{pane("left", left)}