import { GearIcon } from "@refs/design-system/icons";
import type { Attribution, OnlineAgent } from "@refs/backend/contract";
import { AgentAvatar, Avatar, Button, cn } from "@refs/design-system";
type AvatarSize = "xs" | "sm" | "base";
export function human(name: string): Attribution {
return { actor: { kind: "human", id: "", name } };
}
/** Who opened a pull request: the agent, acting for its author, or the author alone. */
export function openerOf(pull: { readonly author: { readonly name: string }; readonly agent: string | null }): Attribution {
return pull.agent ? { actor: { kind: "agent", id: "", name: pull.agent, runtime: pull.agent }, onBehalfOf: { id: "", name: pull.author.name } } : human(pull.author.name);
}
/** A small actor mark and name, for list rows and headers. */
export function Opener({ by }: { by: Attribution }) {
return (
);
}
export function isAgent(by: Attribution): boolean {
return by.actor.kind === "agent" || by.onBehalfOf !== undefined;
}
/** A person is a filled blue circle; an agent is a hollow ring. */
export function ActorMark({ by, size = "sm" }: { by: Attribution; size?: AvatarSize }) {
return isAgent(by) ? : ;
}
/** "claude-code for Aman": the runtime in medium weight, the person it acts for muted. */
export function ActorName({ by }: { by: Attribution }) {
return (
{by.actor.name}
{by.onBehalfOf && for {by.onBehalfOf.name}}
);
}
export function AgentName({ agent }: { agent: Pick }) {
return (
{agent.runtime} for {agent.onBehalfOf.name}
);
}
export function Who({ by }: { by: Attribution }) {
return (
);
}
type MarkerTone = "human" | "agent" | "event";
const MARKER: Record = {
human: "bg-accent",
agent: "bg-ground shadow-[inset_0_0_0_1.5px_var(--porcelain)]",
event: "bg-line",
};
export function toneOf(by: Attribution): MarkerTone {
return isAgent(by) ? "agent" : "human";
}
/** A vertical hairline; each row hangs a station mark on it. */
export function Timeline({ children }: { children: React.ReactNode }) {
return (
);
}
/** An event: one quiet line on the timeline. */
export function EventLine({ by, icon, children }: { by: Attribution; icon: React.ReactNode; children: React.ReactNode }) {
return (
{icon}
{children}
);
}
/** A field of a page's side column: a caption, an optional control, and the value. */
export function Field({ label, action, children }: { label: string; action?: React.ReactNode; children: React.ReactNode }) {
return (