mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-13 21:27:41 +02:00
[aidan] fix/chat-history: stop retaining unopened histories
This commit is contained in:
@@ -84,6 +84,10 @@ export interface AgentSession {
|
||||
cost_usd: number;
|
||||
tokens: { input: number; output: number };
|
||||
messages: AgentMessage[];
|
||||
/** Compact dashboard-list metadata; full messages are fetched when a chat opens. */
|
||||
last_message_preview?: string;
|
||||
first_user_message?: string;
|
||||
message_count?: number;
|
||||
pending_approvals: ApprovalRequest[];
|
||||
branches: Record<string, MessageBranch>;
|
||||
active_branch_id: string;
|
||||
|
||||
@@ -36,8 +36,13 @@ export function displayChatTitle(session: AgentSession | null | undefined): stri
|
||||
return session.name;
|
||||
}
|
||||
const firstUserMsg = session.messages?.find((m) => m.role === 'user');
|
||||
if (firstUserMsg && typeof firstUserMsg.content === 'string') {
|
||||
const truncated = truncateForTitle(firstUserMsg.content);
|
||||
const firstUserContent = firstUserMsg && typeof firstUserMsg.content === 'string'
|
||||
? firstUserMsg.content
|
||||
: session.messages.length === 0
|
||||
? session.first_user_message
|
||||
: undefined;
|
||||
if (firstUserContent) {
|
||||
const truncated = truncateForTitle(firstUserContent);
|
||||
if (truncated) return truncated;
|
||||
}
|
||||
return session.mode === 'view-builder' ? 'Untitled App' : SESSION_NAME_PLACEHOLDER;
|
||||
|
||||
Reference in New Issue
Block a user