feat(projects): notify enabled plugins on project deletion (project_deleted hook) - #1833
Open
Jehu wants to merge 1 commit into
Open
feat(projects): notify enabled plugins on project deletion (project_deleted hook)#1833Jehu wants to merge 1 commit into
Jehu wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:project_deleted(project_name: str, **kwargs)hook, implemented by plugins in theirhooks.py.call_plugin_hookmechanism; plugins without the hook are skipped silently.Implementation notes
delete_project()plus a small private helper_notify_project_deleted()inhelpers/projects.py.Tests
New
tests/test_project_deleted_hook.pycovers:hooks.pyare harmlessAll 4 new tests pass, plus the existing
tests/test_projects.pysuite (20 passed) on Python 3.12.Out of scope
Project renaming (and a corresponding
project_renamedhook) is intentionally not included; renaming project directories is not currently supported by the UI and would be a separate, larger change.