perf: track execution duration by state and bound summary I/O

This commit is contained in:
mesalogo
2026-10-04 16:21:55 +08:00
parent 2c2b6c31eb
commit 4d18794e74
31 changed files with 987 additions and 1397 deletions
+7 -8
View File
@@ -14,17 +14,16 @@ export const executionStatsInputSchema = z.union([
])
export type ExecutionStatsInput = z.infer<typeof executionStatsInputSchema>
export interface ExecutionStats {
/** Sum of evidenced top-level reply intervals, including tools and approvals. */
/** Accumulated running time, including open segments through asOf. */
durationMs: number
requestCount: number
/** Requests/replies with missing timing evidence; confirmed live intervals are complete as of asOf. */
incompleteRequestCount: number
/** Requests currently leased by Main; does not authorize renderer extrapolation. */
activeRequestCount: number
/** Epoch milliseconds at query time. */
/** Number of open segments; the UI adds (now - asOf) * runningCount. */
runningCount: number
/** Pre-timing history or an interrupted segment has unknown duration. */
incomplete: boolean
/** Main epoch milliseconds at snapshot time. */
asOf: number
/** Project card totals; empty for conversation queries. */
taskDurations: Array<{ id: string; durationMs: number; incompleteRequestCount: number }>
taskDurations: Array<{ id: string; durationMs: number; runningCount: number; incomplete: boolean }>
}
export const interactiveWorkModes = ['ask', 'execute'] as const
export const workModeSchema = z.enum(interactiveWorkModes)
+1
View File
@@ -2155,6 +2155,7 @@ export type DesktopApi = {
tasks: {
list: () => Promise<AssistantTask[]>
getExecutionStats: (input: ExecutionStatsInput) => Promise<ExecutionStats>
onExecutionStatsChanged: (listener: () => void) => () => void
setStatus: (
taskId: string,
status: Extract<AssistantTask['status'], 'completed' | 'cancelled'>
+1
View File
@@ -252,6 +252,7 @@ export const ipcChannels = {
workspacePathOpen: 'workspace:path:open',
tasksList: 'tasks:list',
tasksExecutionStats: 'tasks:execution-stats',
tasksExecutionStatsChanged: 'tasks:execution-stats-changed',
tasksSetStatus: 'tasks:set-status',
activityHistoryGet: 'activity-history:get',
activityHistoryReplace: 'activity-history:replace',