Skip to content

feat(projects): notify enabled plugins on project deletion (project_deleted hook) - #1833

Open
Jehu wants to merge 1 commit into
agent0ai:mainfrom
Jehu:feat/project-deleted-hook
Open

feat(projects): notify enabled plugins on project deletion (project_deleted hook)#1833
Jehu wants to merge 1 commit into
agent0ai:mainfrom
Jehu:feat/project-deleted-hook

Conversation

@Jehu

@Jehu Jehu commented Aug 18, 2026

Copy link
Copy Markdown

Motivation

Deleting a project can leave external, per-project resources behind (for example per-project memory banks used by memory plugins). Plugins currently have no reliable signal that a project was removed, which leads to orphaned external state.

What it does

delete_project() now notifies all enabled plugins after the project directory is removed and the project is deactivated in chats:

  • New project_deleted(project_name: str, **kwargs) hook, implemented by plugins in their hooks.py.
  • Notification goes to every enabled plugin via the existing call_plugin_hook mechanism; plugins without the hook are skipped silently.

Implementation notes

  • Fully additive: one call in delete_project() plus a small private helper _notify_project_deleted() in helpers/projects.py.
  • No new module-level imports (deferred import avoids import cycles).
  • Fail-safe by design: plugin enumeration and every hook call are guarded, so hook errors can never break project deletion.

Tests

New tests/test_project_deleted_hook.py covers:

  • enabled plugin hook receives the correct project name
  • raising hook does not break deletion
  • disabled plugins are not notified
  • plugins without hooks.py are harmless

All 4 new tests pass, plus the existing tests/test_projects.py suite (20 passed) on Python 3.12.

Out of scope

Project renaming (and a corresponding project_renamed hook) is intentionally not included; renaming project directories is not currently supported by the UI and would be a separate, larger change.

…roject_deleted hook fired by delete_project() after the project\ndirectory is removed and the project is deactivated in chats. Enabled\nplugins can implement project_deleted(project_name=...) in hooks.py to\nclean up external per-project resources (e.g. per-project memory banks).\n\nHook notification is fully guarded: plugin enumeration and every hook\ncall are fail-safe, so hook errors can never break project deletion.\n\nIncludes regression tests for notification, disabled plugins, missing\nhooks, and failing hooks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant