mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-12 19:06:06 +02:00
* refactor(ui): converge ActorAvatar size to semantic tiers (MUL-4277) Replace the free-form numeric `size` on ActorAvatar with a constrained `AvatarSize` union (xs/sm/md/lg/xl/2xl) so avatar dimensions are chosen by role instead of ad-hoc pixels. This eliminates the magic-number drift where the same role rendered at different sizes across pages. - Add `@multica/ui/lib/avatar-size` (AvatarSize union + AVATAR_SIZE_PX map + default tier). - Base `ActorAvatar` (packages/ui) and business `ActorAvatar`/`AgentStatusDot` (packages/views) now take `AvatarSize`; internal font/icon math and the presence-dot threshold read px from the map. - Migrate all web/desktop call sites (packages/ui + packages/views) from numeric sizes to tiers using the role table (12,14->xs 16,18,20->sm 22,24,28->md 30,32,34->lg 40,44->xl 56,64->2xl). - Token-ise the derived consumers `AgentAvatarStack` and `IssueAgentActivityIndicator` (px looked up internally for overlap/+N math). Out of scope (per plan): ui/avatar.tsx primitive, account-tab/AvatarPicker, mobile, and component-name disambiguation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * fix(ui): unify all avatars and the upload cropper to round (MUL-4277, MUL-4184) main's avatar-shape decision rendered non-human actors (agent, squad, system) and the workspace logo as rounded squares, and the upload cropper mirrored that with a square crop window. Per the updated decision (avatars_and_cropper_round_required), every avatar and the crop UI are now circular; the square path is removed rather than left as dead config. - Base ActorAvatar: always rounded-full (drop the isHuman/rounded-md split). - avatar-crop-dialog: remove the AvatarCropShape/square path; crop window is always cropShape="round". - avatar-upload-control: drop VARIANT_SHAPE; the control is always round and no longer threads a shape to the dialog (variant still drives the fallback). - Strip rounded-md/rounded-none square overrides from agent/squad/member ActorAvatar call sites; round the read-only agent/squad static wrappers. - WorkspaceAvatar: round the org logo so it matches the (now round) workspace upload/crop and the shared avatar shape. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * fix(ui): make round avatar shape a hard invariant (MUL-4277) Close the two remaining square squad-avatar paths flagged in review and prevent call sites from re-squaring the avatar: - base ActorAvatar: keep `rounded-full` as the last class in cn() so a call-site `className` can no longer override the circle. - SquadHeaderAvatar: drop `className="rounded"` (was overriding the base circle into a small rounded square). - SquadsPage no-avatar fallback: route through the shared ActorAvatarBase (`isSquad size="lg"`) instead of a hand-written rounded-md tile, so the fallback matches the image path — one shape source of truth. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * fix(views): round the agent/squad avatar loading skeletons (MUL-4277) The avatar placeholder skeletons on the agent/squad list, detail, and profile-card loading states were still rounded squares (rounded-md/lg) from the pre-round era, so the avatar visibly popped from square to circle on load — inconsistent with the round avatars and with the member/inbox/issue skeletons that already use rounded-full. Round all five: agents-page, agent-detail-page, squads-page, squad-detail-page, squad-profile-card. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
125 lines
4.7 KiB
TypeScript
125 lines
4.7 KiB
TypeScript
"use client";
|
|
|
|
import { memo, useMemo } from "react";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import {
|
|
HoverCard,
|
|
HoverCardTrigger,
|
|
HoverCardContent,
|
|
} from "@multica/ui/components/ui/hover-card";
|
|
import { useWorkspaceId } from "@multica/core/hooks";
|
|
import { agentTaskSnapshotOptions } from "@multica/core/agents";
|
|
import type { AgentTask } from "@multica/core/types";
|
|
import { cn } from "@multica/ui/lib/utils";
|
|
import type { AvatarSize } from "@multica/ui/lib/avatar-size";
|
|
import { AgentAvatarStack } from "../../agents/components/agent-avatar-stack";
|
|
import { AgentActivityHoverContent } from "../../agents/components/agent-activity-hover-content";
|
|
import { useT } from "../../i18n";
|
|
|
|
interface IssueAgentActivityIndicatorProps {
|
|
issueId: string;
|
|
// Avatar tier. Kept very small — this is a corner-of-card cue, not a
|
|
// primary control. Default xs (16 px) reads as a dot at typical board
|
|
// densities while still showing the agent's face on hover-zoom.
|
|
size?: AvatarSize;
|
|
}
|
|
|
|
/**
|
|
* Small "is there an agent working on this issue right now" badge shown
|
|
* in the top-right of board cards and right after the identifier in list
|
|
* rows. Derives state from the workspace-wide agent task snapshot:
|
|
*
|
|
* - has ≥1 running task → tiny avatar stack + shimmering "Working"
|
|
* - 0 running, ≥1 queued → half-opacity stack + muted "Queued"
|
|
* - nothing → return null (no chrome, no placeholder)
|
|
*
|
|
* The shimmer reuses chat's `animate-chat-text-shimmer` utility (defined
|
|
* in packages/ui/styles/base.css). Earlier iterations layered a brand
|
|
* ring + opacity pulse around the avatars; both read as nervous on a
|
|
* dense board. Moving the "alive" signal onto the label keeps the
|
|
* avatars themselves still and lets the cue ride a piece of text the
|
|
* user can already read.
|
|
*
|
|
* Hover opens AgentActivityHoverContent which lists every active task
|
|
* with status dot + duration. No link rows — the card itself is the
|
|
* navigation target for issue detail.
|
|
*
|
|
* Re-renders on every snapshot invalidation (WS task:* events drive it
|
|
* via use-realtime-sync). 30s staleTime is the offline fallback only.
|
|
*/
|
|
export const IssueAgentActivityIndicator = memo(function IssueAgentActivityIndicator({
|
|
issueId,
|
|
size = "xs",
|
|
}: IssueAgentActivityIndicatorProps) {
|
|
const { t } = useT("issues");
|
|
const wsId = useWorkspaceId();
|
|
const { data: snapshot = [] } = useQuery(agentTaskSnapshotOptions(wsId));
|
|
|
|
const { runningTasks, queuedTasks, agentIds, opacity } = useMemo(() => {
|
|
const running: AgentTask[] = [];
|
|
const queued: AgentTask[] = [];
|
|
for (const task of snapshot) {
|
|
if (task.issue_id !== issueId) continue;
|
|
if (task.status === "running") running.push(task);
|
|
else if (
|
|
task.status === "queued" ||
|
|
task.status === "dispatched" ||
|
|
// waiting_local_directory is the daemon-parked variant of "queued"
|
|
// — the agent is still actively waiting on a path lock, so it
|
|
// belongs in the active hover stack rather than dropping out.
|
|
task.status === "waiting_local_directory"
|
|
)
|
|
queued.push(task);
|
|
// Terminal statuses are intentionally ignored — they belong on the
|
|
// issue history, not the live indicator.
|
|
}
|
|
// Stack heads: prefer running. If 0 running, fall back to queued.
|
|
// Each case is visually distinct (running gets shimmer, queued gets
|
|
// muted text) so the indicator always offers a face to hover.
|
|
const primary = running.length > 0 ? running : queued;
|
|
const uniqueAgents = [...new Set(primary.map((t) => t.agent_id))];
|
|
return {
|
|
runningTasks: running,
|
|
queuedTasks: queued,
|
|
agentIds: uniqueAgents,
|
|
opacity: (running.length > 0 ? "full" : "half") as "full" | "half",
|
|
};
|
|
}, [snapshot, issueId]);
|
|
|
|
if (agentIds.length === 0) return null;
|
|
const hoverTasks = [...runningTasks, ...queuedTasks];
|
|
const isRunning = opacity === "full";
|
|
|
|
return (
|
|
<HoverCard>
|
|
<HoverCardTrigger
|
|
render={
|
|
<span className="inline-flex shrink-0 items-center gap-1" />
|
|
}
|
|
>
|
|
<AgentAvatarStack
|
|
agentIds={agentIds}
|
|
size={size}
|
|
opacity={opacity}
|
|
max={3}
|
|
/>
|
|
<span
|
|
className={cn(
|
|
"text-[10px] leading-none",
|
|
isRunning
|
|
? "animate-chat-text-shimmer"
|
|
: "text-muted-foreground",
|
|
)}
|
|
>
|
|
{isRunning
|
|
? t(($) => $.agent_activity.status_running)
|
|
: t(($) => $.agent_activity.status_queued)}
|
|
</span>
|
|
</HoverCardTrigger>
|
|
<HoverCardContent align="end" className="w-72">
|
|
<AgentActivityHoverContent tasks={hoverTasks} />
|
|
</HoverCardContent>
|
|
</HoverCard>
|
|
);
|
|
});
|