import React, { useCallback } from 'react'; import type { DeepImmutable } from 'src/types/utils.js'; import { useElapsedTime } from '../../hooks/useElapsedTime.js'; import { Box, Text, type KeyboardEvent } from '@anthropic/ink'; import { useKeybindings } from '../../keybindings/useKeybinding.js'; import type { LocalWorkflowTaskState } from '../../tasks/LocalWorkflowTask/LocalWorkflowTask.js'; import { Byline } from '../design-system/Byline.js'; import { Dialog } from '../design-system/Dialog.js'; import { KeyboardShortcutHint } from '../design-system/KeyboardShortcutHint.js'; type Props = { workflow: DeepImmutable; onDone: (message?: string, options?: { display?: string }) => void; onKill?: () => void; onSkipAgent?: (agentId: string) => void; onRetryAgent?: (agentId: string) => void; onBack?: () => void; }; /** * Detail dialog for local workflow tasks shown in the Shift+Down background * tasks overlay. Displays the workflow name, file, status, and output. * Follows the DreamDetailDialog/ShellDetailDialog pattern. */ export function WorkflowDetailDialog({ workflow, onDone: _onDone, onKill, onSkipAgent: _onSkipAgent, onRetryAgent: _onRetryAgent, onBack, }: Props): React.ReactNode { const elapsedTime = useElapsedTime(workflow.startTime, workflow.status === 'running', 1000, 0); useKeybindings({}, { context: 'WorkflowDetail' }); const handleKeyDown = useCallback( (e: KeyboardEvent): void => { if (e.key === 'left' && onBack) { e.preventDefault(); onBack(); } else if (e.key === 'x' && workflow.status === 'running' && onKill) { e.preventDefault(); onKill(); } }, [onBack, onKill, workflow.status], ); return ( {elapsedTime} ยท {workflow.workflowName} } onCancel={onBack ?? (() => {})} inputGuide={() => ( {onBack && } {workflow.status === 'running' && onKill && } )} > Status:{' '} {workflow.status === 'running' ? ( running ) : workflow.status === 'completed' ? ( {workflow.status} ) : ( {workflow.status} )} Description: {workflow.description} Workflow: {workflow.workflowName} File: {workflow.workflowFile} {workflow.summary && ( Summary: {workflow.summary} )} {workflow.output && ( Output: {workflow.output} )} ); }