mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-28 05:46:58 +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>
200 lines
5.4 KiB
TypeScript
200 lines
5.4 KiB
TypeScript
"use client";
|
|
|
|
import React, { useMemo, useState } from "react";
|
|
import { Plus } from "lucide-react";
|
|
import { Button } from "@multica/ui/components/ui/button";
|
|
import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
|
|
import { ActorAvatar } from "../../common/actor-avatar";
|
|
import {
|
|
PickerEmpty,
|
|
PickerItem,
|
|
PickerSection,
|
|
PropertyPicker,
|
|
} from "../../issues/components/pickers/property-picker";
|
|
import { matchesPinyin } from "../../editor/extensions/pinyin-match";
|
|
import type { Agent } from "@multica/core/types";
|
|
import { useT } from "../../i18n";
|
|
|
|
/**
|
|
* Agent picker: a searchable, grouped (My agents / Others) list of agents in a
|
|
* PropertyPicker. The caller supplies the trigger. `currentAgentId` marks one
|
|
* agent with a check — omit it (as "new chat" does) when there is no current
|
|
* selection to highlight.
|
|
*/
|
|
export function AgentPicker({
|
|
agents,
|
|
userId,
|
|
currentAgentId,
|
|
onSelect,
|
|
trigger,
|
|
triggerRender,
|
|
side = "bottom",
|
|
align = "start",
|
|
}: {
|
|
agents: Agent[];
|
|
userId: string | undefined;
|
|
currentAgentId?: string;
|
|
onSelect: (agent: Agent) => void;
|
|
trigger: React.ReactNode;
|
|
triggerRender: React.ReactElement;
|
|
side?: "top" | "bottom";
|
|
align?: "start" | "center" | "end";
|
|
}) {
|
|
const { t } = useT("chat");
|
|
const [open, setOpen] = useState(false);
|
|
const [filter, setFilter] = useState("");
|
|
const { mine, others } = useMemo(() => {
|
|
const mine: Agent[] = [];
|
|
const others: Agent[] = [];
|
|
for (const a of agents) {
|
|
if (a.owner_id === userId) mine.push(a);
|
|
else others.push(a);
|
|
}
|
|
return { mine, others };
|
|
}, [agents, userId]);
|
|
|
|
const query = filter.trim().toLowerCase();
|
|
const matches = (name: string) =>
|
|
!query || name.toLowerCase().includes(query) || matchesPinyin(name, query);
|
|
const filteredMine = mine.filter((agent) => matches(agent.name));
|
|
const filteredOthers = others.filter((agent) => matches(agent.name));
|
|
|
|
const handlePick = (agent: Agent) => {
|
|
onSelect(agent);
|
|
setOpen(false);
|
|
};
|
|
|
|
return (
|
|
<PropertyPicker
|
|
open={open}
|
|
onOpenChange={setOpen}
|
|
width="w-64"
|
|
align={align}
|
|
side={side}
|
|
searchable
|
|
searchPlaceholder={t(($) => $.window.agent_filter_placeholder)}
|
|
onSearchChange={setFilter}
|
|
triggerRender={triggerRender}
|
|
trigger={trigger}
|
|
>
|
|
{filteredMine.length === 0 && filteredOthers.length === 0 ? (
|
|
<PickerEmpty />
|
|
) : (
|
|
<>
|
|
{filteredMine.length > 0 && (
|
|
<PickerSection label={t(($) => $.window.my_agents)}>
|
|
{filteredMine.map((agent) => (
|
|
<AgentPickerItem
|
|
key={agent.id}
|
|
agent={agent}
|
|
isCurrent={agent.id === currentAgentId}
|
|
onSelect={handlePick}
|
|
/>
|
|
))}
|
|
</PickerSection>
|
|
)}
|
|
{filteredOthers.length > 0 && (
|
|
<PickerSection label={t(($) => $.window.others)}>
|
|
{filteredOthers.map((agent) => (
|
|
<AgentPickerItem
|
|
key={agent.id}
|
|
agent={agent}
|
|
isCurrent={agent.id === currentAgentId}
|
|
onSelect={handlePick}
|
|
/>
|
|
))}
|
|
</PickerSection>
|
|
)}
|
|
</>
|
|
)}
|
|
</PropertyPicker>
|
|
);
|
|
}
|
|
|
|
function AgentPickerItem({
|
|
agent,
|
|
isCurrent,
|
|
onSelect,
|
|
}: {
|
|
agent: Agent;
|
|
isCurrent: boolean;
|
|
onSelect: (agent: Agent) => void;
|
|
}) {
|
|
return (
|
|
<PickerItem selected={isCurrent} onClick={() => onSelect(agent)}>
|
|
<ActorAvatar
|
|
actorType="agent"
|
|
actorId={agent.id}
|
|
size="md"
|
|
enableHoverCard
|
|
showStatusDot
|
|
/>
|
|
<span className="truncate flex-1">{agent.name}</span>
|
|
</PickerItem>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* "New chat" ⊕ button. Per the Chat V2 design, starting a new chat is where the
|
|
* agent is chosen — so this opens an AgentPicker and reports the pick via
|
|
* `onStart`. No agent is pre-checked: a new chat has no "current" agent yet.
|
|
* Shortcuts: with a single available agent it starts immediately (no point
|
|
* showing a one-item menu); with none it still fires `onStart(null)` so the
|
|
* surface shows its no-agent empty state.
|
|
*/
|
|
export function NewChatButton({
|
|
agents,
|
|
userId,
|
|
onStart,
|
|
side = "bottom",
|
|
}: {
|
|
agents: Agent[];
|
|
userId: string | undefined;
|
|
onStart: (agent: Agent | null) => void;
|
|
side?: "top" | "bottom";
|
|
}) {
|
|
const { t } = useT("chat");
|
|
const label = t(($) => $.window.new_chat_tooltip);
|
|
|
|
if (agents.length <= 1) {
|
|
const only = agents[0] ?? null;
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger
|
|
render={
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
className="rounded-full text-muted-foreground"
|
|
aria-label={label}
|
|
onClick={() => onStart(only)}
|
|
/>
|
|
}
|
|
>
|
|
<Plus />
|
|
</TooltipTrigger>
|
|
<TooltipContent side={side === "top" ? "top" : "bottom"}>{label}</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<AgentPicker
|
|
agents={agents}
|
|
userId={userId}
|
|
onSelect={(agent) => onStart(agent)}
|
|
side={side}
|
|
align="start"
|
|
triggerRender={
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
className="rounded-full text-muted-foreground"
|
|
aria-label={label}
|
|
/>
|
|
}
|
|
trigger={<Plus />}
|
|
/>
|
|
);
|
|
}
|