Skip to content

Rebuild tag-based subdecks when dissolving block exam subdecks#1210

Draft
RisingOrange wants to merge 6 commits intoNRT-432from
refresh-subdecks-on-subdeck-merge
Draft

Rebuild tag-based subdecks when dissolving block exam subdecks#1210
RisingOrange wants to merge 6 commits intoNRT-432from
refresh-subdecks-on-subdeck-merge

Conversation

@RisingOrange
Copy link
Collaborator

@RisingOrange RisingOrange commented Oct 17, 2025

This PR improves compatibility between block exam subdecks and subdeck tag features by ensuring notes return to their proper tag-based subdecks when a block exam subdeck is dissolved.

Related issues

  • Closes # (add issue number if applicable)

Proposed changes

1. Refresh tag-based subdecks on subdeck dissolution

  • When dissolving a block exam subdeck from an AnkiHub deck with subdecks enabled, notes are now redistributed to their appropriate tag-based subdecks
  • Previously, notes would stay in the root deck after dissolution, breaking the subdeck tag organization
  • This ensures the subdeck tag feature continues working correctly after temporary block exam subdecks are removed

2. Rename function for clarity

  • Renames move_subdeck_to_main_deck()dissolve_block_exam_subdeck()
  • The new name better reflects the actual behavior: dissolving the subdeck structure and redistributing notes appropriately
  • More accurate since notes don't necessarily end up in the main deck - they may be redistributed to tag-based subdecks

3. Update tests and documentation

  • Adds test coverage for subdeck rebuilding with test_dissolve_subdeck_with_subdecks_enabled
  • Updates existing tests to properly verify both scenarios:
    • Non-AnkiHub decks: notes stay in root deck
    • AnkiHub decks with subdecks enabled: notes are redistributed to tag-based subdecks
  • Updated docstring to clearly explain the two-step redistribution process

How to reproduce

Testing subdeck tag compatibility (main feature):

  • Set up an AnkiHub deck subdecks enabled and a note with a subdeck tag
    • Add AnkiHub_Subdeck::AnKing_Overhaul_for_Step_1_&_2::foo to a note
    • Use Anki Browser -> AnkiHub -> Rebuild subdecks and move cards into subdecks
    • You can unsuspend the card of the note so that you can see the "1" new note next to the deck name
      image
  • Create a block exam subdeck and move the note with the subdeck tag into it
    image
  • Remove the tag-based deck ("foo")
    image
  • Merge the block exam subdeck into the parent deck
  • Expected: The tag-based deck is recreated, and the note is moved back into it
    image

Testing the unit tests:

xvfb-run python -m pytest tests/addon/test_unit.py::TestDissolveBlockExamSubdeck -v --show-capture=no --disable-warnings -n 0

All three test cases should pass:

  • test_dissolve_block_exam_subdeck_success - Basic dissolution without subdeck rebuilding
  • test_dissolve_subdeck_with_subdecks_enabled - Dissolution with subdeck rebuilding for AnkiHub decks (key test)
  • test_dissolve_subdeck_not_found - Error handling when subdeck doesn't exist

Screenshots and videos

N/A - The feature works behind the scenes to maintain subdeck tag organization.

Further comments

Why this matters:

Block exam subdecks and subdeck tags serve different purposes:

  • Block exam subdecks: Local, user-specific temporary organization for exam preparation
  • Subdeck tags: Shared across all deck subscribers, part of the deck's content organization

Without this change, dissolving a block exam subdeck would leave notes orphaned in the main deck, breaking the tag-based subdeck organization. This PR ensures the two features work together properly - block exam subdecks can be created and dissolved without disrupting the underlying tag-based subdeck structure.

@RisingOrange RisingOrange changed the base branch from main to NRT-432 October 17, 2025 12:57
@RisingOrange RisingOrange changed the title Refresh subdecks on subdeck merge Refresh subdecks on block exam subdeck merge Oct 17, 2025
@RisingOrange RisingOrange changed the title Refresh subdecks on block exam subdeck merge Rebuild tag-based subdecks when dissolving block exam subdecks Oct 17, 2025
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