import { memo } from "react"; import type { SkillInfo } from "../types"; // T-032: SkillRowHoverCard is imported here so sidebar callers can wrap a // SkillRow with the hover card via `...`. // This import lines up the dependency without altering SkillRow styling. import { SkillRowHoverCard } from "./SkillRowHoverCard"; import { SymlinkChip } from "./SymlinkChip"; import { UpdateBadge } from "./UpdateBadge"; import { UpdateChip } from "./UpdateChip"; import { VersionBadge } from "./VersionBadge"; // 0848: tiny lock chip for skills that came from a private GitHub repo. import { PrivateRepoChip } from "./PrivateRepoChip"; import type { RepoVisibility } from "../hooks/useSkillRepoVisibility"; void SkillRowHoverCard; // 0686 T-015 (US-008): SkillInfo carries `isSymlink` + `symlinkTarget` once // the server enrichment is active. Legacy payloads (pre-0686) omit both, // so the chip only renders when `isSymlink === true`. interface Props { skill: SkillInfo; isSelected: boolean; onSelect: () => void; /** * T-041: optional context-menu opener. When provided, right-click on the * row calls this with the raw mouse event so the parent can position the * ContextMenu at the cursor location. */ onContextMenu?: (event: React.MouseEvent, skill: SkillInfo) => void; /** * 0759 Phase 6: when `true`, render a small amber dot before the version * badge to flag that this authored skill has uncommitted git changes. * Resolved by the parent via `useDirtySkills` + `getDirtySkillIds`. * Optional — pre-Phase-6 callers omit it; the dot stays hidden. */ dirty?: boolean; /** * 0848: source-repo visibility resolved at the list level by the parent * (via `useConnectedRepoLookup` + `resolveSkillRepoVisibility`). The row * stays a pure presentational component — no hooks beyond memo — so the * existing custom-render tests (which invoke the component as a plain * function outside a React tree) keep working. * * Omit/`"unknown"`/`"public"` → no chip. Only `"private"` shows the amber * lock chip per AC-US1-01. */ repoVisibility?: RepoVisibility; /** 0848: `owner/name` for the chip tooltip. Optional. */ repoFullName?: string | null; } /** * 36px single-line row in the sidebar skill list. * * - Provenance dot prefix (no pill): --status-own for source skills, * --status-installed for installed skills. * - At rest: no background. On hover: subtle canvas wash. * - Selected: 1px accent-surface left border (implemented via * `box-shadow: inset 2px 0 0 var(--color-accent)`) + a soft accent wash. * - Name in Inter Tight; version in JetBrains Mono tabular-nums. * - `updateAvailable` chip renders an accent-colored "Update" pill with the * latest version when applicable. */ function SkillRowBase({ skill, isSelected, onSelect, onContextMenu, dirty, repoVisibility, repoFullName, }: Props) { const dotColor = skill.origin === "installed" ? "var(--status-installed)" : "var(--status-own)"; return ( ); } /** * 0683 T-004: wrap SkillRow in `React.memo` so sidebars with many rows only * re-render the rows whose props actually changed when an update poll lands. * The raw function is still exported as `SkillRowInner` for existing tests * that invoke the component as a plain function. */ export const SkillRowInner = SkillRowBase; export const SkillRow = memo(SkillRowBase);