import { Archive, GitFork, Plus } from 'lucide-react'; import { closeDialogOnEscape } from '../../app/dialogs'; import type { AgentBackgroundSubmitMode } from '../../app/types'; import { AgentGoalStatusPanel, AgentRuntimeStatusPanel, formatAgentConversationSessionMeta, } from '../agent-runtime'; import { taskGroupLabels, taskStatusLabels, } from '../project-summary/projectSummary'; import type { DeveloperAgentPanelController } from './useDeveloperAgentPanel'; export function DeveloperAgentPanel({ controller, onRuntimeConfigOpen, }: { controller: DeveloperAgentPanelController; onRuntimeConfigOpen: () => void; }) { const { agentChatActiveSessionId, agentChatBackgroundBusy, agentChatBusy, agentChatConversationPath, agentChatGoal, agentChatGoalError, agentChatInput, agentChatInteractionMode, agentChatLegacySessionMode, agentChatLlmStatus, agentChatLoadVersionRef, agentChatMessages, agentChatMessagesRef, agentChatProjectPath, agentChatResumeConfirmation, agentChatRunSubmitMode, agentChatRuntime, agentChatRuntimeError, agentChatRuntimeResumeProjectPathRef, agentChatSelectedAgentId, agentChatSelectedSessionId, agentChatSessionStatus, agentChatSessions, agentChatStatus, cancelAgentChatRuntimeResume, confirmAgentChatRuntimeResume, currentAgentChatActiveSessions, currentAgentChatAgent, currentAgentChatArchivedSessions, currentAgentChatGoalDialogMode, currentAgentChatGoalStatus, currentAgentChatLlmWarning, currentAgentChatNeedsUserInput, currentAgentChatSession, currentAgentChatSessionArchived, currentAgentChatSessionMutationBlocked, currentAgentChatSteerRuntime, currentAgentChatWaiting, currentAgentChatWaitingDetail, currentAgentChatWaitingStatus, handleAgentChatArchiveSession, handleAgentChatCancelRuntimeTask, handleAgentChatCompactContext, handleAgentChatConfirmRuntimeTask, handleAgentChatCreateSession, handleAgentChatForkSession, handleAgentChatGoalControl, handleAgentChatMessagesScroll, handleAgentChatPickProjectDirectory, handleAgentChatRejectRuntimeTask, handleAgentChatRetryRuntimeTask, handleAgentChatSelectSession, handleAgentChatStartBackgroundTask, handleAgentChatSubmit, handleAgentChatSubmitUserInput, handleOpenProjectSupervisorChatWindow, launcherAgentChatAgents, loadAgentChatConversation, loadAgentChatLlmStatus, openAgentChatGoalDialog, resetAgentChatSessionView, setAgentChatInput, setAgentChatInteractionMode, setAgentChatProjectPath, setAgentChatResumeConfirmation, setAgentChatRunSubmitMode, setAgentChatSelectedAgentId, setAgentChatStatus, } = controller; return (

Agent 聊天

{agentChatStatus}

{currentAgentChatAgent?.title ?? '未选择 Agent'}

{currentAgentChatAgent ? (

{`${taskGroupLabels[currentAgentChatAgent.group]} / ${currentAgentChatAgent.role} · ${taskStatusLabels[currentAgentChatAgent.status]}`}

) : null}

{agentChatLlmStatus}

{agentChatConversationPath || '请选择并读取会话'}
{currentAgentChatActiveSessions.map((session) => ( ))} {currentAgentChatArchivedSessions.map((session) => ( ))}
{agentChatSessionStatus}
{currentAgentChatLlmWarning ? (
{currentAgentChatLlmWarning}
) : null} openAgentChatGoalDialog('create') : undefined } onEdit={ agentChatSelectedSessionId ? () => openAgentChatGoalDialog('edit') : undefined } onPause={ currentAgentChatSessionArchived ? undefined : () => void handleAgentChatGoalControl('pause') } onResume={ currentAgentChatSessionArchived ? undefined : () => void handleAgentChatGoalControl('resume') } onClear={ currentAgentChatSessionArchived ? undefined : () => void handleAgentChatGoalControl('clear') } /> void handleAgentChatCancelRuntimeTask(runId) } onRetryRuntimeTask={ currentAgentChatSessionArchived ? undefined : (runId) => void handleAgentChatRetryRuntimeTask(runId) } onConfirmRuntimeTask={ currentAgentChatSessionArchived ? undefined : (runId, actionId) => void handleAgentChatConfirmRuntimeTask(runId, actionId) } onRejectRuntimeTask={ currentAgentChatSessionArchived ? undefined : (runId, actionId) => void handleAgentChatRejectRuntimeTask(runId, actionId) } onSubmitUserInput={ currentAgentChatSessionArchived ? undefined : handleAgentChatSubmitUserInput } onCompactContext={ currentAgentChatSessionArchived ? undefined : () => void handleAgentChatCompactContext() } onRefreshRuntime={() => void loadAgentChatConversation( agentChatSelectedAgentId, agentChatProjectPath, agentChatSelectedSessionId, ) } />
{agentChatResumeConfirmation ? (
agent.resume {agentChatResumeConfirmation.detail}
) : null}
{agentChatMessages.length > 0 ? ( agentChatMessages.map((message, index) => (

{message.content}

)) ) : (

暂无对话

)} {currentAgentChatWaiting ? (
) : null}
{ if (agentChatInteractionMode === 'run') { event.preventDefault(); void handleAgentChatStartBackgroundTask(); return; } if (agentChatInteractionMode === 'goal') { event.preventDefault(); openAgentChatGoalDialog(currentAgentChatGoalDialogMode); return; } void handleAgentChatSubmit(event); }} >
{agentChatInteractionMode === 'goal' ? (
{agentChatGoal ? `${currentAgentChatGoalStatus ?? '-'} · Revision ${ agentChatGoal.revision } · ${agentChatGoal.outcome}` : '尚未开始'}
) : ( setAgentChatInput(event.currentTarget.value) } /> )} {agentChatInteractionMode === 'run' && currentAgentChatSteerRuntime ? ( ) : null}
); } export function DeveloperAgentDialogs({ controller, }: { controller: DeveloperAgentPanelController; }) { const { agentChatBackgroundBusy, agentChatGoalDialog, agentChatGoalDialogError, closeAgentChatGoalDialog, handleAgentChatGoalDialogSubmit, setAgentChatGoalDialog, } = controller; return ( <> {agentChatGoalDialog ? (
{ if (event.target === event.currentTarget) { closeAgentChatGoalDialog(); } }} >
void handleAgentChatGoalDialogSubmit(event)} onKeyDown={(event) => closeDialogOnEscape(event, closeAgentChatGoalDialog) } >

{agentChatGoalDialog.mode === 'create' ? '创建持久目标' : '编辑持久目标'}