'use client'; import { memo } from 'react'; import { IconDeviceFloppy, IconX, IconLoader2, IconRobot, IconUser, IconArrowRight, IconCopy, IconRefresh, IconTrash, IconSend, } from '@tabler/icons-react'; import { Button } from '@kandev/ui/button'; import { Tooltip, TooltipContent, TooltipTrigger } from '@kandev/ui/tooltip'; import { cn, formatRelativeTime } from '@/lib/utils'; import type { TaskPlan } from '@/lib/types/http'; type TaskPlanToolbarProps = { plan: TaskPlan | null; hasUnsavedChanges: boolean; hasDraftContent: boolean; isSaving: boolean; isAgentBusy: boolean; isReanalyzing: boolean; hasActiveSession: boolean; showApproveButton?: boolean; // Comments props commentCount?: number; isSubmittingComments?: boolean; onSubmitComments?: () => void; onClearComments?: () => void; // Existing handlers onSave: () => void; onDiscard: () => void; onCopy: () => void; onReanalyze: () => void; onClear: () => void; onApprove?: () => void; }; export const TaskPlanToolbar = memo(function TaskPlanToolbar({ plan, hasUnsavedChanges, hasDraftContent, isSaving, isAgentBusy, isReanalyzing, hasActiveSession, showApproveButton, commentCount = 0, isSubmittingComments = false, onSubmitComments, onClearComments, onSave, onDiscard, onCopy, onReanalyze, onClear, onApprove, }: TaskPlanToolbarProps) { const hasComments = commentCount > 0; return (
{/* Left: Status info */}
{plan && (
{plan.created_by === 'agent' ? ( ) : ( )} {plan.created_by}
Created by {plan.created_by}
)} {hasUnsavedChanges ? ( Unsaved changes · ⌘S to save ) : plan?.updated_at ? ( Saved {formatRelativeTime(plan.updated_at)} ) : null}
{/* Right: Actions */}
{hasUnsavedChanges && ( <> Discard changes Save plan )} {/* Separator before utility actions */} {(hasUnsavedChanges || plan || hasDraftContent) && (
)} {/* Copy to clipboard */} Copy to clipboard {/* Re-analyze with agent */} Ask agent to review plan {/* Clear/Delete plan */} Clear plan {/* Separator before comments */} {hasComments &&
} {/* Comments section */} {hasComments && (
{/* Clear comments */} Clear all comments {/* Submit comments button - round with count inside */} Send {commentCount} comment{commentCount !== 1 ? 's' : ''} to agent
)} {/* Separator before approve button */} {showApproveButton && onApprove && (
)} {/* Approve button - styled like submit button */} {showApproveButton && onApprove && (
Approve plan and continue
)}
); });