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:
@@ -5344,6 +5344,25 @@ export class AssistantDatabase {
|
||||
this.writeActivityHistoryPlan(database, (previous) => planActivityHistoryUpdate(input, previous))
|
||||
}
|
||||
|
||||
/** Deletes every activity record in one transaction. */
|
||||
clearActivityHistory(): void {
|
||||
const database = this.requireDatabase()
|
||||
database.exec('BEGIN IMMEDIATE')
|
||||
try {
|
||||
database.exec('DELETE FROM activity_history_records')
|
||||
database.exec(
|
||||
`UPDATE activity_history
|
||||
SET record_order_json = '[]', legacy_history_may_be_incomplete = 0
|
||||
WHERE singleton = 1`
|
||||
)
|
||||
database.exec('COMMIT')
|
||||
} catch (error) {
|
||||
database.exec('ROLLBACK')
|
||||
throw error
|
||||
}
|
||||
this.activityHistoryCache = undefined
|
||||
}
|
||||
|
||||
/** The cached committed state, when no other connection committed since. */
|
||||
private committedActivityHistoryState(database: DatabaseSync): ActivityHistoryState | undefined {
|
||||
const cache = this.activityHistoryCache
|
||||
|
||||
Reference in New Issue
Block a user