mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 00:05:27 +00:00
refactor: keep recent summary turns immutable
Signed-off-by: Afloat <ShuffleMonkey@163.com>
This commit is contained in:
1 parent
887eccc271
commit
11d5bc0a8a
1 file changed
+5
-5
@@ -54,11 +54,11 @@ function extractConversationText(transcriptPath) {
|
||||
}
|
||||
|
||||
const lines = content.split('\n').filter(Boolean);
|
||||
const turns = [];
|
||||
let turns = [];
|
||||
|
||||
// Older records cannot change a summary once its most recent turns are full.
|
||||
for (let index = lines.length - 1; index >= 0 && turns.length < MAX_TURNS; index--) {
|
||||
const entryTurns = [];
|
||||
let entryTurns = [];
|
||||
try {
|
||||
const entry = JSON.parse(lines[index]);
|
||||
const isUser = entry.type === 'user' || entry.message?.role === 'user';
|
||||
@@ -77,7 +77,7 @@ function extractConversationText(transcriptPath) {
|
||||
: '';
|
||||
const cleaned = text.replace(/\n+/g, ' ').trim();
|
||||
if (cleaned && !isClassifierNotice(cleaned)) {
|
||||
entryTurns.push({ role: 'User', text: cleaned.slice(0, 400) });
|
||||
entryTurns = [...entryTurns, { role: 'User', text: cleaned.slice(0, 400) }];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,13 @@ function extractConversationText(transcriptPath) {
|
||||
.replace(/\n+/g, ' ')
|
||||
.trim();
|
||||
if (textParts) {
|
||||
entryTurns.push({ role: 'Claude', text: textParts.slice(0, 600) });
|
||||
entryTurns = [...entryTurns, { role: 'Claude', text: textParts.slice(0, 600) }];
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Skip unparseable lines
|
||||
}
|
||||
turns.unshift(...entryTurns);
|
||||
turns = [...entryTurns, ...turns];
|
||||
}
|
||||
|
||||
if (turns.length === 0) return null;
|
||||
|
||||
Reference in new issue
Block a user