Skip to content

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

Go
2.3 KB
Raw Blame
import { cn } from "@multica/ui/lib/utils";
import type { AgentRuntime } from "@multica/core/types";
import { runtimeDisplayName } from "@multica/core/runtimes";
import { ProviderLogo } from "./provider-logo";
import { useT } from "../../i18n";

/**
 * One-line runtime row for Step 3's web CLI expand. Provider logo,
 * name + subtitle, online indicator on the right. Selection state is
 * driven by the caller (kept stateless so both StepPlatformFork and
 * any future embedder can share it without duplicating the picker
 * plumbing).
 */
export function CompactRuntimeRow({
  runtime,
  selected,
  onSelect,
  disabled = false,
}: {
  runtime: AgentRuntime;
  selected: boolean;
  onSelect: () => void;
  /** Set while a submit is in flight, so the choice cannot change under it. */
  disabled?: boolean;
}) {
  const { t: tAgents } = useT("agents");
  const online = runtime.status === "online";
  return (
    // A real button rather than role="button": it brings disabled, focus, and
    // Enter/Space for free. The hand-rolled keydown branch this replaces did
    // not honour disabled at all, so a member could switch runtimes mid-submit
    // and end up with Mika on a machine they no longer had selected.
    <button
      type="button"
      onClick={onSelect}
      disabled={disabled}
      aria-pressed={selected}
      className={cn(
        "flex w-full flex-row items-center gap-3 rounded-lg border bg-card p-4 text-left transition-colors",
        "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
        "disabled:pointer-events-none disabled:opacity-60",
        selected
          ? "border-primary ring-1 ring-primary"
          : "hover:border-foreground/20",
      )}
    >
      <ProviderLogo provider={runtime.provider} className="h-5 w-5" />
      <div className="min-w-0 flex-1">
        <div className="truncate text-body font-medium">
          {runtimeDisplayName(runtime)}
        </div>
        <div className="text-caption text-muted-foreground">{runtime.provider}</div>
      </div>
      <span
        className={cn(
          "h-2 w-2 shrink-0 rounded-full",
          online ? "bg-success" : "bg-muted-foreground/40",
        )}
        aria-label={online ? tAgents(($) => $.availability.online) : tAgents(($) => $.availability.offline)}
      />
    </button>
  );
}