import { Trans, useLingui } from "@lingui/react/macro"; import type { RunActivityRow, Space } from "@rakazo/contracts"; import { projectThreads } from "@rakazo/core"; import { Button } from "@rakazo/ui-web"; import { FolderOpen, GitBranch, Pencil, Plus, Target } from "lucide-react"; import type { ReactNode } from "react"; import { useState } from "react"; import { ProjectIcon } from "../../components/project-icon"; import { useRunActivity } from "../../lib/run-activity"; import { ActivityRow } from "../ActivityList"; type Section = "needsYou" | "running" | "done"; /** * The coordinator's view of its project: project identity, mission goal, context badges, * sub-thread creation launcher, and delegated task activity. */ export function ProjectOverview({ spaceId, space, coordinator, onOpenRun, onOpenNewInquiry, onEditProject, }: { spaceId: string; space?: Space; coordinator?: { threadId: string; botId?: string }; onOpenRun: (run: RunActivityRow) => void; onOpenNewInquiry?: () => void; onEditProject?: () => void; }) { const { t } = useLingui(); const activity = useRunActivity(); const threads = projectThreads(activity, { spaceId, coordinator }); // null until the user picks; "none" once they closed every group. const [open, setOpen] = useState
(null); const sections: { id: Section; runs: RunActivityRow[]; label: ReactNode; tone: string }[] = [ { id: "needsYou", runs: threads.needsYou, label: Needs you, tone: "text-warning", }, { id: "running", runs: threads.running, label: Running, tone: "text-foreground", }, { id: "done", runs: threads.done, label: Done, tone: "text-muted-foreground" }, ]; const visible = sections.filter((section) => section.runs.length > 0); const isProjectSpace = Boolean(space && !space.isDefault); // If not a project space and no runs, keep hidden if (!isProjectSpace && visible.length === 0) return null; // Waiting threads are what the user came for, so they start open. const shown = open ?? (threads.needsYou.length > 0 ? "needsYou" : null); const current = visible.find((section) => section.id === shown); const folderPath = space?.workspace?.path; const gitRemote = space?.workspace?.git?.remoteUrl; const goal = space?.goal; return (
{isProjectSpace && space ? (
{space.name} {onEditProject ? ( ) : null}
{onOpenNewInquiry ? ( ) : null}
{goal ? (
{goal}
) : null} {folderPath || gitRemote ? (
{folderPath ? (
{folderPath}
) : null} {gitRemote ? ( {gitRemote.replace(/^https?:\/\/(www\.)?github\.com\//, "")} ) : null}
) : null}
) : null} {visible.length > 0 ? (
{visible.map((section) => ( ))}
{current ? (
{current.runs.map((run) => ( onOpenRun(run)} /> ))}
) : null}
) : null}
); }