From 713686a250bafe543eab63d7319c51a836d5db69 Mon Sep 17 00:00:00 2001 From: Dylan Boudro <121908331+starmorph@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:11:37 -0700 Subject: [PATCH] rm edit add delete from UI (#147) * rm edit add delete from UI * rm unneeded CRUD utils props funcs * fix build --- apps/web/src/components/tasks/index.tsx | 324 ++++-------------- apps/web/src/components/tasks/useTaskPlan.tsx | 95 ----- apps/web/src/components/thread/index.tsx | 11 +- 3 files changed, 65 insertions(+), 365 deletions(-) diff --git a/apps/web/src/components/tasks/index.tsx b/apps/web/src/components/tasks/index.tsx index 81305a4a..fcafb071 100644 --- a/apps/web/src/components/tasks/index.tsx +++ b/apps/web/src/components/tasks/index.tsx @@ -1,8 +1,6 @@ "use client"; - import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; -import { Textarea } from "@/components/ui/textarea"; import { Collapsible, CollapsibleContent, @@ -15,10 +13,6 @@ import { ChevronDown, ChevronRight, ChevronLeft, - Edit2, - Save, - Plus, - Trash2, Clock, Filter, PanelLeftClose, @@ -36,27 +30,11 @@ interface TasksSidebarProps { taskPlan: TaskPlan; className?: string; onTaskChange?: (taskId: string) => void; - onRevisionChange?: (taskId: string, revisionIndex: number) => void; - onEditPlanItem?: ( - taskId: string, - planItemIndex: number, - newPlan: string, - ) => void; - onAddPlanItem?: (taskId: string, plan: string) => void; - onDeletePlanItem?: (taskId: string, planItemIndex: number) => void; } interface TaskPlanViewProps { taskPlan: TaskPlan; onTaskChange?: (taskId: string) => void; - onRevisionChange?: (taskId: string, revisionIndex: number) => void; - onEditPlanItem?: ( - taskId: string, - planItemIndex: number, - newPlan: string, - ) => void; - onAddPlanItem?: (taskId: string, plan: string) => void; - onDeletePlanItem?: (taskId: string, planItemIndex: number) => void; } type FilterType = "all" | "completed" | "current" | "pending"; @@ -67,10 +45,6 @@ export function TasksSidebar({ onClose, taskPlan, onTaskChange, - onRevisionChange, - onEditPlanItem, - onAddPlanItem, - onDeletePlanItem, }: TasksSidebarProps) { const [currentTaskIndex, setCurrentTaskIndex] = useState( taskPlan.activeTaskIndex, @@ -79,10 +53,6 @@ export function TasksSidebar({ const [expandedSummaries, setExpandedSummaries] = useState>( new Set(), ); - const [editingPlanItem, setEditingPlanItem] = useState(null); - const [editingText, setEditingText] = useState(""); - const [newPlanItemText, setNewPlanItemText] = useState(""); - const [showAddPlanItem, setShowAddPlanItem] = useState(false); const [filter, setFilter] = useState("all"); const currentTask = taskPlan.tasks[currentTaskIndex]; @@ -94,7 +64,6 @@ export function TasksSidebar({ if (currentTask?.planRevisions) { setCurrentRevisionIndex(currentTask.activeRevisionIndex); setExpandedSummaries(new Set()); - setEditingPlanItem(null); } }, [currentTask]); @@ -120,15 +89,6 @@ export function TasksSidebar({ return true; }); - const isPlanItemEditable = (item: PlanItem) => { - return ( - isLatestTask && - isLatestRevision && - !item.completed && - item.index !== currentPlanItemIndex - ); - }; - const getItemState = ( item: PlanItem, ): "completed" | "current" | "remaining" => { @@ -148,34 +108,11 @@ export function TasksSidebar({ } }; - const startEditing = (item: PlanItem) => { - setEditingPlanItem(item.index); - setEditingText(item.plan); - }; - - const saveEdit = () => { - if (editingPlanItem !== null && editingText.trim()) { - onEditPlanItem?.(currentTask.id, editingPlanItem, editingText.trim()); - setEditingPlanItem(null); - setEditingText(""); - } - }; - - const addNewPlanItem = () => { - if (newPlanItemText.trim()) { - onAddPlanItem?.(currentTask.id, newPlanItemText.trim()); - setNewPlanItemText(""); - setShowAddPlanItem(false); - } - }; - const goToPreviousRevision = () => { if (currentRevisionIndex > 0) { const newIndex = currentRevisionIndex - 1; setCurrentRevisionIndex(newIndex); - onRevisionChange?.(currentTask.id, newIndex); setExpandedSummaries(new Set()); - setEditingPlanItem(null); } }; @@ -183,18 +120,14 @@ export function TasksSidebar({ if (currentRevisionIndex < currentTask.planRevisions.length - 1) { const newIndex = currentRevisionIndex + 1; setCurrentRevisionIndex(newIndex); - onRevisionChange?.(currentTask.id, newIndex); setExpandedSummaries(new Set()); - setEditingPlanItem(null); } }; const goToLatestRevision = () => { const latestIndex = currentTask.activeRevisionIndex; setCurrentRevisionIndex(latestIndex); - onRevisionChange?.(currentTask.id, latestIndex); setExpandedSummaries(new Set()); - setEditingPlanItem(null); }; const formatDate = (timestamp: number) => { @@ -353,12 +286,6 @@ export function TasksSidebar({ - - {isLatestTask && isLatestRevision && ( - - Editable - - )} @@ -373,8 +300,6 @@ export function TasksSidebar({ filteredItems.map((item) => { const state = getItemState(item); const isExpanded = expandedSummaries.has(item.index); - const isEditing = editingPlanItem === item.index; - const editable = isPlanItemEditable(item); return (
- {isEditing ? ( -
-