feat(jsonl): enhance message counting logic for AIGroup interactions
- Added logic to await the first main-thread assistant message after a UserGroup to accurately count AIGroup messages. - Updated tests to reflect the new message counting behavior, ensuring correct results in session file analysis.
This commit is contained in:
parent
c9ed63af55
commit
44a499e62c
2 changed files with 12 additions and 1 deletions
|
|
@ -328,6 +328,8 @@ export async function analyzeSessionFileMetadata(
|
|||
let firstUserMessage: { text: string; timestamp: string } | null = null;
|
||||
let firstCommandMessage: { text: string; timestamp: string } | null = null;
|
||||
let messageCount = 0;
|
||||
// After a UserGroup, await the first main-thread assistant message to count the AIGroup
|
||||
let awaitingAIGroup = false;
|
||||
let gitBranch: string | null = null;
|
||||
|
||||
let activityIndex = 0;
|
||||
|
|
@ -357,6 +359,15 @@ export async function analyzeSessionFileMetadata(
|
|||
|
||||
if (isParsedUserChunkMessage(parsed)) {
|
||||
messageCount++;
|
||||
awaitingAIGroup = true;
|
||||
} else if (
|
||||
awaitingAIGroup &&
|
||||
parsed.type === 'assistant' &&
|
||||
parsed.model !== '<synthetic>' &&
|
||||
!parsed.isSidechain
|
||||
) {
|
||||
messageCount++;
|
||||
awaitingAIGroup = false;
|
||||
}
|
||||
|
||||
if (!gitBranch && 'gitBranch' in entry && entry.gitBranch) {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ describe('jsonl', () => {
|
|||
|
||||
expect(result.firstUserMessage?.text).toBe('hello world');
|
||||
expect(result.firstUserMessage?.timestamp).toBe('2026-01-01T00:00:00.000Z');
|
||||
expect(result.messageCount).toBe(1);
|
||||
expect(result.messageCount).toBe(2);
|
||||
expect(result.isOngoing).toBe(true);
|
||||
expect(result.gitBranch).toBe('feature/test');
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Reference in a new issue