feat(memory): add agent memory health snapshot#1852
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds a memory health feature end-to-end: shared health contracts and keys, SQLite aggregation and read-model assembly, a new ChangesMemory Health Dashboard
Sequence Diagram(s)sequenceDiagram
participant MemoryManagerPanel
participant MemoryClient
participant Bridge
participant RoutesIndex
participant MemoryPresenter
participant AgentMemoryTable
participant AgentMemoryAuditTable
MemoryManagerPanel->>MemoryClient: getHealth(agentId)
MemoryClient->>Bridge: invoke(memory.getHealth, { agentId })
Bridge->>RoutesIndex: dispatchDeepchatRoute
RoutesIndex->>MemoryPresenter: getHealth(agentId)
MemoryPresenter->>AgentMemoryTable: getHealthStats(agentId)
MemoryPresenter->>AgentMemoryTable: countStaleEmbeddings(agentId, dim, fingerprint)
MemoryPresenter->>AgentMemoryTable: listTopAccessed(agentId, limit)
MemoryPresenter->>AgentMemoryAuditTable: getHealthAuditStats(agentId, scanLimit, failuresLimit)
MemoryPresenter-->>RoutesIndex: MemoryHealthDto
RoutesIndex-->>Bridge: { health }
Bridge-->>MemoryClient: result.health
MemoryClient-->>MemoryManagerPanel: MemoryHealthDto
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/renderer/settings/components/MemoryHealthSection.vue (1)
21-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse stable keys instead of translated labels.
metric.label/row.labelchanges with locale and is not guaranteed unique across translations. Add a stablekey/idfrom the metric name or DTO enum key, then bind:keyto that.Example pattern
- :key="metric.label" + :key="metric.key"{ + key: 'totalRows', label: t('settings.deepchatAgents.memoryManager.health.totalRows'), value: formatCount(health.totalRows) },Also applies to: 37-38, 52-53, 67-68, 84-85, 98-99, 161-162
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/renderer/settings/components/MemoryHealthSection.vue` around lines 21 - 22, The loops in MemoryHealthSection.vue are using translated labels as Vue keys, which can change by locale and may collide. Add a stable identifier such as `id` or `key` derived from the metric name/DTO enum in the data model, then update the `headlineMetrics` and row rendering loops to bind `:key` to that stable field instead of `metric.label` or `row.label`. Apply the same change to all repeated `v-for` blocks in this component that currently key off translated text.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/main/presenter/memoryPresenter.test.ts`:
- Around line 2188-2191: The test around setPersonaAnchor only asserts the first
persona-anchor emission because onMemoryChanged is cleared after the false call.
Update the memoryPresenter.test.ts case to assert that setPersonaAnchor('a',
v2!, false) also triggers onMemoryChanged with 'persona-anchor' before calling
mockClear, using the onMemoryChanged spy and the setPersonaAnchor method to
verify both emissions.
In `@test/renderer/components/MemoryHealthSection.test.ts`:
- Around line 122-133: The loaded-state test in MemoryHealthSection is using a
timezone-sensitive timestamp assertion, which makes the rendered month flaky
across runners. Update the test around mountSection/loadedHealth to avoid
relying on `createdAt: 3000`; either use a midday January timestamp that is
stable in all timezones or mock the date formatter so the `wrapper.text()` check
remains deterministic.
---
Nitpick comments:
In `@src/renderer/settings/components/MemoryHealthSection.vue`:
- Around line 21-22: The loops in MemoryHealthSection.vue are using translated
labels as Vue keys, which can change by locale and may collide. Add a stable
identifier such as `id` or `key` derived from the metric name/DTO enum in the
data model, then update the `headlineMetrics` and row rendering loops to bind
`:key` to that stable field instead of `metric.label` or `row.label`. Apply the
same change to all repeated `v-for` blocks in this component that currently key
off translated text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26b373ec-9e84-48c6-ae43-35955ee055e8
📒 Files selected for processing (41)
package.jsonsrc/main/presenter/memoryPresenter/index.tssrc/main/presenter/memoryPresenter/types.tssrc/main/presenter/sqlitePresenter/tables/agentMemory.tssrc/main/presenter/sqlitePresenter/tables/agentMemoryAudit.tssrc/main/routes/index.tssrc/renderer/api/MemoryClient.tssrc/renderer/settings/components/MemoryHealthSection.vuesrc/renderer/settings/components/MemoryManagerPanel.vuesrc/renderer/src/i18n/da-DK/settings.jsonsrc/renderer/src/i18n/de-DE/settings.jsonsrc/renderer/src/i18n/en-US/settings.jsonsrc/renderer/src/i18n/es-ES/settings.jsonsrc/renderer/src/i18n/fa-IR/settings.jsonsrc/renderer/src/i18n/fr-FR/settings.jsonsrc/renderer/src/i18n/he-IL/settings.jsonsrc/renderer/src/i18n/id-ID/settings.jsonsrc/renderer/src/i18n/it-IT/settings.jsonsrc/renderer/src/i18n/ja-JP/settings.jsonsrc/renderer/src/i18n/ko-KR/settings.jsonsrc/renderer/src/i18n/ms-MY/settings.jsonsrc/renderer/src/i18n/pl-PL/settings.jsonsrc/renderer/src/i18n/pt-BR/settings.jsonsrc/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/i18n/tr-TR/settings.jsonsrc/renderer/src/i18n/vi-VN/settings.jsonsrc/renderer/src/i18n/zh-CN/settings.jsonsrc/renderer/src/i18n/zh-HK/settings.jsonsrc/renderer/src/i18n/zh-TW/settings.jsonsrc/shared/contracts/events/memory.events.tssrc/shared/contracts/routes.tssrc/shared/contracts/routes/memory.routes.tssrc/shared/types/agent-memory.tstest/main/presenter/agentMemoryTable.test.tstest/main/presenter/fakes/memoryFakes.tstest/main/presenter/memoryPresenter.test.tstest/main/routes/dispatcher.test.tstest/main/routes/memoryDto.test.tstest/renderer/api/clients.test.tstest/renderer/components/MemoryHealthSection.test.tstest/renderer/components/MemoryManagerDialog.test.ts
Adds a read-only Agent Memory Health snapshot and settings Health tab, with lazy loading, typed routes/client support, repository stats, i18n, and coverage for health metrics, refresh behavior, and native SQLite-gated table tests.
Summary by CodeRabbit
New Features
Bug Fixes