fix(data): populate aiConversationCount from conversations.db instead of returning 0

The /_web/sessions route never called getAIChatCountsBySession() to
enrich session DTOs, leaving aiConversationCount always 0 in the
data management UI. Use the existing enrichSession callback and
AIChatManager to fill real counts for both list and detail endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
diguaandCursor committed 2026-06-14 23:54:12 +08:00
1 parent d90a6e4bf7
commit 7afb31e679
2 files changed
+10 -2

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ export function getAllSessions(): any[] {
id: sessionId,
dbPath,
memberAvatar,
aiConversationCount: 0, // filled by IPC layer
aiConversationCount: 0,
})
}
@@ -13,7 +13,12 @@ export function registerSessionRoutes(server: FastifyInstance, ctx: HttpRouteCon
}
server.get('/_web/sessions', async () => {
return sessionService.listAnalysisSessions(adapter)
const aiChatCounts = ctx.aiChatManager?.getAIChatCountsBySession()
return sessionService.listAnalysisSessions(adapter, {
enrichSession: aiChatCounts?.size
? (dto) => ({ ...dto, aiConversationCount: aiChatCounts.get(dto.id) ?? 0 })
: undefined,
})
})
server.get<{ Params: { id: string } }>('/_web/sessions/:id', async (request) => {
@@ -21,6 +26,9 @@ export function registerSessionRoutes(server: FastifyInstance, ctx: HttpRouteCon
if (!session) {
throw Object.assign(new Error(`Session not found: ${request.params.id}`), { statusCode: 404 })
}
if (ctx.aiChatManager) {
session.aiConversationCount = ctx.aiChatManager.getAIChats(request.params.id).length
}
return session
})