mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 17:10:28 +00:00
3.5 KiB
3.5 KiB
Clear Current File Full-Coverage Gap Report
Scope reviewed
src/application/use-cases/ClearCurrentFileSyncedCardsUseCase.tssrc/application/services/MarkdownMarkerRemovalService.tssrc/domain/manual-sync/services/CardMarkerRemovalService.tssrc/domain/manual-sync/services/GroupMarkerService.tssrc/domain/manual-sync/entities/PluginState.tssrc/application/use-cases/cleanupResetTypes.tssrc/presentation/notices/NoticeService.tssrc/application/use-cases/ClearCurrentFileSyncedCardsUseCase.test.ts- related write-back/state flow in
MarkdownWriteBackServiceandQaGroupSyncService
Confirmed current behavior
1. Current clear command only tracks normal cards
ClearCurrentFileSyncedCardsUseCaseonly callscollectTrackedCards(state, filePath).collectTrackedCards(...)only readsstate.files[filePath]?.noteIdsandstate.cardsfallback.state.files[filePath]?.groupIdsandstate.groupBlocksare ignored entirely.
2. Current marker removal is ID-only
MarkdownMarkerRemovalServicedelegates only toCardMarkerRemovalService.CardMarkerRemovalServiceonly removes<!--ID: ...-->markers bynoteId.- There is no application-layer remover that also consumes
GroupMarkerServiceand strips<!--GI: ...-->.
3. Current local cleanup only clears card records
buildNextState(...)deletes matchingstate.cardsentries and the file entry instate.files.- It does not delete
state.groupBlocksfor the same file. pendingWriteBackcleanup currently filters by bothpending.filePath !== filePathand tracked note keys, which is narrower than the required file-scoped clear semantics.- Because
group-gipending entries are file-scoped and may not map cleanly through the tracked-note filter, current cleanup is incomplete for group writes.
4. Current result type and notice summary assume only normal cards
ClearCurrentFileSyncedCardsResultonly exposestrackedCards,deletedNotes,removedMarkers,deletedLocalRecords,conflictFiles, andfailureFiles.NoticeService.showClearCurrentFileSummary(...)renders only one tracked-card count and one removed-marker total.- A file containing only QA Group state would currently produce misleading summary output.
5. State model already supports the missing routes
PluginStatealready containsgroupBlocksandFileState.groupIds.PendingWriteBackStatealready hasmarkerKind?: "card-id" | "group-gi"andtargetGroupId.MarkdownWriteBackServicealready persistsgroup-gipending entries andQaGroupSyncServicealready writes GI markers.- This confirms the bug is in the clear-current-file command path, not in the underlying state model.
6. Current tests only cover normal cards
ClearCurrentFileSyncedCardsUseCase.test.tscovers:- normal-card clear success
- empty-file result
- ID-marker conflict handling
- It does not cover:
- semantic QA child cards
- QA Group GI markers
- mixed files
- group conflict behavior
group-gipending cleanup
Gap versus required behavior
- Missing tracked group collection from
groupIdsandgroupBlocksfallback. - Missing unified marker removal for both
IDandGImarkers. - Missing group-block deletion from local state.
- Missing file-scoped pending cleanup for all entries in the cleared file.
- Missing result fields for group-specific stats.
- Missing notice summary split for card markers vs group markers.
- Missing regression coverage for semantic QA, QA Group, mixed files, group conflicts, and pending cleanup.