/** Header sub-component for WorkItemDetailPanel. */ import type { AgentConfigInfo, AgentInfo, AgentStatusValue } from "../api/agents"; import { STAGE_LABELS, formatStoryTitle } from "./workItemDetailPanelUtils"; const STAGE_TO_AGENT_STAGE: Record = { current: "coder", qa: "qa", merge: "mergemaster", }; interface WorkItemDetailPanelHeaderProps { storyId: string; name: string | null; stage: string; assignedAgent: string | null; agentConfig: AgentConfigInfo[]; agentInfo: AgentInfo | null; agentStatus: AgentStatusValue | null; assigning: boolean; assignError: string | null; onAgentAssign: (agentName: string) => Promise; onClose: () => void; } /** * Panel header: title, stage label, agent assignment dropdown, and close button. */ export function WorkItemDetailPanelHeader({ storyId, name, stage, assignedAgent, agentConfig, agentInfo, agentStatus, assigning, assignError, onAgentAssign, onClose, }: WorkItemDetailPanelHeaderProps) { const stageLabel = STAGE_LABELS[stage] ?? stage; const filteredAgents = agentConfig.filter( (a) => a.stage === STAGE_TO_AGENT_STAGE[stage], ); const activeAgentName = agentInfo && (agentStatus === "running" || agentStatus === "pending") ? agentInfo.agent_name : null; return (
{formatStoryTitle(storyId, name)}
{stage && (
{stageLabel}
)} {filteredAgents.length > 0 && (
Agent: {assigning && ( Assigning… )} {assignError && ( {assignError} )}
)} {filteredAgents.length === 0 && assignedAgent ? (
Agent: {assignedAgent}
) : null}
); }