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.

7.3 KB
Raw Blame
import seedCatalog from "../../../../../../marketplace/seed_catalog.json";
import { afterEach, describe, expect, it } from "vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { toolIdentity } from "./toolIdentity";
import { ToolChoiceChips, ToolChoiceIcon } from "./ToolChoiceChips";
import type { ToolChoice } from "./toolChoices";
import { EMPTY_TIMELINE, reduceEvents } from "./reduce";
import { AgentTimeline } from "./AgentTimeline";

const row = (over: Partial<ToolChoice> = {}): ToolChoice => ({
  id: "plugin:gmail",
  label: "Gmail",
  category: "plugins",
  group: "Gmail",
  brand: "gmail",
  description: "Read your inbox",
  available: true,
  tool_names: ["gmail"],
  skill: "",
  ...over,
});
afterEach(cleanup);

describe("tool visual identities", () => {
  it.each([
    ["mcp:github-mcp", "mcp", "github"],
    ["tool:mcp__github__search", "mcp", "github"],
    ["skill:google-workspace:gws-gmail-read", "skills", "gmail"],
    ["skill:google-drive:sheets", "skills", "google_drive"],
    ["tool:cli_gh", "cli", "github"],
    ["tool:cli_codex", "cli", "openai"],
    ["cli:kubectl", "cli", "kubernetes"],
    ["cli:gcloud", "cli", "google-cloud"],
    ["cli:az", "cli", "azure"],
    ["skill:figma:design", "skills", "figma"],
    ["mcp:postgres-server", "mcp", "postgresql"],
  ])("resolves %s to the original %s identity", (id, category, brand) => {
    const identity = toolIdentity(
      row({ id, category: category as ToolChoice["category"], brand: "", group: "", label: "" }),
    );
    expect(identity.key).toBe(brand);
    expect(identity.logo).toBeTruthy();
  });

  it("uses original artwork for every raster and hyphenated catalog brand", () => {
    const cloud = toolIdentity(row({ id: "plugin:google_cloud", brand: "google_cloud", label: "Google Cloud" }));
    expect(cloud.logo).toBeTruthy();
    expect(cloud.mark).toBe("colour");
    const hyphen = toolIdentity(row({ id: "plugin:google-cloud", brand: "google-cloud", label: "Google Cloud" }));
    expect(hyphen.logo).toBeTruthy();
    const flare = toolIdentity(row({ id: "plugin:cloudflare", brand: "cloudflare", label: "Cloudflare" }));
    expect(flare.logo).toBeTruthy();
    expect(flare.mark).toBe("colour");
    const gitlab = toolIdentity(row({ id: "plugin:gitlab", brand: "gitlab", label: "GitLab" }));
    expect(gitlab.mark).toBe("colour");
    const figma = toolIdentity(row({ id: "plugin:figma", brand: "figma", label: "Figma" }));
    expect(figma.mark).toBe("colour");
  });

  it("uses the bundled PNG for AgentMail and the AMD arrow for GPU status", () => {
    const mail = toolIdentity(row({ id: "plugin:agentmail", brand: "agentmail", label: "AgentMail" }));
    expect(mail.key).toBe("agentmail");
    expect(mail.logo).toMatch(/agentmail/);
    expect(mail.logo).not.toMatch(/^https?:/);
    const amd = toolIdentity(row({ id: "plugin:amd_gpu", brand: "amd_gpu", label: "AMD GPU Status" }));
    expect(amd.key).toBe("amd_gpu");
    expect(amd.logo).toBeTruthy();
    expect(amd.logo).toMatch(/389\.9|amd_gpu/);
    expect(amd.mark).toBe("mono");
  });

  it.each(["cursor", "deepseek", "kimi", "opencode", "zai"])(
    "draws the %s agent glyph from the ledgered folder as a neutral mask",
    (brand) => {
      const identity = toolIdentity(row({ id: `cli:${brand}`, brand, label: brand, category: "cli" }));
      expect(identity.key).toBe(brand);
      expect(identity.logo).toBeTruthy();
      expect(identity.logo).not.toMatch(/agent-logos|provider-logos/);
      expect(identity.mark).toBe("mono");
    },
  );

  it("has a local mark for every shipped marketplace connector", () => {
    for (const plugin of seedCatalog.plugins) {
      const identity = toolIdentity(
        row({
          id: `plugin:${plugin.id}`,
          brand: plugin.id,
          label: plugin.display_name,
          group: plugin.display_name,
        }),
      );
      expect(identity.logo, plugin.id).toBeTruthy();
      expect(identity.key?.replace(/-/g, "_"), plugin.id).toBe(plugin.id);
      expect(identity.logo).not.toMatch(/^https?:/);
    }
  });

  it.each(["my-github-helper", "drive-dodaios-cli", "daily-brief"])(
    "does not invent a brand for %s",
    (id) => {
      const identity = toolIdentity(
        row({
          id: `skill:${id}`,
          label: id,
          brand: "",
          group: "skills",
          description: "Work with Gmail and GitHub",
        }),
      );
      expect(identity.logo).toBeUndefined();
      expect(identity.Glyph).toBeTruthy();
    },
  );

  it("uses the Artifacts section mark for the artifact pin", async () => {
    const artifact = toolIdentity(
      row({
        id: "tool:create_artifact",
        label: "Artifact / Artefakt",
        brand: "artifact",
        group: "Artifact",
        category: "system",
      }),
    );
    expect(artifact.key).toBe("artifact");
    expect(artifact.logo).toBeUndefined();
    const { Shapes } = await import("lucide-react");
    expect(artifact.Glyph).toBe(Shapes);
  });

  it("uses distinct glyphs for unbranded documents and memory", () => {
    const pdf = toolIdentity(
      row({ id: "skill:pdf", label: "PDF", brand: "", group: "skills", category: "skills" }),
    );
    const memory = toolIdentity(
      row({
        id: "tool:wiki-recall",
        label: "Recall",
        brand: "",
        group: "memory",
        category: "memory",
      }),
    );
    expect(pdf.Glyph).not.toBe(memory.Glyph);
  });

  it("preserves brand identity in a reloaded user message below the text", () => {
    const saved = JSON.parse(JSON.stringify(row()));
    const { items } = reduceEvents(EMPTY_TIMELINE, [
      {
        seq: 1,
        ts_ms: 1000,
        kind: "user_message",
        payload: { text: "Find that email", tool_choices: [saved] },
      },
    ]);
    render(
      <AgentTimeline
        items={items}
        assistantName="Jarvis"
        providerLabel={(s) => s}
        onDecide={() => {}}
      />,
    );
    const chips = screen.getByTestId("tool-choice-chips");
    expect(chips.dataset.editable).toBe("false");
    expect(chips.querySelector('[data-brand="gmail"]')).not.toBeNull();
    expect(chips.textContent).toContain("Find that email");
    expect(chips.querySelector("button")).toBeNull();
  });

  it("uses the same ink for composer and sent tags, with removal only in the composer", () => {
    const items = [row(), row({ id: "plugin:github", brand: "github", label: "GitHub" })];
    const removed: string[] = [];
    const { container } = render(
      <>
        <ToolChoiceChips items={items} onRemove={(id) => removed.push(id)} />
        <ToolChoiceChips items={items} />
      </>,
    );
    const gmail = container.querySelectorAll<HTMLElement>('[data-brand="gmail"]');
    expect(gmail[0].style.cssText).toBe(gmail[1].style.cssText);
    expect(gmail[0].style.getPropertyValue("--tool-ink-light")).toBe("#b3261e");
    const github = container.querySelectorAll<HTMLElement>('[data-brand="github"]');
    expect(github[0].querySelector(".tool-choice-mask")).not.toBeNull();
    fireEvent.click(gmail[0].querySelector("button")!);
    expect(removed).toEqual(["plugin:gmail"]);
  });

  it("falls back to a meaningful symbol when a colour logo fails", () => {
    const { container } = render(<ToolChoiceIcon row={row()} />);
    fireEvent.error(container.querySelector("img")!);
    expect(container.querySelector("img")).toBeNull();
    expect(container.querySelector("svg")).not.toBeNull();
  });
});