chore: rebuild release package
This commit is contained in:
40
server.js
40
server.js
@@ -2895,6 +2895,26 @@ function isCodexLikeAgent(agent) {
|
||||
return normalized === 'codex' || normalized === 'codexapp';
|
||||
}
|
||||
|
||||
function normalizeTitleHistory(history) {
|
||||
if (!Array.isArray(history)) return [];
|
||||
const normalized = [];
|
||||
history.forEach((event) => {
|
||||
if (!event || typeof event !== 'object') return;
|
||||
const title = String(event.title || '').replace(/\s+/g, ' ').trim().slice(0, 120);
|
||||
const changedAtMs = Date.parse(String(event.changedAt || ''));
|
||||
const messageIndex = Number(event.messageIndex);
|
||||
const source = String(event.source || '').trim().toLowerCase();
|
||||
if (!title || !Number.isFinite(changedAtMs) || !Number.isFinite(messageIndex) || messageIndex < 0 || source !== 'llm') return;
|
||||
normalized.push({
|
||||
title,
|
||||
changedAt: new Date(changedAtMs).toISOString(),
|
||||
messageIndex: Math.trunc(messageIndex),
|
||||
source: 'llm',
|
||||
});
|
||||
});
|
||||
return normalized.slice(-100);
|
||||
}
|
||||
|
||||
function normalizeSession(session) {
|
||||
if (!session || typeof session !== 'object') return session;
|
||||
session.agent = normalizeAgent(session.agent);
|
||||
@@ -2906,6 +2926,7 @@ function normalizeSession(session) {
|
||||
} else if (Object.prototype.hasOwnProperty.call(session, 'titleSource')) {
|
||||
delete session.titleSource;
|
||||
}
|
||||
session.titleHistory = normalizeTitleHistory(session.titleHistory);
|
||||
if (!Object.prototype.hasOwnProperty.call(session, 'claudeSessionId')) session.claudeSessionId = null;
|
||||
if (!Object.prototype.hasOwnProperty.call(session, 'codexThreadId')) session.codexThreadId = null;
|
||||
if (!Object.prototype.hasOwnProperty.call(session, 'codexAppThreadId')) session.codexAppThreadId = null;
|
||||
@@ -7051,6 +7072,7 @@ function handleSlashCommand(ws, text, sessionId, fallbackAgent, source = {}) {
|
||||
cleanRunDir(sessionId);
|
||||
}
|
||||
session.messages = [];
|
||||
session.titleHistory = [];
|
||||
clearRuntimeSessionId(session);
|
||||
session.updated = new Date().toISOString();
|
||||
saveSession(session);
|
||||
@@ -7059,6 +7081,7 @@ function handleSlashCommand(ws, text, sessionId, fallbackAgent, source = {}) {
|
||||
sessionId: session.id,
|
||||
messages: [],
|
||||
title: session.title,
|
||||
titleHistory: session.titleHistory,
|
||||
pinnedAt: session.pinnedAt || null,
|
||||
...publicTitleMetadata(session),
|
||||
mode: session.permissionMode || 'yolo',
|
||||
@@ -7295,6 +7318,17 @@ function setCurrentConversationTitle(args = {}, sourceSessionId = '') {
|
||||
}
|
||||
|
||||
const changed = previousTitle !== normalizedTitle;
|
||||
let titleEvent = null;
|
||||
if (changed) {
|
||||
titleEvent = {
|
||||
title: normalizedTitle,
|
||||
changedAt: new Date().toISOString(),
|
||||
messageIndex: Array.isArray(session.messages) ? session.messages.length : 0,
|
||||
source: 'llm',
|
||||
};
|
||||
session.titleHistory = normalizeTitleHistory([...(session.titleHistory || []), titleEvent]);
|
||||
titleEvent = session.titleHistory[session.titleHistory.length - 1] || null;
|
||||
}
|
||||
session.title = normalizedTitle;
|
||||
session.titleSource = 'llm';
|
||||
saveSession(session);
|
||||
@@ -7302,6 +7336,7 @@ function setCurrentConversationTitle(args = {}, sourceSessionId = '') {
|
||||
type: 'session_renamed',
|
||||
sessionId: session.id,
|
||||
title: session.title,
|
||||
...(titleEvent ? { titleEvent } : {}),
|
||||
...publicTitleMetadata(session),
|
||||
});
|
||||
broadcastSessionList();
|
||||
@@ -7314,6 +7349,7 @@ function setCurrentConversationTitle(args = {}, sourceSessionId = '') {
|
||||
title: session.title,
|
||||
previousTitle,
|
||||
lockedByUser: false,
|
||||
...(titleEvent ? { titleEvent } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7461,6 +7497,7 @@ function buildSessionInfoPayload(session) {
|
||||
sessionId: session.id,
|
||||
messages,
|
||||
title: session.title,
|
||||
titleHistory: session.titleHistory,
|
||||
pinnedAt: session.pinnedAt || null,
|
||||
...publicTitleMetadata(session),
|
||||
mode: session.permissionMode || 'yolo',
|
||||
@@ -7677,6 +7714,7 @@ function handleLoadSession(ws, msg) {
|
||||
sessionId: refreshedSession.id,
|
||||
messages: recentMessages,
|
||||
title: refreshedSession.title,
|
||||
titleHistory: refreshedSession.titleHistory,
|
||||
pinnedAt: refreshedSession.pinnedAt || null,
|
||||
...publicTitleMetadata(refreshedSession),
|
||||
mode: refreshedSession.permissionMode || 'yolo',
|
||||
@@ -10782,6 +10820,7 @@ function handleImportNativeSession(ws, msg) {
|
||||
sessionId: id,
|
||||
messages: transportMessages,
|
||||
title: session.title,
|
||||
titleHistory: session.titleHistory,
|
||||
pinnedAt: session.pinnedAt || null,
|
||||
...publicTitleMetadata(session),
|
||||
mode: session.permissionMode,
|
||||
@@ -10955,6 +10994,7 @@ function handleImportCodexSession(ws, msg) {
|
||||
sessionId: id,
|
||||
messages: transportMessages,
|
||||
title: session.title,
|
||||
titleHistory: session.titleHistory,
|
||||
pinnedAt: session.pinnedAt || null,
|
||||
...publicTitleMetadata(session),
|
||||
mode: session.permissionMode,
|
||||
|
||||
Reference in New Issue
Block a user