fix profile-aware session history actions (#1011)

This commit is contained in:
ekko
2026-05-25 12:32:42 +08:00
committed by GitHub
parent bbb8b1d536
commit 56c6cf3e2d
7 changed files with 211 additions and 58 deletions
+1
View File
@@ -75,6 +75,7 @@ function shouldAttachProfileHeader(path: string, options: RequestInit): boolean
function isProfileWideSessionCollection(pathname: string): boolean {
return pathname === '/api/hermes/sessions' ||
pathname === '/api/hermes/sessions/batch-delete' ||
pathname === '/api/hermes/search/sessions' ||
pathname === '/api/hermes/sessions/search' ||
pathname === '/api/hermes/sessions/conversations'
+15 -2
View File
@@ -122,13 +122,26 @@ export async function deleteSession(id: string, profile?: string | null): Promis
}
}
export async function batchDeleteSessions(ids: string[]): Promise<{ deleted: number; failed: number; errors: Array<{ id: string; error: string }> }> {
export interface BatchDeleteSessionTarget {
id: string
profile?: string | null
}
export async function batchDeleteSessions(targets: Array<string | BatchDeleteSessionTarget>): Promise<{ deleted: number; failed: number; errors: Array<{ id: string; error: string }> }> {
try {
const sessions = targets.map(target =>
typeof target === 'string'
? { id: target }
: { id: target.id, profile: target.profile || undefined },
)
const res = await request<{ deleted: number; failed: number; errors: Array<{ id: string; error: string }> }>(
'/api/hermes/sessions/batch-delete',
{
method: 'POST',
body: JSON.stringify({ ids }),
body: JSON.stringify({
ids: sessions.map(session => session.id),
sessions,
}),
}
)
return res