Skip to content

AnkiEDN maintener request: add an auto-protect feature for learned cards#75

Open
Dev-Zaius wants to merge 3 commits into
CravingCrates:mainfrom
Dev-Zaius:feature/auto-protect
Open

AnkiEDN maintener request: add an auto-protect feature for learned cards#75
Dev-Zaius wants to merge 3 commits into
CravingCrates:mainfrom
Dev-Zaius:feature/auto-protect

Conversation

@Dev-Zaius

Copy link
Copy Markdown
  • 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with 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 thread plugin_source/crowd_anki/representation/note.py
Comment thread plugin_source/crowd_anki/representation/note.py Outdated
Comment thread plugin_source/menu.py
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"
Comment thread plugin_source/auto_protect.py Outdated
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.

2 participants