mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(session-index): honor selected session IDs in CLI batch summary generation
This commit is contained in:
1 parent
46204db9b8
commit
45dfa5026f
1 file changed
+21
-17
@@ -119,25 +119,29 @@ export class FetchSessionIndexAdapter implements SessionIndexAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
async generateSummaries(
|
||||
dbSessionId: string,
|
||||
_chatSessionIds: number[],
|
||||
locale?: string
|
||||
): Promise<BatchSummaryResult> {
|
||||
try {
|
||||
const resp = await fetch(`/_web/sessions/${dbSessionId}/summaries/generate-all`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ locale }),
|
||||
})
|
||||
const result = await resp.json()
|
||||
if (!resp.ok) {
|
||||
return { success: 0, failed: 0, skipped: 0 }
|
||||
async generateSummaries(dbSessionId: string, chatSessionIds: number[], locale?: string): Promise<BatchSummaryResult> {
|
||||
// Call generateSummary individually for each selected session so that only
|
||||
// the requested IDs are processed, matching the Electron adapter's behaviour.
|
||||
// Previously this called /generate-all and ignored chatSessionIds entirely,
|
||||
// which caused every session in the database to be regenerated.
|
||||
let success = 0
|
||||
let failed = 0
|
||||
const skipped = 0
|
||||
|
||||
for (const chatSessionId of chatSessionIds) {
|
||||
try {
|
||||
const result = await this.generateSummary(dbSessionId, chatSessionId, locale)
|
||||
if (result.success) {
|
||||
success++
|
||||
} else {
|
||||
failed++
|
||||
}
|
||||
} catch {
|
||||
failed++
|
||||
}
|
||||
return { success: result.success ?? 0, failed: result.failed ?? 0, skipped: result.skipped ?? 0 }
|
||||
} catch {
|
||||
return { success: 0, failed: 0, skipped: 0 }
|
||||
}
|
||||
|
||||
return { success, failed, skipped }
|
||||
}
|
||||
|
||||
async checkCanGenerateSummary(
|
||||
|
||||
Reference in new issue
Block a user