From b6a29bb563499b2fd6280c742bd2106d66393112 Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Mon, 16 Feb 2026 15:09:25 +0000
Subject: Add pick-up-orders feature for directives (#64)

* WIP: heartbeat checkpoint

* WIP: heartbeat checkpoint

* feat: soryu-co/soryu - makima: Add frontend pick-up-orders button and API integration

* feat: soryu-co/soryu - makima: Add pick-up-orders backend endpoint and repository functions
---
 .../src/components/directives/DirectiveDetail.tsx  | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

(limited to 'makima/frontend/src/components/directives/DirectiveDetail.tsx')

diff --git a/makima/frontend/src/components/directives/DirectiveDetail.tsx b/makima/frontend/src/components/directives/DirectiveDetail.tsx
index e278939..9305e20 100644
--- a/makima/frontend/src/components/directives/DirectiveDetail.tsx
+++ b/makima/frontend/src/components/directives/DirectiveDetail.tsx
@@ -26,6 +26,7 @@ interface DirectiveDetailProps {
   onDelete: () => void;
   onRefresh: () => void;
   onCleanupTasks: () => void;
+  onPickUpOrders: () => Promise<{ message: string; orderCount: number; taskId: string | null } | null>;
 }
 
 export function DirectiveDetail({
@@ -41,10 +42,13 @@ export function DirectiveDetail({
   onDelete,
   onRefresh,
   onCleanupTasks,
+  onPickUpOrders,
 }: DirectiveDetailProps) {
   const [editingGoal, setEditingGoal] = useState(false);
   const [goalText, setGoalText] = useState(directive.goal);
   const [visibleTaskIds, setVisibleTaskIds] = useState<Set<string> | null>(null);
+  const [pickingUpOrders, setPickingUpOrders] = useState(false);
+  const [pickUpResult, setPickUpResult] = useState<string | null>(null);
 
   // Sync goalText and reset editing state when directive changes
   useEffect(() => {
@@ -121,6 +125,23 @@ export function DirectiveDetail({
     prevHadRunningRef.current = hasRunningTasks;
   }, [hasRunningTasks]);
 
+  const handlePickUpOrders = async () => {
+    setPickingUpOrders(true);
+    setPickUpResult(null);
+    try {
+      const result = await onPickUpOrders();
+      if (result) {
+        setPickUpResult(result.message);
+        setTimeout(() => setPickUpResult(null), 5000);
+      }
+    } catch (e) {
+      setPickUpResult(e instanceof Error ? e.message : "Failed to pick up orders");
+      setTimeout(() => setPickUpResult(null), 5000);
+    } finally {
+      setPickingUpOrders(false);
+    }
+  };
+
   const handleGoalSave = () => {
     if (goalText.trim() && goalText !== directive.goal) {
       onUpdateGoal(goalText.trim());
@@ -312,6 +333,14 @@ export function DirectiveDetail({
               Clean up tasks
             </button>
           )}
+          <button
+            type="button"
+            onClick={handlePickUpOrders}
+            disabled={pickingUpOrders}
+            className="text-[10px] font-mono text-[#c084fc] hover:text-[#d8b4fe] border border-[rgba(192,132,252,0.3)] rounded px-2 py-1 disabled:opacity-50"
+          >
+            {pickingUpOrders ? "Picking up..." : "Pick Up Orders"}
+          </button>
           <button
             type="button"
             onClick={onDelete}
@@ -320,6 +349,12 @@ export function DirectiveDetail({
             Delete
           </button>
         </div>
+
+        {pickUpResult && (
+          <div className="mt-2 px-2 py-1.5 bg-[#1a1030] border border-[rgba(192,132,252,0.2)] rounded">
+            <span className="text-[10px] font-mono text-[#c084fc]">{pickUpResult}</span>
+          </div>
+        )}
       </div>
 
       {/* Goal */}
-- 
cgit v1.2.3

