perf(core): cache AgentStore SQLite connection per project

The dashboard re-instantiates AgentStore on every /api/agents request, and
each instance was opening a fresh Database — re-running schema migrations
and PRAGMA integrity_check on the full file. On a multi-hundred-MB DB that
was 3-7s per request and leaked file handles. Sharing a cached Database
keyed by rootDir reduces it to a one-time process cost.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-03 02:02:09 -07:00
parent 85ec574c25
commit 41bb6be0f8
2 changed files with 36 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@runfusion/fusion": patch
---
Cache the AgentStore SQLite connection per project so the dashboard no longer reopens the database, re-runs migrations, and re-executes `PRAGMA integrity_check` on every `/api/agents` request. On large project databases this turned a sub-100ms call into multi-second latency that bled into every dashboard view fetching the agent list.