feat(memory): clear source memory on disconnect
Summary
- Add source-scoped memory cleanup helpers that delete matching memory-tree chunks plus dependent score/entity/embedding/reembed rows and best-effort content files.
- Thread opt-in
clearMemory/clear_memorythrough channel and Composio disconnect flows, returningmemory_chunks_deletedcounts. - Add disconnect UI checkboxes for channel and Composio flows with irreversible-action copy and focused tests.
- Address review feedback: safe content-file cleanup, local cleanup/event/cache completion even if memory deletion errors, Composio Notion/Drive cleanup targets, Korean translations, and checkbox reset on failed disconnect retry.
Related Issue
Closes #2515
Type of Change
- [x] Feature
- [x] Bug fix
- [x] N/A: Refactor
- [x] N/A: Documentation
- [x] Tests
- [x] N/A: Chore
How Tested
pnpm --filter openhuman-app test:unit src/services/api/__tests__/channelConnectionsApi.test.ts src/lib/composio/composioApi.test.ts src/components/composio/ComposioConnectModal.test.tsx src/components/channels/__tests__/TelegramConfig.test.tsxpnpm --filter openhuman-app test:unit src/components/channels/__tests__/DiscordConfig.test.tsxpnpm --filter openhuman-app exec vitest run --coverage --config test/vitest.config.ts src/components/channels/__tests__/DiscordConfig.test.tsx src/components/channels/__tests__/TelegramConfig.test.tsx src/components/composio/ComposioConnectModal.test.tsx src/services/api/__tests__/channelConnectionsApi.test.ts src/lib/composio/composioApi.test.tsGGML_NATIVE=OFF cargo test --manifest-path Cargo.toml clear_memory --libGGML_NATIVE=OFF cargo test --manifest-path Cargo.toml cleanup_targets --libGGML_NATIVE=OFF cargo test --manifest-path Cargo.toml composio::ops --libGGML_NATIVE=OFF cargo test --manifest-path Cargo.toml delete_chunks_by_source --libGGML_NATIVE=OFF cargo test --manifest-path Cargo.toml memory::tree::store --libpnpm i18n:checkpnpm typecheckGGML_NATIVE=OFF cargo check --manifest-path Cargo.tomlpnpm lint(passes with existing warnings)pnpm format:checkgit diff --checkGGML_NATIVE=OFF pnpm rust:checkGGML_NATIVE=OFF git push(pre-push hook passed)
Screenshots / Recordings
Not applicable.
Checklist
- [x] I have linked the relevant issue.
- [x] I have added or updated tests for the change.
- [x] I have updated documentation where needed, or this change does not need docs.
- [x] I have run the commands listed above and reported any blockers.
- [x] Diff coverage for changed lines is expected to meet the 80% gate; CI remains authoritative.
AI Authorship Checklist
- [x] I reviewed the generated diff for unintended changes.
- [x] I kept the change scoped to #2515.
- [x] I did not include local superpowers files.
- [x] Latest commit:
6e1eaa2632d7ea010dd54b4cb1a797deabd527de.
Summary by CodeRabbit
-
New Features
- Users can now optionally delete associated memory when disconnecting accounts from Discord, Telegram, and Composio integrations.
- Added a checkbox control in the disconnect flow to enable memory clearing; disabled by default.
- Memory deletion is permanent once confirmed.
-
Tests
- Added test coverage for the memory deletion feature across account disconnect scenarios.
-
Documentation
- Added multilingual translations for the memory deletion option across all supported languages.
[!CAUTION]
Review failed
Failed to post review comments
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] βΆοΈ Resume reviews
- [ ] π Trigger review
π Walkthrough
Walkthrough
This PR implements opt-in memory deletion on disconnect for Discord, Telegram, and Composio integrations. Users can now select "also delete memory from this source" when disconnecting to permanently remove ingested chat/email/document chunks. The feature wires through RPC schema and operations on the backend, frontend API methods, UI components with state management, comprehensive tests, and i18n strings across 13 language chunks.
Changes
Memory deletion on channel/Composio disconnect
| Layer / File(s) | Summary |
|---|---|
Channels RPC: schema, operations, and tests src/openhuman/channels/controllers/schemas.rs, src/openhuman/channels/controllers/ops.rs, src/openhuman/channels/controllers/schemas_tests.rs, src/openhuman/channels/controllers/ops_tests.rs |
DisconnectParams gains optional clear_memory field with serde default; disconnect_channel operation accepts the flag and deletes chat-source memory chunks (exact and prefix-matched) when enabled, reporting memory_chunks_deleted count. Deserialization and integration tests verify parameter handling and memory cleanup. |
Channels frontend API app/src/services/api/channelConnectionsApi.ts, app/src/services/api/__tests__/channelConnectionsApi.test.ts |
channelConnectionsApi.disconnectChannel accepts optional options.clearMemory and conditionally includes it in RPC params. Test verifies the param is forwarded to the backend. |
Discord and Telegram UI components app/src/components/channels/DiscordConfig.tsx, app/src/components/channels/TelegramConfig.tsx, app/src/components/channels/__tests__/DiscordConfig.test.tsx, app/src/components/channels/__tests__/TelegramConfig.test.tsx |
Discord and Telegram components track per-auth-mode clearMemoryOnDisconnect checkbox state, render the checkbox only when connection status is connected, pass the flag to the API, and reset the state after disconnect. Tests seed Redux state, toggle the checkbox, and verify the API is called with clearMemory: true. |
Composio RPC: types and schema src/openhuman/composio/types.rs, src/openhuman/composio/schemas.rs |
ComposioDeleteResponse gains memory_chunks_deleted field; delete_connection RPC schema declares optional clear_memory input and memory_chunks_deleted output; handler forwards the flag to the operation. |
Composio operations: memory deletion and cleanup targets src/openhuman/composio/ops.rs |
composio_delete_connection accepts clear_memory flag, conditionally resolves toolkit, computes toolkit-specific memory cleanup targets (Slack by connection ID, Gmail via identity emails, Notion via synced page sources, Drive via connection-scoped patterns), deletes exact and prefix-matched chunks for each target, accumulates the deletion count, and returns errors only if any per-target deletion fails. |
Composio operations tests src/openhuman/composio/ops_test.rs |
Adds sample_memory_chunk helper for deterministic memory seeding; updates existing tests to pass the clear_memory flag; adds integration test seeding Slack chunks and verifying memory deletion counts only matching sources; adds target-selection tests for Notion (synced pages + connection-scoped prefixes) and Drive (connection-scoped patterns). |
Composio frontend API app/src/lib/composio/composioApi.ts, app/src/lib/composio/composioApi.test.ts |
composioApi.deleteConnection accepts optional options.clearMemory and conditionally includes clear_memory in the JSON-RPC params. Test verifies RPC param forwarding and memory_chunks_deleted value unwrapping. |
ComposioConnectModal UI component app/src/components/composio/ComposioConnectModal.tsx, app/src/components/composio/ComposioConnectModal.test.tsx |
Adds clearMemoryOnDisconnect state and checkbox in the connected view; forwards the flag to deleteConnection on disconnect; resets state after disconnect (success or failure) and when dismissing from the error phase. Tests verify success path, error recovery, and state reset. |
Internationalization strings app/src/lib/i18n/en.ts, app/src/lib/i18n/chunks/{ar-1,bn-1,de-1,en-1,es-1,fr-1,hi-1,id-1,it-1,ko-1,pt-1,ru-1,zh-CN-1}.ts |
Adds accounts.disconnectClearMemory label and accounts.disconnectClearMemoryHint permanence warning across all 13 language chunks. |
Estimated code review effort
π― 4 (Complex) | β±οΈ ~60 minutes
Possibly related issues
#2598: The PR extendscomposio_delete_connectionwith toolkit-specific memory cleanup logic using LIKE patterns for Notion and Drive sources. If issue#2598reports over-deletion via these patterns, the cleanup target functions insrc/openhuman/composio/ops.rsshould be reviewed to ensure correct source scoping.
Suggested reviewers
- graycyrus
Poem
π° Hop skip, now memories can flee,
Delete them with one checkbox spree!
Clean breaks from sources, crisp and bright,
Opt-in control, users' delight! ποΈβ¨
π₯ Pre-merge checks | β 4 | β 1
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 69.81% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'feat(memory): clear source memory on disconnect' accurately reflects the main feature: adding opt-in memory cleanup on channel/Composio disconnection. |
| Linked Issues check | β Passed | All core and app requirements from #2515 are implemented: delete_chunks_by_source helper, clear_memory parameter threading through disconnect_channel and composio_delete_connection RPCs, UI checkboxes with proper copy, and memory_chunks_deleted reporting. |
| Out of Scope Changes check | β Passed | All changes directly support memory deletion on disconnect. i18n additions, API signature updates, component UI changes, and test coverage are all within scope of #2515 objectives. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
π§ ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
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 @coderabbitai help to get the list of available commands and usage tips.
placeholder
@graycyrus @senamakel Ready for review.
Latest state for #2528 (feat(memory): clear source memory on disconnect):
- all required checks are green
- no unresolved review threads
- CodeRabbit has no actionable comments on the latest head
@graycyrus @senamakel Required checks are all green now, and there are no unresolved review threads. The non-required Windows secrets ACL job is marked cancelled after successful checkout/submodule setup and passing test output in the log. Ready for review from the required-gate perspective.