From ba70ad8e81443916224f9808c50cd29bf283c4e1 Mon Sep 17 00:00:00 2001 From: Haileyesus Dessie <118998054+blackmammoth@users.noreply.github.com> Date: Wed, 31 Dec 2025 19:10:33 +0300 Subject: [PATCH 1/2] fix: navigate to the correct session ID when updating session state --- src/components/ChatInterface.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/ChatInterface.jsx b/src/components/ChatInterface.jsx index 337513c..e8b0a40 100644 --- a/src/components/ChatInterface.jsx +++ b/src/components/ChatInterface.jsx @@ -2971,12 +2971,20 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess if (latestMessage.sessionId && !currentSessionId) { sessionStorage.setItem('pendingSessionId', latestMessage.sessionId); + // Mark as system change to prevent clearing messages when session ID updates + setIsSystemSessionChange(true); + // Session Protection: Replace temporary "new-session-*" identifier with real session ID // This maintains protection continuity - no gap between temp ID and real ID // The temporary session is removed and real session is marked as active if (onReplaceTemporarySession) { onReplaceTemporarySession(latestMessage.sessionId); } + + // Navigate to the new session to ensure URL and selectedSession are updated + if (onNavigateToSession) { + onNavigateToSession(latestMessage.sessionId); + } } break; From 9efe433d99215838f6bbe9f796959c0066121f72 Mon Sep 17 00:00:00 2001 From: Haileyesus Dessie <118998054+blackmammoth@users.noreply.github.com> Date: Mon, 5 Jan 2026 16:35:20 +0300 Subject: [PATCH 2/2] fix: get codex sessions in windows; improve message counting logic; fix session navigation in ChatInterface --- server/openai-codex.js | 3 ++- server/projects.js | 13 +++++++++---- src/components/ChatInterface.jsx | 12 ++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/server/openai-codex.js b/server/openai-codex.js index ddc023f..d83d39b 100644 --- a/server/openai-codex.js +++ b/server/openai-codex.js @@ -280,7 +280,8 @@ export async function queryCodex(command, options = {}, ws) { // Send completion event sendMessage(ws, { type: 'codex-complete', - sessionId: currentSessionId + sessionId: currentSessionId, + actualSessionId: thread.id }); } catch (error) { diff --git a/server/projects.js b/server/projects.js index a4efb10..ff7a8d1 100755 --- a/server/projects.js +++ b/server/projects.js @@ -1206,7 +1206,12 @@ async function getCodexSessions(projectPath) { const sessionData = await parseCodexSessionFile(filePath); // Check if this session matches the project path - if (sessionData && sessionData.cwd === projectPath) { + // Handle Windows long paths with \\?\ prefix + const sessionCwd = sessionData?.cwd || ''; + const cleanSessionCwd = sessionCwd.startsWith('\\\\?\\') ? sessionCwd.slice(4) : sessionCwd; + const cleanProjectPath = projectPath.startsWith('\\\\?\\') ? projectPath.slice(4) : projectPath; + + if (sessionData && (sessionData.cwd === projectPath || cleanSessionCwd === cleanProjectPath || path.relative(cleanSessionCwd, cleanProjectPath) === '')) { sessions.push({ id: sessionData.id, summary: sessionData.summary || 'Codex Session', @@ -1273,12 +1278,12 @@ async function parseCodexSessionFile(filePath) { // Count messages and extract user messages for summary if (entry.type === 'event_msg' && entry.payload?.type === 'user_message') { messageCount++; - if (entry.payload.text) { - lastUserMessage = entry.payload.text; + if (entry.payload.message) { + lastUserMessage = entry.payload.message; } } - if (entry.type === 'response_item' && entry.payload?.type === 'message') { + if (entry.type === 'response_item' && entry.payload?.type === 'message' && entry.payload.role === 'assistant') { messageCount++; } diff --git a/src/components/ChatInterface.jsx b/src/components/ChatInterface.jsx index e8b0a40..5d86001 100644 --- a/src/components/ChatInterface.jsx +++ b/src/components/ChatInterface.jsx @@ -2980,11 +2980,6 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess if (onReplaceTemporarySession) { onReplaceTemporarySession(latestMessage.sessionId); } - - // Navigate to the new session to ensure URL and selectedSession are updated - if (onNavigateToSession) { - onNavigateToSession(latestMessage.sessionId); - } } break; @@ -3538,8 +3533,13 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess } const codexPendingSessionId = sessionStorage.getItem('pendingSessionId'); + const codexActualSessionId = latestMessage.actualSessionId || codexPendingSessionId; if (codexPendingSessionId && !currentSessionId) { - setCurrentSessionId(codexPendingSessionId); + setCurrentSessionId(codexActualSessionId); + setIsSystemSessionChange(true); + if (onNavigateToSession) { + onNavigateToSession(codexActualSessionId); + } sessionStorage.removeItem('pendingSessionId'); console.log('Codex session complete, ID set to:', codexPendingSessionId); }