mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 17:10:28 +00:00
2.5 KiB
2.5 KiB
Clear Current File Full-Coverage Decisions
Command semantic
- Keep the command semantic fixed as: clear all synced entries in the current file.
- Covered routes:
- normal QA / cloze cards
- semantic QA child cards written with
<!--ID: ...--> - QA Group blocks written with
<!--GI: ...-->
Collection strategy
ClearCurrentFileSyncedCardsUseCasewill collect two separate tracked sets:trackedCards: CardState[]trackedGroupBlocks: GroupBlockState[]
- Collection sources:
- cards from
files[filePath].noteIdsplusstate.cardsfallback byfilePath - groups from
files[filePath].groupIdsplusstate.groupBlocksfallback byfilePath
- cards from
hasTrackedCards(filePath)will mean any tracked card or tracked group exists for the file.- Anki note deletion will use one deduplicated
noteIdsarray across both sets.
Marker removal strategy
- Add a new application-layer service named
MarkdownSyncedMarkerRemovalService. - The service will:
- read the Markdown file once
- remove matching
IDmarkers bynoteId - remove matching
GImarkers bynoteId - call
replaceMarkdownFile(...)at most once per file
- It will reuse
CardMarkerRemovalServiceandGroupMarkerServicefor marker recognition and low-level line operations instead of replacing their existing responsibilities. - Removal will match by
noteId;groupIdandblockStartLinestay in the input/result surface for traceability but not as the primary deletion key.
Local state cleanup strategy
- The clear path will remove from local state:
- tracked card entries in
state.cards - tracked group entries in
state.groupBlocks state.files[filePath]- all
pendingWriteBackentries wherepending.filePath === filePath
- tracked card entries in
- Pending cleanup is file-scoped by design and will not rely on
targetNoteIdmatching.
Result and notice shape
- Extend
ClearCurrentFileSyncedCardsResultwith split stats for cards, groups, ID markers, GI markers, and local-record deletions. NoticeService.showClearCurrentFileSummary(...)will render total counts plus group/card breakdown instead of collapsing everything intotrackedCards.
Testing scope
- Keep existing normal-card clear behavior passing.
- Add coverage for:
- semantic QA clear
- QA Group clear
- mixed-file clear with deduplicated note deletion
- GI-marker conflict handling
- file-scoped pending cleanup for both
card-idandgroup-gi
- No changes will be made to normal sync, rebuild,
QaGroupSyncService, or semantic/group routing beyond what is needed to support clear-current-file.