mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
perf: optimize /api/sessions endpoint response payload
Slim down SessionSummary responses to reduce payload size: - Replace full todos array with computed todoProgress summary - Replace metadata object with only necessary fields (name, path, summary.text) - Remove unused fields (thinking, createdAt, permissionMode, modelMode) - Refactor sorting to work on full Session objects before mapping This significantly reduces /api/sessions response size, especially for sessions with many todos or tools.
This commit is contained in:
@@ -58,11 +58,9 @@ function getSessionTitle(session: SessionSummary): string {
|
||||
}
|
||||
|
||||
function getTodoProgress(session: SessionSummary): { completed: number; total: number } | null {
|
||||
if (!session.todos || session.todos.length === 0) return null
|
||||
const total = session.todos.length
|
||||
const completed = session.todos.filter(t => t.status === 'completed').length
|
||||
if (completed === total) return null
|
||||
return { completed, total }
|
||||
if (!session.todoProgress) return null
|
||||
if (session.todoProgress.completed === session.todoProgress.total) return null
|
||||
return session.todoProgress
|
||||
}
|
||||
|
||||
export function SessionList(props: {
|
||||
|
||||
Reference in New Issue
Block a user