From 7d2079d7c13804766405af8044574bfc93a86897 Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Mon, 16 Feb 2026 15:45:42 +0000
Subject: Add PR button to directives

---
 .../src/components/directives/DirectiveDetail.tsx        | 16 ++++++++++++++++
 1 file changed, 16 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 9305e20..c8da7a0 100644
--- a/makima/frontend/src/components/directives/DirectiveDetail.tsx
+++ b/makima/frontend/src/components/directives/DirectiveDetail.tsx
@@ -27,6 +27,7 @@ interface DirectiveDetailProps {
   onRefresh: () => void;
   onCleanupTasks: () => void;
   onPickUpOrders: () => Promise<{ message: string; orderCount: number; taskId: string | null } | null>;
+  onCreatePR: () => Promise<void>;
 }
 
 export function DirectiveDetail({
@@ -43,12 +44,14 @@ export function DirectiveDetail({
   onRefresh,
   onCleanupTasks,
   onPickUpOrders,
+  onCreatePR,
 }: 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);
+  const [creatingPR, setCreatingPR] = useState(false);
 
   // Sync goalText and reset editing state when directive changes
   useEffect(() => {
@@ -333,6 +336,19 @@ export function DirectiveDetail({
               Clean up tasks
             </button>
           )}
+          {completedSteps > 0 && !directive.completionTaskId && (
+            <button
+              type="button"
+              onClick={async () => {
+                setCreatingPR(true);
+                try { await onCreatePR(); } catch (e) { console.error("Failed to create PR:", e); } finally { setCreatingPR(false); }
+              }}
+              disabled={creatingPR}
+              className="text-[10px] font-mono text-emerald-400 hover:text-emerald-300 border border-emerald-800 rounded px-2 py-1 disabled:opacity-50"
+            >
+              {creatingPR ? "Creating..." : directive.prUrl ? "Update PR" : "Create PR"}
+            </button>
+          )}
           <button
             type="button"
             onClick={handlePickUpOrders}
-- 
cgit v1.2.3

