perf(activity): page, summarize and reconcile activity history in Main by index
Schema 57 rebuilds activity_history_records with order_seq (newer = larger;
a move to the front assigns a new maximum) and stored generated columns
(record_id, occurrence, status, status_group, kind, request_id,
conversation_id, project_id, created_at) with indexes. The order is migrated
from record_order_json exactly; legacy duplicates keep their occurrence and
only the first is shown. record_order_json is no longer written.
ActivityHistoryRepository owns the SQL: page({before, limit <= 500, filter,
projectId, conversationId}) newest first by index, summary() with the counts
and conversation titles/status the Activity page derived from the full list,
reconcile() joined with tasks with a renderer-localized detail line, update()
applied directly in SQL without reading the history, replace() for the
legacy migration, clear(). New activity-history:page/summary/reconcile IPC
with zod validation; page and summary run on the readonly worker.
perf:main measures 24,000 records: startup load 106 ms on Main (14 MB) ->
first page + summary 13.5 ms on the worker (0.6 ms loop block, 114 KB).
This commit is contained in:
@@ -44,7 +44,12 @@ import {
|
||||
type AssistantTask,
|
||||
type ExecutionStats,
|
||||
type ExecutionStatsInput,
|
||||
type ActivityHistoryPage,
|
||||
type ActivityHistoryPageRequest,
|
||||
type ActivityHistoryReconcileRequest,
|
||||
type ActivityHistorySnapshot,
|
||||
type ActivityHistorySummary,
|
||||
type ActivityHistorySummaryRequest,
|
||||
type ActivityHistoryUpdate,
|
||||
type ActivityRecord,
|
||||
type TokenUsageSummary,
|
||||
@@ -2167,6 +2172,15 @@ export type DesktopApi = {
|
||||
update: (update: ActivityHistoryUpdate) => Promise<void>
|
||||
/** Deletes the whole history in one transaction. */
|
||||
clear: () => Promise<void>
|
||||
/** One page of shown records, newest first (see activityHistoryPageRequestSchema). */
|
||||
page: (request: ActivityHistoryPageRequest) => Promise<ActivityHistoryPage>
|
||||
/** Counts and conversation titles/status over the whole history. */
|
||||
summary: (request: ActivityHistorySummaryRequest) => Promise<ActivityHistorySummary>
|
||||
/**
|
||||
* Ends records left pending/running by requests that are no longer
|
||||
* active, against the stored tasks; returns how many changed.
|
||||
*/
|
||||
reconcile: (request: ActivityHistoryReconcileRequest) => Promise<number>
|
||||
}
|
||||
usage: {
|
||||
getTokenSummary: () => Promise<TokenUsageSummary>
|
||||
|
||||
Reference in New Issue
Block a user