From 712b7ce8306d8bf5b21f35aa51957a82fa771e3b Mon Sep 17 00:00:00 2001
From: bndw <ben@bdw.to>
Date: Wed, 4 Mar 2026 22:26:24 -0800
Subject: feat: Sync sessions array after phase advance in handleSubmit (+1
 more)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- ✅ Sync sessions array after phase advance in handleSubmit
- ✅ Auto-send initial message in handleConfirmNewSession for plan/implement phases
---
 renderer/src/App.tsx | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'renderer/src/App.tsx')

diff --git a/renderer/src/App.tsx b/renderer/src/App.tsx
index 7c5c969..5fb3dd1 100644
--- a/renderer/src/App.tsx
+++ b/renderer/src/App.tsx
@@ -432,6 +432,14 @@ export function App() {
           phase: advanced.phase,
           git_branch: advanced.git_branch,
         });
+        // Keep sessions array in sync so Sidebar reflects the new phase immediately.
+        setSessions((prev) =>
+          prev.map((s) =>
+            s.id === id
+              ? { ...s, phase: advanced.phase, git_branch: advanced.git_branch }
+              : s
+          )
+        );
         setLoadingBySession((prev) => ({ ...prev, [id]: true }));
         const initialMsg =
           advanced.phase === "plan"
@@ -479,6 +487,22 @@ export function App() {
     setMessages([]);
     setDocumentContent("");
     setOriginalContent("");
+
+    // For sessions that start beyond research, kick off Claude immediately
+    // with the same message used when advancing into that phase via Submit.
+    if (phase === "plan" || phase === "implement") {
+      const initialMsg =
+        phase === "plan"
+          ? "Create a detailed implementation plan based on the research."
+          : "Begin implementing the plan.";
+      setLoadingBySession((prev) => ({ ...prev, [session.id]: true }));
+      try {
+        await api.sendMessage(session.id, initialMsg);
+      } catch (err) {
+        setError(err instanceof Error ? err.message : "Failed to start session");
+        setLoadingBySession((prev) => ({ ...prev, [session.id]: false }));
+      }
+    }
   };
 
   const handleDeleteProject = async (id: string) => {
-- 
cgit v1.2.3

