Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(layout): withdraw working-agent footer entry (MUL-9107) (#10433)
Bohan Jiang686f1e5c6dc3
diff --git a/packages/views/layout/bottom-bar.test.tsx b/packages/views/layout/bottom-bar.test.tsxindex d31d148d8d..1690e8085c 100644--- a/packages/views/layout/bottom-bar.test.tsx+++ b/packages/views/layout/bottom-bar.test.tsx@@ -1,15 +1,13 @@-import { screen, within } from "@testing-library/react";-import userEvent from "@testing-library/user-event";-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { screen } from "@testing-library/react";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; name: string; avatar_url: string | null }[];+ working: { id: string }[];stuck: { id: string }[];- byAgent: Map<string, { queuedCount: number; runningCount?: number }>;+ byAgent: Map<string, { queuedCount: number }>;}const h = vi.hoisted(() => ({@@ -17,18 +15,8 @@ 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),@@ -55,28 +43,17 @@ function renderBar(pathname = "/acme/issues") {getShareableUrl: (path) => path,};return renderWithI18n(- <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>- <NavigationProvider value={adapter}>- <AppBottomBar />- </NavigationProvider>- </QueryClientProvider>,+ <NavigationProvider value={adapter}>+ <AppBottomBar />+ </NavigationProvider>,);}-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", () => {@@ -88,60 +65,13 @@ describe("AppBottomBar", () => {expect(screen.queryByRole("link")).not.toBeInTheDocument();});- it("counts the agents that are working and links to the team", () => {- workingAgents(4);- renderBar();-- const link = screen.getByRole("link", { name: "4 agents working" });- expect(link).toHaveAttribute("href", "/acme/agents");- 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" },- ]);+ it("keeps quick chat without a working-agent entry when agents are running", () => {+ h.team.working = [{ id: "a1" }, { id: "a2" }, { id: "a3" }, { id: "a4" }];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");+ expect(screen.queryByText("4 agents working")).not.toBeInTheDocument();+ expect(screen.queryByRole("link")).not.toBeInTheDocument();+ expect(screen.getByTestId("chat-bar")).toBeInTheDocument();});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.tsxindex cad88dcbce..335f032fd4 100644--- a/packages/views/layout/bottom-bar.tsx+++ b/packages/views/layout/bottom-bar.tsx@@ -1,126 +1,26 @@"use client";-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 { TriangleAlert } from "@multica/ui/icons";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 { 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_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- * that cannot start because its runtime is offline. Both lead to Team, which- * names the agents. Renders nothing while the team is idle.+ * Work that cannot start because its runtime is offline. Links to Team,+ * which names the agents. Keeps the left slot occupied when there is no alert+ * so quick chat stays on the right.*/function TeamStatus({ wsId }: { wsId: string }) {const { t } = useT("layout");const p = useWorkspacePaths();const shell = useAppShell();- const { working, stuck, byAgent } = useTeamAgentStatus(wsId);+ const { stuck, byAgent } = useTeamAgentStatus(wsId);const teamHref = shell?.spaceHref("team", p.agents()) ?? p.agents();const waitingTasks = stuck.reduce((total, agent) => total + (byAgent.get(agent.id)?.queuedCount ?? 0),@@ -129,21 +29,6 @@ function TeamStatus({ wsId }: { wsId: string }) {return (<div className="flex min-w-0 items-center gap-1">- {working.length > 0 && (- <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 && (<AppLinkhref={teamHref}@@ -183,7 +68,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-6 md:flex"+ className="hidden h-8 shrink-0 items-center justify-between gap-4 pr-[18px] pl-3 md:flex"><TeamStatus wsId={wsId} />{showChat && <ChatBar />}