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:
mesalogo
2026-10-03 05:53:10 +08:00
parent 169941ceda
commit 3c31f0b499
13 changed files with 908 additions and 56 deletions
+5 -2
View File
@@ -5404,6 +5404,9 @@ describe('registerIpcHandlers agent terminal state', () => {
),
listConversations: vi.fn<() => ConversationSnapshot[]>(() => []),
listConversationSummaries: vi.fn<(ids?: string[]) => ConversationSnapshot[]>(() => []),
// The readonly-worker variants delegate to the synchronous mocks.
listConversationSummariesAsync: vi.fn(async (ids?: string[]) => assistantDatabase.listConversationSummaries(ids)),
getConversationAsync: vi.fn(async (conversationId: string) => assistantDatabase.getConversation(conversationId)),
listRecoverableRemoteTasks: vi.fn<
() => Array<{
taskId: string
@@ -8221,10 +8224,10 @@ describe('registerIpcHandlers agent terminal state', () => {
harness.recoveryGetHandler?.(event)
await vi.waitFor(() => expect(ready.size).toBe(2))
await vi.waitFor(() => expect(list().every(c => c.activeRequest?.questions.length === 1)).toBe(true))
const summaries = electronMocks.handlers.get(ipcChannels.conversationsListSummaries)!(event, { detailIds: [] }) as ConversationSnapshot[]
const summaries = await electronMocks.handlers.get(ipcChannels.conversationsListSummaries)!(event, { detailIds: [] }) as ConversationSnapshot[]
expect(summaries).toEqual(list())
for (const snapshot of summaries) {
expect(electronMocks.handlers.get(ipcChannels.conversationsGet)!(event, snapshot.id)).toEqual(snapshot)
expect(await electronMocks.handlers.get(ipcChannels.conversationsGet)!(event, snapshot.id)).toEqual(snapshot)
}
expect(harness.assistantDatabase.appendRemoteConversationTaskEventOnce).not.toHaveBeenCalled()
const update = settingsKind === 'runtime'