fix(ocr): fill empty MANUAL blocks in guided OCR mode

When a user draws annotation boxes to mark OCR regions, the blocks are
created with source=MANUAL and empty text. upsertGuidedBlock was
protecting all MANUAL blocks unconditionally, so guided OCR silently
produced no output for these drawn-but-empty blocks.

Changed the guard to only protect non-empty MANUAL blocks — empty ones
are treated like OCR blocks and get their text filled in.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-13 16:25:23 +02:00
parent 3e34366702
commit 8618e520b5
2 changed files with 21 additions and 3 deletions

View File

@@ -104,8 +104,8 @@ public class TranscriptionService {
public TranscriptionBlock upsertGuidedBlock(UUID documentId, UUID annotationId,
String text, UUID userId) {
return blockRepository.findByAnnotationId(annotationId).map(existing -> {
if (existing.getSource() == BlockSource.MANUAL) {
return existing; // never overwrite manual transcription
if (existing.getSource() == BlockSource.MANUAL && !existing.getText().isBlank()) {
return existing; // never overwrite non-empty manual transcription
}
existing.setText(sanitizeText(text));
existing.setUpdatedBy(userId);