Skip to content

feat: support deleting selected note types#4777

Draft
caleblee789 wants to merge 1 commit into
ankitects:mainfrom
caleblee789:codex/cleanup-unused-notetypes
Draft

feat: support deleting selected note types#4777
caleblee789 wants to merge 1 commit into
ankitects:mainfrom
caleblee789:codex/cleanup-unused-notetypes

Conversation

@caleblee789
Copy link
Copy Markdown

@caleblee789 caleblee789 commented May 4, 2026

Linked issue (required)

N/A

Summary / motivation (required)

Replaces the proposed Clean Up button in the Manage Note Types dialog with multi-select deletion support.

Users can now select multiple note types in the dialog and press the existing Delete button to remove the selected note types in one confirmed operation. Single-selection delete keeps the existing behavior and confirmation text. When every note type is selected, the current row is preserved so the collection keeps at least one note type.

The bulk delete path:

  • enables extended selection in the note type list
  • confirms deletion with different copy when selected note types have notes/cards
  • re-checks selected IDs inside the collection operation before deleting
  • merges the removals into one undo entry
  • refreshes the dialog and reports the number of selected note types removed

Steps to reproduce (required, use N/A if not applicable)

N/A

How to test (required)

Checklist (minimum)

  • I ran ./ninja check or an equivalent relevant check locally.
  • I added or updated tests when the change is non-trivial or behavior changed.

Details

Ran:

  • out/pyenv/bin/ruff format --check qt/aqt/models.py qt/aqt/operations/notetype.py qt/tests/test_notetype_delete.py
  • out/pyenv/bin/ruff check qt/aqt/models.py qt/aqt/operations/notetype.py qt/tests/test_notetype_delete.py
  • git diff --check main...HEAD
  • PYTHONPYCACHEPREFIX=/private/tmp/anki-pycache python3 -m compileall qt/aqt/models.py qt/aqt/operations/notetype.py qt/tests/test_notetype_delete.py

Attempted ./ninja check:pytest, but this checkout failed before pytest while initializing local build inputs: git submodule config lock errors for ftl/*-repo and missing MDI SVGs under out/node_modules.

Attempted focused pytest for qt/tests/test_notetype_delete.py, but direct invocation failed during collection because this local source/generated import path hits an existing anki.models circular import before collecting tests.

Before / after behavior (optional)

Before: the PR added a separate Clean Up action that removed all unused note types.

After: users select one or more note types in the existing list and press Delete. Multiple selected note types are deleted together, including used note types after a stronger warning.

Risk / compatibility / migration (optional)

Moderate UI risk. The existing Delete action now considers multi-selection, but single-selection deletion remains unchanged. The bulk operation revalidates IDs in the collection operation, preserves at least one note type, and merges multiple removals into a single undo step.

UI evidence (required for visual changes; otherwise N/A)

Not captured. The UI change is interaction behavior in the existing Manage Note Types dialog: the note type list now supports extended selection, and the existing Delete button applies to the selected rows.

Scope

  • This PR is focused on one change (no unrelated edits).

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 4, 2026

Documentation build overview

📚 Anki | 🛠️ Build #32607608 | 📁 Comparing ab336eb against latest (7d8dc01)

  🔍 Preview build  

3 files changed
± genindex.html
± autoapi/aqt/models/index.html
± autoapi/aqt/operations/notetype/index.html

@ZornHadNoChoice
Copy link
Copy Markdown

Adding multi select like on AnkiDroid would be better imo. Users don't usually (and regularly) have many unused note types.

@caleblee789
Copy link
Copy Markdown
Author

I import a lot of decks, so I frequently have to clear many note types, but I could see where most people wouldn't. If this is preferred, I could port the change over to multiselect instead.

@caleblee789 caleblee789 force-pushed the codex/cleanup-unused-notetypes branch from 57d0294 to ab336eb Compare May 8, 2026 17:28
@caleblee789 caleblee789 changed the title feat: add cleanup action for unused note types feat: support deleting selected note types May 8, 2026
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