AnkiEDN maintener request: add an auto-protect feature for learned cards#75
Open
Dev-Zaius wants to merge 3 commits into
Open
AnkiEDN maintener request: add an auto-protect feature for learned cards#75Dev-Zaius wants to merge 3 commits into
Dev-Zaius wants to merge 3 commits into
Conversation
Dev-Zaius
commented
May 4, 2026
- Add auto_protect.py with two functions:
- on_card_reviewed(): hook that protects a note when its card transitions to Review state (card.type == 2)
- protect_all_learned(): batch that protects all learned notes
- Register reviewer_did_answer_card hook in hooks_init()
- Add two opt-in checkboxes and batch button in Global Settings
- Fix case-insensitive tag detection in note.py (line 429) to handle Anki's automatic tag lowercasing
- Add auto_protect.py with two functions:
* on_card_reviewed(): hook that protects a note when its card
transitions to Review state (card.type == 2)
* protect_all_learned(): batch that protects all learned notes
- Register reviewer_did_answer_card hook in hooks_init()
- Add two opt-in checkboxes and batch button in Global Settings
- Fix case-insensitive tag detection in note.py (line 429)
to handle Anki's automatic tag lowercasing
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an auto-protect workflow so learned/reviewed notes can be tagged with AnkiCollab_Protect::All, plus related settings UI and a partial fix for lowercased protection tags during import. In the current state, the lowercased-tag handling is still incomplete, so the new feature can fail to preserve protected content and can leak personal protection tags into exported deck data.
Changes:
- Added
auto_protect.pywith a reviewer hook and a batch action for protecting learned/reviewed notes. - Exposed new auto-protect controls in the global settings dialog.
- Updated protected-tag detection in note import logic to be case-insensitive.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
plugin_source/menu.py |
Adds global settings controls for auto-protect and the batch action button. |
plugin_source/hooks.py |
Imports the new auto-protect helpers and registers the reviewer hook. |
plugin_source/crowd_anki/representation/note.py |
Adjusts protected-tag detection during import; also still contains related export stripping logic. |
plugin_source/auto_protect.py |
Implements automatic note tagging on review and batch protection for learned notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+924
to
+929
| auto_protect_review_cb = QCheckBox("Protects new card from change automatically") | ||
| auto_protect_review_cb.setStyleSheet(checkbox_style) | ||
| auto_protect_review_cb.setChecked(bool(settings.get("auto_protect_on_review", False))) | ||
| auto_protect_review_cb.setToolTip( | ||
| "Add Protect All Fields tag to your card immediately after you reviewed it " | ||
| "so the note won't be erased on updates" |
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.