perf(activity): save activity history incrementally through an activity store and sync queue
The renderer no longer sends the whole history on every change. Domain actions on an external activity store update the list and queue the matching contract changes; activity-sync.ts flushes them every 250 ms via activityHistory.update (<= 20,000 per call), keeps failed changes queued in order with backoff retry, and flushes on quit and unmount. replace remains only for the legacy localStorage migration; clearing uses the new activityHistory.clear IPC. App's activity state is gone; ActivityPanel reads a selector. update is now required in the desktop API.
This commit is contained in:
@@ -110,6 +110,8 @@ export const activityHistorySnapshotSchema = z
|
||||
* - `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.
|
||||
* - `remove-duplicates` deletes every record but the first of each ID; the
|
||||
* renderer shows only the first (see `mergeActivityRecords`).
|
||||
*/
|
||||
export const activityHistoryChangeSchema = z.discriminatedUnion('type', [
|
||||
z.object({
|
||||
@@ -120,7 +122,8 @@ export const activityHistoryChangeSchema = z.discriminatedUnion('type', [
|
||||
z.object({
|
||||
type: z.literal('remove'),
|
||||
id: z.string().min(1).max(256)
|
||||
}).strict()
|
||||
}).strict(),
|
||||
z.object({ type: z.literal('remove-duplicates') }).strict()
|
||||
])
|
||||
|
||||
export const activityHistoryUpdateSchema = z
|
||||
|
||||
Reference in New Issue
Block a user