import { useState } from "react" import { CheckCircle, XCircle } from "../ui/icons" import type { GoalRecord, ProfileSnapshot, ProjectRecord, TaskRecord, TaskStatus, WorkspaceRecord } from "@shared/types" import { useT } from "../../i18n" import { unwrap } from "../../lib/desktop" import { ActionButton, Input, Select, TextArea } from "../ui" import { describeActionError } from "./execution-utils" export function TaskInspectorEditForm({ task, agents, goals, projects, workspaces, onDone, onRefresh, onError, onNotice, addToast, }: { task: TaskRecord agents: ProfileSnapshot["agents"] goals: GoalRecord[] projects: ProjectRecord[] workspaces: WorkspaceRecord[] onDone: () => void onRefresh: () => Promise onError: (message: string | null) => void onNotice: (message: string | null) => void addToast: (message: string, tone?: "success" | "warn" | "danger") => void }) { const t = useT() const [title, setTitle] = useState(task.title) const [description, setDescription] = useState(task.description) const [priority, setPriority] = useState(task.priority) const [status, setStatus] = useState(task.status) const [assignee, setAssignee] = useState(task.assigneeAgentId ?? "") const [workspace, setWorkspace] = useState(task.workspaceId ?? "") const [project, setProject] = useState(task.projectId ?? "") const [goal, setGoal] = useState(task.goalId ?? "") const [saving, setSaving] = useState(false) const save = async () => { onError(null); onNotice(null); setSaving(true) try { unwrap(await window.agentCompany.saveTask({ id: task.id, companyId: task.companyId, title, description, priority: priority as TaskRecord["priority"], status, assigneeAgentId: assignee || null, workspaceId: workspace || null, projectId: project || null, goalId: goal || null, })) await onRefresh() onDone() onNotice("Task changes saved.") addToast("Task changes saved", "success") } catch (e) { onError(describeActionError(e)) } finally { setSaving(false) } } return (