feat: annotations linked to file version (#55) #58

Merged
marcel merged 2 commits from feature/55-file-hash-annotations into main 2026-03-24 22:09:13 +01:00
Owner

Summary

  • SHA-256 hashing on upload: FileService.uploadFile() now reads file bytes once, computes a SHA-256 hash, and returns it alongside the S3 key via a new UploadResult record
  • Hash stored on document and annotation: Flyway migration V13 adds file_hash VARCHAR(64) to both documents and document_annotations; annotations capture the document's hash at creation time
  • Frontend filtering: PdfViewer accepts a documentFileHash prop and filters annotations to only show those whose hash matches the current file (or have no hash). An amber notice banner appears when outdated annotations exist
  • i18n: translation key annotation_outdated_notice added in de/en/es

Test plan

  • All 164 backend unit tests pass (./mvnw test)
  • svelte-check introduces no new type errors
  • E2E: annotations are hidden after a different file is uploaded — upload PDF, create annotation, replace file → annotation hidden + notice shown
  • E2E: annotations reappear after re-uploading the original file — upload PDF, annotate, replace, re-upload original → annotation visible, no notice
  • Existing annotation e2e tests (draw, persist, delete, reader) remain green

Closes #55

## Summary - **SHA-256 hashing on upload**: `FileService.uploadFile()` now reads file bytes once, computes a SHA-256 hash, and returns it alongside the S3 key via a new `UploadResult` record - **Hash stored on document and annotation**: Flyway migration V13 adds `file_hash VARCHAR(64)` to both `documents` and `document_annotations`; annotations capture the document's hash at creation time - **Frontend filtering**: `PdfViewer` accepts a `documentFileHash` prop and filters annotations to only show those whose hash matches the current file (or have no hash). An amber notice banner appears when outdated annotations exist - **i18n**: translation key `annotation_outdated_notice` added in de/en/es ## Test plan - [ ] All 164 backend unit tests pass (`./mvnw test`) - [ ] `svelte-check` introduces no new type errors - [ ] E2E: `annotations are hidden after a different file is uploaded` — upload PDF, create annotation, replace file → annotation hidden + notice shown - [ ] E2E: `annotations reappear after re-uploading the original file` — upload PDF, annotate, replace, re-upload original → annotation visible, no notice - [ ] Existing annotation e2e tests (draw, persist, delete, reader) remain green Closes #55
marcel added 2 commits 2026-03-24 17:12:00 +01:00
- Flyway V13: add file_hash column to documents and document_annotations
- FileService.uploadFile() now returns UploadResult(s3Key, fileHash) with SHA-256 hash computed from raw bytes
- Document and DocumentAnnotation models gain a fileHash field
- DocumentService propagates the hash at all three upload sites (storeDocument, createDocument, updateDocument)
- AnnotationService.createAnnotation() accepts and persists a fileHash
- AnnotationController resolves the document's hash and passes it through

Closes #55

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(frontend): hide outdated annotations when file version changes
Some checks failed
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (push) Has started running
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled
CI / E2E Tests (pull_request) Has been cancelled
7fbc33b32d
- Regenerate API types with fileHash on Document and DocumentAnnotation
- PdfViewer accepts documentFileHash prop; filters visibleAnnotations to
  those whose hash matches (or is null) and shows an amber notice banner
  when any annotations are hidden due to a hash mismatch
- Document detail page passes doc.fileHash to PdfViewer
- Add i18n key annotation_outdated_notice in de/en/es
- E2E: two new tests covering hide-on-reupload and restore-on-original-reupload
  scenarios; add minimal2.pdf fixture for a different-hash upload

Closes #55

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel merged commit 7fbc33b32d into main 2026-03-24 22:09:13 +01:00
marcel deleted branch feature/55-file-hash-annotations 2026-03-24 22:09:14 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#58