From c843c89a34e7dfaa1aaa4a4b49bc5ecb5b3eed6f Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Wed, 1 Apr 2026 17:39:16 -0700 Subject: [PATCH 1/2] Persist new task draft across navigation --- .../components/CommandCenterPanel.tsx | 28 +++++++++-- .../stores/commandCenterStore.ts | 46 +++++++++++++++---- .../task-detail/components/TaskInput.tsx | 8 +++- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/apps/code/src/renderer/features/command-center/components/CommandCenterPanel.tsx b/apps/code/src/renderer/features/command-center/components/CommandCenterPanel.tsx index 9206b47b1..686ab32cf 100644 --- a/apps/code/src/renderer/features/command-center/components/CommandCenterPanel.tsx +++ b/apps/code/src/renderer/features/command-center/components/CommandCenterPanel.tsx @@ -1,3 +1,4 @@ +import { useDraftStore } from "@features/message-editor/stores/draftStore"; import { TaskInput } from "@features/task-detail/components/TaskInput"; import { ArrowsOut, Plus, X } from "@phosphor-icons/react"; import { Flex, Text } from "@radix-ui/themes"; @@ -15,18 +16,35 @@ interface CommandCenterPanelProps { isActiveSession: boolean; } +function getCellSessionId(cellIndex: number): string { + return `cc-cell-${cellIndex}`; +} + function EmptyCell({ cellIndex }: { cellIndex: number }) { const [selectorOpen, setSelectorOpen] = useState(false); - const [isCreating, setIsCreating] = useState(false); + const isCreating = useCommandCenterStore((s) => + s.creatingCells.includes(cellIndex), + ); const assignTask = useCommandCenterStore((s) => s.assignTask); + const startCreating = useCommandCenterStore((s) => s.startCreating); + const stopCreating = useCommandCenterStore((s) => s.stopCreating); + const clearDraft = useDraftStore((s) => s.actions.setDraft); + + const sessionId = getCellSessionId(cellIndex); const handleTaskCreated = useCallback( (task: Task) => { assignTask(cellIndex, task.id); + clearDraft(sessionId, null); }, - [assignTask, cellIndex], + [assignTask, cellIndex, clearDraft, sessionId], ); + const handleCancel = useCallback(() => { + stopCreating(cellIndex); + clearDraft(sessionId, null); + }, [stopCreating, cellIndex, clearDraft, sessionId]); + if (isCreating) { return ( @@ -46,7 +64,7 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) { - + ); @@ -67,7 +85,7 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) { cellIndex={cellIndex} open={selectorOpen} onOpenChange={setSelectorOpen} - onNewTask={() => setIsCreating(true)} + onNewTask={() => startCreating(cellIndex)} >