From 73d2680b83ccbdbd8dfec2d319533e98b379b830 Mon Sep 17 00:00:00 2001
From: bndw <ben@bdw.to>
Date: Wed, 4 Mar 2026 21:36:32 -0800
Subject: feat: Thread optional `phase` param into `db/sessions.ts::cre… (+7
 more)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- ✅ Thread optional `phase` param into `db/sessions.ts::createSession()`
- ✅ Thread optional `phase` param into `ipc/handlers.ts` sessions:create handler
- ✅ Thread optional `phase` param into `preload.ts` createSession API
- ✅ Update Plan phase system prompt to gracefully handle missing research.md
- ✅ Update Implement phase system prompt to gracefully handle missing plan.md
- ✅ Create `renderer/src/components/NewSessionModal.tsx`
- ✅ Update `App.tsx`: add modal state, split handler, add modal JSX
- ✅ Add modal CSS to `globals.css`
---
 renderer/src/App.tsx | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

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

diff --git a/renderer/src/App.tsx b/renderer/src/App.tsx
index 719faac..7c5c969 100644
--- a/renderer/src/App.tsx
+++ b/renderer/src/App.tsx
@@ -5,6 +5,7 @@ import { DocumentPane } from "./components/DocumentPane";
 import { ChatPane } from "./components/ChatPane";
 import { ActionBar } from "./components/ActionBar";
 import { SettingsPage } from "./components/SettingsPage";
+import { NewSessionModal } from "./components/NewSessionModal";
 import type { Project, Session, Message, Phase, TokenUsage } from "./types";
 import "./styles/globals.css";
 
@@ -66,6 +67,8 @@ export function App() {
   });
   const [error, setError] = useState<string | null>(null);
   const [showSettings, setShowSettings] = useState(false);
+  const [showNewSessionModal, setShowNewSessionModal] = useState(false);
+  const [newSessionProjectId, setNewSessionProjectId] = useState<string | null>(null);
   const [activeModel, setActiveModel] = useState<string | null>(null);
 
   const [theme, setTheme] = useState<Theme>(
@@ -451,12 +454,25 @@ export function App() {
     setSelectedProject(project);
   };
 
-  const handleCreateSession = async (projectId: string) => {
+  // Called by Sidebar when user clicks "+" — opens the phase-selection modal
+  const handleCreateSession = (projectId: string) => {
+    setNewSessionProjectId(projectId);
+    setShowNewSessionModal(true);
+  };
+
+  // Called by NewSessionModal when user clicks "Create"
+  const handleConfirmNewSession = async (phase: Phase) => {
+    setShowNewSessionModal(false);
+    const projectId = newSessionProjectId;
+    setNewSessionProjectId(null);
+    if (!projectId) return;
+
     const project = projects.find((p) => p.id === projectId);
     if (!project) return;
+
     const projectSessions = sessions.filter((s) => s.project_id === projectId);
     const name = `Session ${projectSessions.length + 1}`;
-    const session = await api.createSession(projectId, name);
+    const session = await api.createSession(projectId, name, phase);
     setSessions((prev) => [session, ...prev]);
     setSelectedProject(project);
     setSelectedSession(session);
@@ -623,6 +639,16 @@ export function App() {
       {showSettings && (
         <SettingsPage onClose={() => setShowSettings(false)} />
       )}
+
+      {showNewSessionModal && (
+        <NewSessionModal
+          onConfirm={handleConfirmNewSession}
+          onCancel={() => {
+            setShowNewSessionModal(false);
+            setNewSessionProjectId(null);
+          }}
+        />
+      )}
     </div>
   );
 }
-- 
cgit v1.2.3

