openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

feat(memory): clear source memory on disconnect

Open YOMXXX opened this issue 6 months ago β€’ 4 comments

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_memory through channel and Composio disconnect flows, returning memory_chunks_deleted counts.
  • 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.tsx
  • pnpm --filter openhuman-app test:unit src/components/channels/__tests__/DiscordConfig.test.tsx
  • pnpm --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.ts
  • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml clear_memory --lib
  • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml cleanup_targets --lib
  • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml composio::ops --lib
  • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml delete_chunks_by_source --lib
  • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml memory::tree::store --lib
  • pnpm i18n:check
  • pnpm typecheck
  • GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml
  • pnpm lint (passes with existing warnings)
  • pnpm format:check
  • git diff --check
  • GGML_NATIVE=OFF pnpm rust:check
  • GGML_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.

Review Change Stack

YOMXXX avatar May 23 '26 10:05 YOMXXX

[!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_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to 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 extends composio_delete_connection with toolkit-specific memory cleanup logic using LIKE patterns for Notion and Drive sources. If issue #2598 reports over-deletion via these patterns, the cleanup target functions in src/openhuman/composio/ops.rs should 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 eslint to 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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 23 '26 10:05 coderabbitai[bot]

placeholder

sanil-23 avatar May 23 '26 11:05 sanil-23

@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

YOMXXX avatar May 23 '26 14:05 YOMXXX

@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.

YOMXXX avatar May 24 '26 13:05 YOMXXX