From 5fc96c90070c0b614d75057bca13cc00457ab83c Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Sun, 11 Jan 2026 12:10:11 -0800 Subject: [PATCH] dim old conversation on new chat initiation and remove sessionId underscore convention --- src/components/Shakespeare/ChatPane.tsx | 15 ++++++--------- src/lib/SessionManager.ts | 14 +++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index cc87075a..d54d32cf 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -795,18 +795,15 @@ export const ChatPane = forwardRef(({ )} {!isLoadingHistory && displayMessages.map((message, index) => { - // Get the current and last session IDs to derive boundaries - const currentSessionId = (message as DisplayMessage)._sessionId; - const prevSessionId = index > 0 ? (displayMessages[index - 1] as DisplayMessage)._sessionId : undefined; - const lastSessionId = displayMessages.length > 0 - ? (displayMessages[displayMessages.length - 1] as DisplayMessage)._sessionId - : undefined; + // Get the current message's session ID and compare to previous + const currentSessionId = (message as DisplayMessage).sessionId; + const prevSessionId = index > 0 ? (displayMessages[index - 1] as DisplayMessage).sessionId : undefined; // Show divider when session changes (not on first message) const showDivider = index > 0 && currentSessionId !== prevSessionId; - // Determine if this message is from an older session - const isOlderSession = currentSessionId !== lastSessionId; + // Dim messages from older sessions (compare against current active session) + const isOlderSession = currentSessionId !== sessionName; // Find the corresponding tool call for tool messages let toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined = undefined; @@ -837,7 +834,7 @@ export const ChatPane = forwardRef(({ {/* Trailing session divider - shown when New Chat is clicked before sending a message */} {!isLoadingHistory && displayMessages.length > 0 && (() => { - const lastSessionId = (displayMessages[displayMessages.length - 1] as DisplayMessage)._sessionId; + const lastSessionId = (displayMessages[displayMessages.length - 1] as DisplayMessage).sessionId; return sessionName && lastSessionId && sessionName !== lastSessionId ? ( ) : null; diff --git a/src/lib/SessionManager.ts b/src/lib/SessionManager.ts index 7cc60523..90d5d48d 100644 --- a/src/lib/SessionManager.ts +++ b/src/lib/SessionManager.ts @@ -26,7 +26,7 @@ export type AIMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam | { /** AIMessage with session tracking for UI display */ export type DisplayMessage = AIMessage & { - _sessionId?: string; // Session identifier for grouping messages in UI + sessionId?: string; // Session identifier for grouping messages in UI }; export interface SessionState { @@ -35,7 +35,7 @@ export interface SessionState { customTools: Record>; maxSteps?: number; messages: AIMessage[]; // Current session messages (sent to AI) - displayMessages: DisplayMessage[]; // All messages from all sessions (for UI, with _sessionId) + displayMessages: DisplayMessage[]; // All messages from all sessions (for UI, with sessionId) streamingMessage?: { role: 'assistant'; content: string; @@ -126,13 +126,13 @@ export class SessionManager { const allSessions = await dotAI.readAllSessionHistories(); if (allSessions.length > 0) { - // Build displayMessages with _sessionId annotations + // Build displayMessages with sessionId annotations for (const session of allSessions) { - // Add all messages from this session with _sessionId annotation + // Add all messages from this session with sessionId annotation for (const msg of session.messages) { displayMessages.push({ ...msg as AIMessage, - _sessionId: session.sessionName, + sessionId: session.sessionName, }); } } @@ -222,7 +222,7 @@ export class SessionManager { session.messages.push(message); // Also add to display messages with session ID annotation (for UI) - const displayMessage: DisplayMessage = { ...message, _sessionId: session.sessionName }; + const displayMessage: DisplayMessage = { ...message, sessionId: session.sessionName }; session.displayMessages.push(displayMessage); session.lastActivity = new Date(); @@ -745,7 +745,7 @@ export class SessionManager { this.stopGeneration(projectId); - // Generate new session name - new messages will automatically get this _sessionId + // Generate new session name - new messages will automatically get this sessionId const newSessionName = DotAI.generateSessionName(); // Clear only the AI prompt messages (not display messages)