fix: reduce activity history disk writes during streaming

Save only changed activity records instead of rewriting the entire history snapshot. Migrate existing history to schema 44 while preserving order and duplicate IDs.

Run unit tests with up to four workers and keep the configured integration phase serial. Include activity-history I/O, storage-upgrade, settings, and OpenCode isolation regression coverage.

Validation: 4 related test files / 123 tests passed; typecheck and lint passed.

Release note: Reduce disk writes while agent activity updates stream in, preserving existing activity history.
This commit is contained in:
mesalogo
2026-09-23 14:54:21 +08:00
parent 7d487f9326
commit 984f16f178
7 changed files with 452 additions and 22 deletions
@@ -96,7 +96,10 @@ describe('subagent progress storage', () => {
try {
legacy.prepare('UPDATE magic_note_entries SET content_json = ? WHERE id = ?')
.run(JSON.stringify(note.entries[0]!.content), note.entries[0]!.id)
legacy.exec('PRAGMA user_version = 37')
legacy.exec(`ALTER TABLE supervision_results DROP COLUMN graph_snapshot_json;
DROP TABLE activity_history_records;
ALTER TABLE activity_history RENAME COLUMN record_order_json TO records_json;
PRAGMA user_version = 37`)
} finally { legacy.close() }
expect(hasPendingAssistantStorageUpgrade(path)).toBe(true)
upgradeAssistantStorage(path, () => undefined)
@@ -408,6 +411,9 @@ describe('subagent progress storage', () => {
const expected: SubagentEvent[] = []
try {
legacy.exec(`ALTER TABLE conversations DROP COLUMN pinned;
ALTER TABLE supervision_results DROP COLUMN graph_snapshot_json;
DROP TABLE activity_history_records;
ALTER TABLE activity_history RENAME COLUMN record_order_json TO records_json;
PRAGMA user_version = ${sourceVersion}; BEGIN`)
const insert = legacy.prepare(
`INSERT INTO task_events(