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:
@@ -193,7 +193,11 @@ vi.mock("./TerminalPanel", () => ({
|
||||
|
||||
import App from "./App";
|
||||
import { ACTIVITY_STORAGE_KEY, type ActivityRecord } from "./activity-store";
|
||||
import { applyActivityChanges } from "../../shared/activity-history-reference";
|
||||
import {
|
||||
applyActivityChanges,
|
||||
referenceActivityPage,
|
||||
referenceActivitySummary,
|
||||
} from "../../shared/activity-history-reference";
|
||||
import type { ActivityHistoryUpdate } from "../../shared/assistant-contracts";
|
||||
import { changeUiLocale } from "./i18n";
|
||||
import { UiLocaleProvider } from "./i18n/UiLocaleProvider";
|
||||
@@ -689,6 +693,10 @@ const api: DesktopApi & RuntimeNativeClientApi = {
|
||||
clear: vi.fn(async () => {
|
||||
savedActivity = [];
|
||||
}),
|
||||
page: vi.fn(async (request) => referenceActivityPage(savedActivity, request)),
|
||||
summary: vi.fn(async (request) =>
|
||||
referenceActivitySummary(savedActivity, request.conversationIds)),
|
||||
reconcile: vi.fn(async () => 0),
|
||||
},
|
||||
usage: {
|
||||
getTokenSummary: vi.fn(async () => ({
|
||||
|
||||
Reference in New Issue
Block a user