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.

fix(society): hide applied identity notices in agent chats (#477)

Ruben Lütke771637b357ad
diff --git a/jarvis/ui/web/frontend/src/components/society/README.md b/jarvis/ui/web/frontend/src/components/society/README.md
index afd746d82c..3db391ab52 100644
--- a/jarvis/ui/web/frontend/src/components/society/README.md
+++ b/jarvis/ui/web/frontend/src/components/society/README.md
@@ -3,8 +3,8 @@
The Jarvis Agents section. Agents v2 (MASTERPLAN §2.10): one click creates an
agent (`data.ts` `useQuickCreateAgent`) and opens its one endless chat
(`chat/AgentChatPanel.tsx`); delegations, waiting messages and routine runs
-render as folded cards there (`chat/ChatActivity.tsx`), and an agent's
-self-chosen identity offers Undo (`IdentityNotice`).
+render as folded cards there (`chat/ChatActivity.tsx`). Applied identity
+changes update the profile without adding a notice to the chat.
Folders, as planned in `docs/agent-society/MASTERPLAN.md` (§4, §9):
@@ -17,8 +17,7 @@ Folders, as planned in `docs/agent-society/MASTERPLAN.md` (§4, §9):
- `feed/` — society message feed and bounded room transcripts.
Branding: the world viewport carries its OWN bright video-game art direction (MASTERPLAN §4.3) —
-never Ink & Paper monochrome and never the Cursor-derived design doc; only the app chrome around
-the viewport uses the app's theme tokens.
+only the app chrome around the viewport uses the app's theme tokens.
Binding frontend rules: every canvas mounts through `useWebglSurface` (AP-32 context-loss
recovery + context budget); rAF pauses via IntersectionObserver, never `document.hidden`; the whole
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
index 343daaf2ee..41bf51a1de 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
@@ -73,9 +73,7 @@ import { offeredModels, useSavedHiddenModels } from "@/lib/agentProviderPrefs";
import { AgentSwatch } from "../AgentSwatch";
import {
useResolveProposal,
- useRestoreIdentity,
useSocietyCapabilities,
- type PreviousIdentity,
type SocietyAgent,
} from "../data";
import { fetchIdeAgents, type AgentStatus } from "@/lib/agenticIdeApi";
@@ -685,8 +683,14 @@ export function Transcript({
const sessionId = useAgentChat((state) => state.activeSessionId);
// Memory receipts are drawn inside the turn they follow, above its reply.
// A coding thread's unchanged status is one row, however often it arrived.
+ // Applied identity changes stay in history without chat rows or timestamps.
const { items, memoryByTurn } = useMemo(
- () => foldMemoryNotices(foldRepeatedThreadStatus(rawItems)),
+ () => foldMemoryNotices(foldRepeatedThreadStatus(rawItems.filter((item) => !(
+ item.type === "notice" && item.data.proposal_kind === "identity" && (
+ item.kind === "proposal" && item.resolved === "applied"
+ || item.kind === "proposal_resolved" && (!item.status || item.status === "applied")
+ )
+ )))),
[rawItems],
);
// Follow the newest while the view sits at the end — the rule every
@@ -769,9 +773,6 @@ function TimeStamp({ ms }: { ms: number }) {
function NoticeLine({ item }: { item: NoticeItem }) {
const t = useT();
if (item.kind === "memory_updated") return <MemoryUpdateNotice item={item} />;
- if (item.kind === "proposal_resolved" && item.data.proposal_kind === "identity") {
- return <IdentityNotice item={item} />;
- }
if (item.kind === "message_queued") {
return <p className="self-end py-1 text-xs text-muted-foreground" data-testid="message-queued">
{t("society.chat.message_waiting")} · {item.text}
@@ -818,76 +819,6 @@ function NoticeLine({ item }: { item: NoticeItem }) {
);
}
-function previousIdentity(data: Record<string, unknown>): PreviousIdentity | null {
- const raw = data.previous;
- if (!raw || typeof raw !== "object") return null;
- const value = raw as Record<string, unknown>;
- if (typeof value.name !== "string" || !value.name) return null;
- return {
- name: value.name,
- title: typeof value.title === "string" ? value.title : "",
- description: typeof value.description === "string" ? value.description : "",
- focus: Array.isArray(value.focus) ? value.focus.map(String) : [],
- ...(value.approval_rules && typeof value.approval_rules === "object"
- ? { approval_rules: rulesOf(value.approval_rules as Record<string, unknown>) }
- : {}),
- };
-}
-
-function rulesOf(raw: Record<string, unknown>): { require_approval: string[]; always_allow: string[] } {
- const list = (v: unknown) => (Array.isArray(v) ? v.map(String) : []);
- return { require_approval: list(raw.require_approval), always_allow: list(raw.always_allow) };
-}
-
-/**
- * The agent took a name and role from the conversation. A fresh agent does
- * this without asking first, so the line offers the way back: Undo restores
- * the name, title, description and focus it had before.
- */
-export function IdentityNotice({ item }: { item: NoticeItem }) {
- const t = useT();
- const restore = useRestoreIdentity();
- const previous = previousIdentity(item.data);
- const [state, setState] = useState<"idle" | "busy" | "undone">("idle");
- const [error, setError] = useState("");
- const agentId = item.agentId || String(item.data.agent_id ?? "");
- const outcome = item.text.split("\n").pop() ?? "";
- const undo = async () => {
- if (!previous || !agentId) return;
- setState("busy");
- setError("");
- try {
- await restore(agentId, previous);
- setState("undone");
- } catch (err) {
- setState("idle");
- setError(err instanceof Error ? err.message : String(err));
- }
- };
- const label =
- state === "undone" && previous
- ? t("society.chat.identity_undone").replace("{0}", previous.name)
- : t("society.chat.identity_now").replace("{0}", item.agentName || outcome);
- return (
- <div className="flex flex-wrap items-center gap-2 self-start py-1 text-xs text-muted-foreground" data-testid="identity-notice">
- <span className="font-medium text-foreground">{label}</span>
- {state !== "undone" && outcome ? <span>{outcome}</span> : null}
- {previous && agentId && state !== "undone" ? (
- <button
- type="button"
- disabled={state === "busy"}
- onClick={() => void undo()}
- className="inline-flex items-center gap-1 rounded-md border border-border px-2 py-0.5 font-medium text-foreground hover:bg-muted disabled:opacity-50"
- >
- <RotateCcw size={12} aria-hidden />
- {t("society.chat.identity_undo")}
- </button>
- ) : null}
- {error ? <span className="text-destructive">{error}</span> : null}
- </div>
- );
-}
-
/** One human-readable line per proposal kind, read off the typed payload. */
function proposalDetail(kind: string, payload: Record<string, unknown>): string {
const list = (v: unknown): string => (Array.isArray(v) ? v.map(String).join(", ") : "");
@@ -968,7 +899,6 @@ function ProposalCard({ item }: { item: NoticeItem }) {
: item.resolved
? t("society.chat.proposal_failed")
: "";
- if (item.resolved === "applied" && kind === "identity") return <IdentityNotice item={item} />;
if (item.resolved && item.resolved !== "failed") return <ChatActivity
label={<>{resolvedLabel} · {kind ? t(`society.chat.proposal_kind_${kind}`) : ""} · {summary}</>}>
<p className="whitespace-pre-wrap">{detail || summary}</p>
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/IdentityNotice.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/IdentityNotice.test.tsx
index d78afc9c04..6f40613822 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/IdentityNotice.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/IdentityNotice.test.tsx
@@ -1,37 +1,55 @@
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
import type { NoticeItem } from "@/components/agentchat/reduce";
-import { IdentityNotice } from "./AgentChatPanel";
+import type { SocietyAgent } from "../data";
+import { Transcript } from "./AgentChatPanel";
-const restore = vi.hoisted(() => ({ fn: vi.fn(async () => undefined) }));
vi.mock("@/i18n", () => ({ useT: () => (key: string) => key, fill: (text: string) => text }));
vi.mock("../data", async (original) => ({
...(await original<typeof import("../data")>()),
- useRestoreIdentity: () => restore.fn,
+ useResolveProposal: () => async () => undefined,
}));
-afterEach(() => { cleanup(); restore.fn.mockClear(); });
+afterEach(cleanup);
-const previous = { name: "Nova", title: "", description: "", focus: [] };
+const agent = { agentId: "agent-1a2b3c4d", name: "Mail Desk", tier: "worker" } as unknown as SocietyAgent;
-function notice(extra: Record<string, unknown> = {}): NoticeItem {
+function notice(overrides: Partial<NoticeItem> = {}): NoticeItem {
return {
type: "notice", id: "n1", kind: "proposal_resolved", text: "I am now Mail Desk - Gmail assistant.",
- agentName: "Mail Desk", agentId: "agent-1a2b3c4d", status: "applied", tsMs: 1, resolved: "",
- data: { proposal_kind: "identity", status: "applied", previous, ...extra },
+ agentName: agent.name, agentId: agent.agentId, status: "applied", tsMs: 1, resolved: "",
+ data: { proposal_kind: "identity", status: "applied", previous: { name: "Nova" } },
+ ...overrides,
};
}
-it("shows the new identity and undoes it back to the placeholder", async () => {
- render(<IdentityNotice item={notice()} />);
- expect(screen.getByText("society.chat.identity_now")).toBeTruthy();
- fireEvent.click(screen.getByRole("button", { name: "society.chat.identity_undo" }));
- await waitFor(() => expect(restore.fn).toHaveBeenCalledWith("agent-1a2b3c4d", previous));
- expect(await screen.findByText("society.chat.identity_undone")).toBeTruthy();
- expect(screen.queryByRole("button", { name: "society.chat.identity_undo" })).toBeNull();
+it.each([
+ {},
+ { status: "" },
+ { kind: "proposal", resolved: "applied" },
+])("hides applied identity receipts without leaving timeline rows: %j", (overrides) => {
+ const { container } = render(<Transcript items={[notice(overrides)]} agent={agent} roster={[]} onDecide={async () => {}} />);
+ expect(screen.queryByTestId("identity-notice")).toBeNull();
+ expect(screen.queryByText(/I am now/)).toBeNull();
+ expect(container.querySelector("[data-chat-item]")).toBeNull();
+ expect(screen.getByText("society.chat.empty_title")).toBeTruthy();
});
-it("offers no undo when the card carries nothing to restore", () => {
- render(<IdentityNotice item={notice({ previous: undefined })} />);
- expect(screen.queryByRole("button")).toBeNull();
+it("keeps an identity proposal visible while it needs approval, then removes its resolved row", () => {
+ const pending = notice({ kind: "proposal", status: "", resolved: "" });
+ const { container, rerender } = render(<Transcript items={[pending]} agent={agent} roster={[]} onDecide={async () => {}} />);
+ expect(screen.getByText("society.chat.proposal_title")).toBeTruthy();
+ expect(container.querySelector('[data-chat-item="n1"]')).not.toBeNull();
+ rerender(<Transcript items={[{ ...pending, resolved: "applied" }]} agent={agent} roster={[]} onDecide={async () => {}} />);
+ expect(container.querySelector('[data-chat-item="n1"]')).toBeNull();
+});
+
+it("preserves identity failures and other proposal results", () => {
+ const items = [
+ notice({ id: "failed", status: "failed", text: "Could not change the name." }),
+ notice({ id: "rule", data: { proposal_kind: "rule" }, text: "Rule saved." }),
+ ];
+ const { container } = render(<Transcript items={items} agent={agent} roster={[]} onDecide={async () => {}} />);
+ expect(container.querySelector('[data-chat-item="failed"]')).not.toBeNull();
+ expect(container.querySelector('[data-chat-item="rule"]')).not.toBeNull();
});