import { useMemo, useRef, useState } from "react"; import { useComposerDictation } from "../hooks/useComposerDictation"; import { MicButton } from "./MicButton"; import { useTranslation } from "react-i18next"; import type { TFunction } from "i18next"; import type { Task, TaskComment } from "@fusion/core"; import { getErrorMessage } from "@fusion/core"; import "./TaskComments.css"; import { addSteeringComment, updateTaskComment, deleteTaskComment } from "../api"; import type { ToastType } from "../hooks/useToast"; const MAX_COMMENT_LENGTH = 2000; interface TaskCommentsProps { task: Task; onTaskUpdated?: (task: Task) => void; addToast: (message: string, type?: ToastType) => void; currentAuthor?: string; projectId?: string; } function formatCommentTimestamp(comment: TaskComment, t: TFunction<"app">): string { const timestamp = comment.updatedAt || comment.createdAt; const label = new Date(timestamp).toLocaleString(); return comment.updatedAt ? `${label} ${t("comments.editedSuffix", "(edited)")}` : label; } function isAIGuidanceComment(author: string): boolean { return author === "agent" || author === "system"; } function EditCommentComposer({ value, onChange, onCancel, onSave, disabled, projectId, t }: { value: string; onChange: (value: string) => void; onCancel: () => void; onSave: () => void; disabled: boolean; projectId?: string; t: TFunction<"app">; }) { const textareaRef = useRef(null); const dictation = useComposerDictation({ textareaRef, value, onChange, projectId }); return