'use client'; import { memo } from 'react'; import { IconDeviceFloppy, IconX, IconLoader2, IconRobot, IconUser, IconCopy, IconRefresh, IconTrash, IconSend, } from '@tabler/icons-react'; import { GridSpinner } from '@/components/grid-spinner'; 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; // Comments props commentCount?: number; isSubmittingComments?: boolean; onSubmitComments?: () => void; onClearComments?: () => void; // Existing handlers onSave: () => void; onDiscard: () => void; onCopy: () => void; onReanalyze: () => void; onClear: () => void; }; export const TaskPlanToolbar = memo(function TaskPlanToolbar({ plan, hasUnsavedChanges, hasDraftContent, isSaving, isAgentBusy, isReanalyzing, hasActiveSession, commentCount = 0, isSubmittingComments = false, onSubmitComments, onClearComments, onSave, onDiscard, onCopy, onReanalyze, onClear, }: TaskPlanToolbarProps) { const hasComments = commentCount > 0; return (
{/* Animated progress bar when agent is working */} {isAgentBusy && (
)}
{/* Left: Status info */}
{plan && (
{plan.created_by === 'agent' ? ( ) : ( )} {plan.created_by}
Created by {plan.created_by}
)} {isAgentBusy ? ( Agent is working ) : 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
)}
); });