Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(layout): simplify bottom bar activity status (MUL-9107) (#10425)

Bohan Jiang854f82de63a4
diff --git a/packages/views/layout/bottom-bar.test.tsx b/packages/views/layout/bottom-bar.test.tsx
index 48e8d5459d..d31d148d8d 100644
--- a/packages/views/layout/bottom-bar.test.tsx
+++ b/packages/views/layout/bottom-bar.test.tsx
@@ -1,13 +1,15 @@
-import { screen } from "@testing-library/react";
+import { screen, within } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { NavigationProvider, type NavigationAdapter } from "../navigation";
import { renderWithI18n } from "../test/i18n";
import { AppBottomBar } from "./bottom-bar";
interface TeamStatus {
- working: { id: string }[];
+ working: { id: string; name: string; avatar_url: string | null }[];
stuck: { id: string }[];
- byAgent: Map<string, { queuedCount: number }>;
+ byAgent: Map<string, { queuedCount: number; runningCount?: number }>;
}
const h = vi.hoisted(() => ({
@@ -15,8 +17,18 @@ const h = vi.hoisted(() => ({
isMobile: false,
workspace: { id: "ws-test" } as { id: string } | null,
team: { working: [], stuck: [], byAgent: new Map() } as TeamStatus,
+ snapshot: vi.fn(),
+ getIssue: vi.fn(),
}));
+vi.mock("@multica/core/api", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@multica/core/api")>();
+ return {
+ ...actual,
+ api: { ...actual.api, getBaseUrl: () => "http://localhost:8080", getAgentTaskSnapshot: h.snapshot, getIssue: h.getIssue },
+ };
+});
+
vi.mock("@multica/core/chat", () => ({
useChatStore: Object.assign(
(selector: (state: typeof h.chat) => unknown) => selector(h.chat),
@@ -31,9 +43,6 @@ vi.mock("@multica/ui/hooks/use-mobile", () => ({ useIsMobile: () => h.isMobile }
vi.mock("./panels/team-status", () => ({ useTeamAgentStatus: () => h.team }));
vi.mock("./app-shell-context", () => ({ useAppShell: () => null }));
vi.mock("../chat/components/chat-bar", () => ({ ChatBar: () => <div data-testid="chat-bar" /> }));
-vi.mock("../common/actor-avatar", () => ({
- ActorAvatar: ({ actorId }: { actorId: string }) => <span data-testid={`avatar-${actorId}`} />,
-}));
function renderBar(pathname = "/acme/issues") {
const adapter: NavigationAdapter = {
@@ -46,17 +55,28 @@ function renderBar(pathname = "/acme/issues") {
getShareableUrl: (path) => path,
};
return renderWithI18n(
- <NavigationProvider value={adapter}>
- <AppBottomBar />
- </NavigationProvider>,
+ <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
+ <NavigationProvider value={adapter}>
+ <AppBottomBar />
+ </NavigationProvider>
+ </QueryClientProvider>,
);
}
+function workingAgents(count: number) {
+ h.team.working = Array.from({ length: count }, (_, i) => ({
+ id: `a${i + 1}`, name: `Agent ${i + 1}`, avatar_url: null,
+ }));
+ h.team.byAgent = new Map(h.team.working.map((agent) => [agent.id, { runningCount: 1, queuedCount: 0 }]));
+}
+
beforeEach(() => {
h.chat.floatingChatEnabled = true;
h.isMobile = false;
h.workspace = { id: "ws-test" };
h.team = { working: [], stuck: [], byAgent: new Map() };
+ h.snapshot.mockReset().mockResolvedValue([]);
+ h.getIssue.mockReset().mockResolvedValue({ title: "Review the activity overview" });
});
describe("AppBottomBar", () => {
@@ -69,13 +89,59 @@ describe("AppBottomBar", () => {
});
it("counts the agents that are working and links to the team", () => {
- h.team.working = [{ id: "a1" }, { id: "a2" }, { id: "a3" }, { id: "a4" }];
+ workingAgents(4);
renderBar();
const link = screen.getByRole("link", { name: "4 agents working" });
expect(link).toHaveAttribute("href", "/acme/agents");
- // The avatar stack is capped; the count carries the rest.
- expect(screen.getAllByTestId(/^avatar-/)).toHaveLength(3);
+ expect(link.querySelector("[data-slot='avatar']")).not.toBeInTheDocument();
+ expect(screen.queryByText("Agent 1")).not.toBeInTheDocument();
+ expect(h.snapshot).not.toHaveBeenCalled();
+ });
+
+ it("previews members and their running issue on hover without showing completed work", async () => {
+ const user = userEvent.setup();
+ workingAgents(2);
+ h.snapshot.mockResolvedValue([
+ { id: "old", agent_id: "a1", status: "completed", issue_id: "old-issue" },
+ { id: "queued", agent_id: "a1", status: "queued", issue_id: "queued-issue" },
+ { id: "live", agent_id: "a1", status: "running", issue_id: "live-issue" },
+ { id: "chat", agent_id: "a2", status: "running", issue_id: "", chat_session_id: "chat-1" },
+ ]);
+ renderBar();
+ await user.hover(screen.getByRole("link", { name: "2 agents working" }));
+
+ expect(await screen.findByText("Agent 1")).toBeInTheDocument();
+ expect(screen.getByText("Agent 2")).toBeInTheDocument();
+ expect(await screen.findByText("Review the activity overview")).toBeInTheDocument();
+ expect(screen.getByText("1 task running")).toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "Team" })).toHaveAttribute("href", "/acme/agents");
+ expect(h.getIssue.mock.calls).toEqual([["live-issue"]]);
+ });
+
+ it("opens the member preview on keyboard focus and keeps the trigger navigable", async () => {
+ const user = userEvent.setup();
+ workingAgents(1);
+ renderBar();
+ const trigger = screen.getByRole("link", { name: "1 agent working" });
+
+ await user.tab();
+ expect(trigger).toHaveFocus();
+ expect(await screen.findByText("Agent 1")).toBeInTheDocument();
+ await user.tab();
+ expect(screen.getByRole("link", { name: "Team" })).toHaveFocus();
+ expect(within(trigger).queryByText("Agent 1")).not.toBeInTheDocument();
+ });
+
+ it("limits the preview to five members and links to the rest", async () => {
+ const user = userEvent.setup();
+ workingAgents(7);
+ renderBar();
+ await user.hover(screen.getByRole("link", { name: "7 agents working" }));
+
+ expect(await screen.findByText("Agent 5")).toBeInTheDocument();
+ expect(screen.queryByText("Agent 6")).not.toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "Show 2 more…" })).toHaveAttribute("href", "/acme/agents");
});
it("adds up the tasks waiting on offline runtimes across agents", () => {
diff --git a/packages/views/layout/bottom-bar.tsx b/packages/views/layout/bottom-bar.tsx
index 87165f0270..cad88dcbce 100644
--- a/packages/views/layout/bottom-bar.tsx
+++ b/packages/views/layout/bottom-bar.tsx
@@ -1,19 +1,115 @@
"use client";
-import { TriangleAlert } from "@multica/ui/icons";
+import { useMemo } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { Activity, ArrowUpRight, TriangleAlert } from "@multica/ui/icons";
+import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";
+import { HoverCard, HoverCardContent, HoverCardTrigger } from "@multica/ui/components/ui/hover-card";
import { useChatStore } from "@multica/core/chat";
+import { agentTaskSnapshotOptions } from "@multica/core/agents/queries";
+import type { AgentPresenceDetail } from "@multica/core/agents";
+import { issueDetailOptions } from "@multica/core/issues/queries";
import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
+import type { Agent, AgentTask } from "@multica/core/types";
+import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";
import { useIsMobile } from "@multica/ui/hooks/use-mobile";
import { ChatBar } from "../chat/components/chat-bar";
import { isFloatingChatRouteSuppressed } from "../chat/floating-chat-visibility";
-import { ActorAvatar } from "../common/actor-avatar";
import { useT } from "../i18n";
import { AppLink, useNavigation } from "../navigation";
import { useAppShell } from "./app-shell-context";
import { BOTTOM_BAR_ITEM_CLASS } from "./bottom-bar-styles";
import { useTeamAgentStatus } from "./panels/team-status";
-const MAX_WORKING_AVATARS = 3;
+const MAX_PREVIEW_AGENTS = 5;
+const EMPTY_TASKS: AgentTask[] = [];
+
+function WorkingAgentPreview({
+ wsId,
+ agent,
+ task,
+ runningCount,
+}: {
+ wsId: string;
+ agent: Agent;
+ task: AgentTask | undefined;
+ runningCount: number;
+}) {
+ const { t } = useT("layout");
+ const issueId = task?.issue_id ?? "";
+ const { data: issue } = useQuery({
+ ...issueDetailOptions(wsId, issueId),
+ enabled: !!issueId,
+ });
+
+ return (
+ <div className="flex min-w-0 items-center gap-2 text-caption">
+ <ActorAvatar
+ name={agent.name}
+ initials={agent.name.charAt(0).toUpperCase()}
+ avatarUrl={resolvePublicFileUrl(agent.avatar_url)}
+ isAgent
+ size="md"
+ />
+ <div className="min-w-0 flex-1">
+ <div className="truncate font-medium">{agent.name}</div>
+ <div className="truncate text-muted-foreground">
+ {issue?.title ?? t(($) => $.panels.team.running_tasks, { count: runningCount })}
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function WorkingAgentsPreview({
+ wsId,
+ working,
+ byAgent,
+ teamHref,
+}: {
+ wsId: string;
+ working: Agent[];
+ byAgent: Map<string, AgentPresenceDetail>;
+ teamHref: string;
+}) {
+ const { t } = useT("layout");
+ const { data: tasks = EMPTY_TASKS } = useQuery(agentTaskSnapshotOptions(wsId));
+ const runningByAgent = useMemo(() => {
+ const result = new Map<string, AgentTask>();
+ for (const task of tasks) {
+ if (task.status === "running" && task.issue_id && !result.has(task.agent_id)) {
+ result.set(task.agent_id, task);
+ }
+ }
+ return result;
+ }, [tasks]);
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="text-caption font-medium text-muted-foreground">
+ {t(($) => $.bottom_bar.working, { count: working.length })}
+ </div>
+ {working.slice(0, MAX_PREVIEW_AGENTS).map((agent) => (
+ <WorkingAgentPreview
+ key={agent.id}
+ wsId={wsId}
+ agent={agent}
+ task={runningByAgent.get(agent.id)}
+ runningCount={byAgent.get(agent.id)?.runningCount ?? 0}
+ />
+ ))}
+ <AppLink
+ href={teamHref}
+ className="flex items-center gap-1.5 border-t border-surface-border pt-2.5 text-caption text-muted-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
+ >
+ {working.length > MAX_PREVIEW_AGENTS
+ ? t(($) => $.panels.team.show_more_agents, { count: working.length - MAX_PREVIEW_AGENTS })
+ : t(($) => $.spaces.team)}
+ <ArrowUpRight aria-hidden className="size-3.5" />
+ </AppLink>
+ </div>
+ );
+}
/**
* What the team is doing, at a glance: how many agents are working, and work
@@ -34,23 +130,19 @@ function TeamStatus({ wsId }: { wsId: string }) {
return (
<div className="flex min-w-0 items-center gap-1">
{working.length > 0 && (
- <AppLink href={teamHref} className={BOTTOM_BAR_ITEM_CLASS}>
- <span aria-hidden className="flex shrink-0 -space-x-1">
- {working.slice(0, MAX_WORKING_AVATARS).map((agent) => (
- <ActorAvatar
- key={agent.id}
- actorType="agent"
- actorId={agent.id}
- size="xs"
- profileLink={false}
- className="ring-[1.5px] ring-app-shell"
- />
- ))}
- </span>
- <span className="truncate">
- {t(($) => $.bottom_bar.working, { count: working.length })}
- </span>
- </AppLink>
+ <HoverCard>
+ <HoverCardTrigger
+ render={<AppLink href={teamHref} className={BOTTOM_BAR_ITEM_CLASS} />}
+ >
+ <Activity aria-hidden className="size-3.5 shrink-0" />
+ <span className="truncate">
+ {t(($) => $.bottom_bar.working, { count: working.length })}
+ </span>
+ </HoverCardTrigger>
+ <HoverCardContent side="top" align="start" sideOffset={8} className="w-80">
+ <WorkingAgentsPreview wsId={wsId} working={working} byAgent={byAgent} teamHref={teamHref} />
+ </HoverCardContent>
+ </HoverCard>
)}
{waitingTasks > 0 && (
<AppLink
@@ -91,7 +183,7 @@ export function AppBottomBar() {
data-mc="bottom-bar"
// pr: the card's mr-2 plus a gutter that puts the last icon on the same
// column as the page header's trailing action.
- className="hidden h-8 shrink-0 items-center justify-between gap-4 pr-[18px] pl-3 md:flex"
+ className="hidden h-8 shrink-0 items-center justify-between gap-4 pr-[18px] pl-6 md:flex"
>
<TeamStatus wsId={wsId} />
{showChat && <ChatBar />}