mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
dim old conversation on new chat initiation and remove sessionId underscore convention
This commit is contained in:
1 parent
9352b70df8
commit
5fc96c9007
2 files changed
+13
-16
No files matched your search
@@ -795,18 +795,15 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
)}
|
||||
|
||||
{!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<ChatPaneRef, ChatPaneProps>(({
|
||||
|
||||
{/* 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 ? (
|
||||
<SessionDivider key="trailing-divider" />
|
||||
) : null;
|
||||
|
||||
@@ -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<string, Tool<unknown>>;
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user