mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-01-23 09:57:32 +00:00
Merge pull request #275 from siteboon/fix/navigate-to-correct-session-id-using-codex
fix: navigate to the correct session ID when updating session state
This commit is contained in:
@@ -280,7 +280,8 @@ export async function queryCodex(command, options = {}, ws) {
|
|||||||
// Send completion event
|
// Send completion event
|
||||||
sendMessage(ws, {
|
sendMessage(ws, {
|
||||||
type: 'codex-complete',
|
type: 'codex-complete',
|
||||||
sessionId: currentSessionId
|
sessionId: currentSessionId,
|
||||||
|
actualSessionId: thread.id
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1206,7 +1206,12 @@ async function getCodexSessions(projectPath) {
|
|||||||
const sessionData = await parseCodexSessionFile(filePath);
|
const sessionData = await parseCodexSessionFile(filePath);
|
||||||
|
|
||||||
// Check if this session matches the project path
|
// 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({
|
sessions.push({
|
||||||
id: sessionData.id,
|
id: sessionData.id,
|
||||||
summary: sessionData.summary || 'Codex Session',
|
summary: sessionData.summary || 'Codex Session',
|
||||||
@@ -1273,12 +1278,12 @@ async function parseCodexSessionFile(filePath) {
|
|||||||
// Count messages and extract user messages for summary
|
// Count messages and extract user messages for summary
|
||||||
if (entry.type === 'event_msg' && entry.payload?.type === 'user_message') {
|
if (entry.type === 'event_msg' && entry.payload?.type === 'user_message') {
|
||||||
messageCount++;
|
messageCount++;
|
||||||
if (entry.payload.text) {
|
if (entry.payload.message) {
|
||||||
lastUserMessage = entry.payload.text;
|
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++;
|
messageCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2971,6 +2971,9 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess
|
|||||||
if (latestMessage.sessionId && !currentSessionId) {
|
if (latestMessage.sessionId && !currentSessionId) {
|
||||||
sessionStorage.setItem('pendingSessionId', latestMessage.sessionId);
|
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
|
// Session Protection: Replace temporary "new-session-*" identifier with real session ID
|
||||||
// This maintains protection continuity - no gap between temp ID and real 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
|
// The temporary session is removed and real session is marked as active
|
||||||
@@ -3530,8 +3533,13 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess
|
|||||||
}
|
}
|
||||||
|
|
||||||
const codexPendingSessionId = sessionStorage.getItem('pendingSessionId');
|
const codexPendingSessionId = sessionStorage.getItem('pendingSessionId');
|
||||||
|
const codexActualSessionId = latestMessage.actualSessionId || codexPendingSessionId;
|
||||||
if (codexPendingSessionId && !currentSessionId) {
|
if (codexPendingSessionId && !currentSessionId) {
|
||||||
setCurrentSessionId(codexPendingSessionId);
|
setCurrentSessionId(codexActualSessionId);
|
||||||
|
setIsSystemSessionChange(true);
|
||||||
|
if (onNavigateToSession) {
|
||||||
|
onNavigateToSession(codexActualSessionId);
|
||||||
|
}
|
||||||
sessionStorage.removeItem('pendingSessionId');
|
sessionStorage.removeItem('pendingSessionId');
|
||||||
console.log('Codex session complete, ID set to:', codexPendingSessionId);
|
console.log('Codex session complete, ID set to:', codexPendingSessionId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user