perf: read conversation lists in the readonly worker and diff activity history saves
conversations:list-summaries and conversations:get run on the readonly query worker. Activity history replace validates and serializes only changed records; a new activity-history:update IPC writes one record. Adds npm run perf:main.
This commit is contained in:
@@ -100,10 +100,42 @@ export const activityHistorySnapshotSchema = z
|
||||
})
|
||||
.strict()
|
||||
|
||||
/**
|
||||
* Incremental activity history change (PERF-15). Changes apply in order to the
|
||||
* stored, newest-first list; the result is identical to `replace` with the
|
||||
* same final list. A record is identified by its `id` (first occurrence when
|
||||
* legacy history contains duplicate IDs).
|
||||
* - `upsert` + `position: 'front'` inserts the record, or moves the existing
|
||||
* record to the front with the new content (renderer `upsertActivityRecord`).
|
||||
* - `upsert` + `position: 'in-place'` replaces the existing record where it
|
||||
* is; a record that does not exist yet is inserted at the front.
|
||||
* - `remove` deletes every record with the ID.
|
||||
*/
|
||||
export const activityHistoryChangeSchema = z.discriminatedUnion('type', [
|
||||
z.object({
|
||||
type: z.literal('upsert'),
|
||||
record: activityRecordSchema,
|
||||
position: z.enum(['front', 'in-place'])
|
||||
}).strict(),
|
||||
z.object({
|
||||
type: z.literal('remove'),
|
||||
id: z.string().min(1).max(256)
|
||||
}).strict()
|
||||
])
|
||||
|
||||
export const activityHistoryUpdateSchema = z
|
||||
.object({
|
||||
changes: z.array(activityHistoryChangeSchema).max(20_000),
|
||||
legacyHistoryMayBeIncomplete: z.boolean().optional()
|
||||
})
|
||||
.strict()
|
||||
|
||||
export type ActivityRecord = z.infer<typeof activityRecordSchema>
|
||||
export type ActivityHistorySnapshot = z.infer<
|
||||
typeof activityHistorySnapshotSchema
|
||||
>
|
||||
export type ActivityHistoryChange = z.infer<typeof activityHistoryChangeSchema>
|
||||
export type ActivityHistoryUpdate = z.infer<typeof activityHistoryUpdateSchema>
|
||||
|
||||
export const projectExecutionSpaceSchema = z.discriminatedUnion(
|
||||
'kind',
|
||||
|
||||
@@ -45,6 +45,7 @@ import {
|
||||
type ExecutionStats,
|
||||
type ExecutionStatsInput,
|
||||
type ActivityHistorySnapshot,
|
||||
type ActivityHistoryUpdate,
|
||||
type ActivityRecord,
|
||||
type TokenUsageSummary,
|
||||
type ConversationSnapshot,
|
||||
@@ -2158,6 +2159,12 @@ export type DesktopApi = {
|
||||
records: ActivityRecord[],
|
||||
legacyHistoryMayBeIncomplete: boolean
|
||||
) => Promise<void>
|
||||
/**
|
||||
* Incremental save (PERF-15): only the changed records cross IPC and are
|
||||
* written. Optional until renderer mocks adopt it; the preload always
|
||||
* provides it.
|
||||
*/
|
||||
update?: (update: ActivityHistoryUpdate) => Promise<void>
|
||||
}
|
||||
usage: {
|
||||
getTokenSummary: () => Promise<TokenUsageSummary>
|
||||
|
||||
@@ -254,6 +254,7 @@ export const ipcChannels = {
|
||||
tasksSetStatus: 'tasks:set-status',
|
||||
activityHistoryGet: 'activity-history:get',
|
||||
activityHistoryReplace: 'activity-history:replace',
|
||||
activityHistoryUpdate: 'activity-history:update',
|
||||
tokenUsageSummary: 'usage:token-summary',
|
||||
tokenUsageChanged: 'usage:token-changed',
|
||||
artifactsList: 'artifacts:list',
|
||||
|
||||
Reference in New Issue
Block a user