Add versioning support to annotation creation/editing and search#7518
Add versioning support to annotation creation/editing and search#7518karenrasmussen wants to merge 1 commit intomainfrom
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (48.57%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #7518 +/- ##
==========================================
- Coverage 99.61% 99.46% -0.15%
==========================================
Files 283 283
Lines 11877 11914 +37
Branches 2898 2908 +10
==========================================
+ Hits 11831 11850 +19
- Misses 46 64 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for extracting a document “version” from HTML metadata and incorporating it into the URI set used to search for annotations, enabling version-aware annotation retrieval.
Changes:
- Extend
DocumentMetadata/HTMLDocumentMetadatawith an optionalversionfield. - Extract a version number (v1–v25) from
citation_id,citation_public_url, and the canonical link when consistent. - Append
:v0:v{version}to frame search URIs when a version is present.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/types/annotator.ts |
Adds version?: number to shared DocumentMetadata type. |
src/annotator/integrations/html-metadata.ts |
Implements version extraction from Highwire metadata + canonical link and stores it in document metadata. |
src/sidebar/store/modules/frames.ts |
Updates annotation search URI generation to incorporate version suffix when present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const version = this._getVersion(metadata); | ||
|
|
||
| if (version !== null) { | ||
| metadata.version = version; | ||
| } |
There was a problem hiding this comment.
There are existing tests for HTMLMetadata (see src/annotator/integrations/test/html-metadata-test.js), but the new version-extraction behavior is currently untested. Add unit tests covering: (1) matching versions across citation_id, citation_public_url, and rel=canonical; (2) mismatch between sources returning null; and (3) out-of-range versions (eg. v0/v26) being rejected.
| // If the document has a version, append :v0:v{version} to each URI | ||
| const version = frame.metadata?.version; | ||
| if (version) { | ||
| uris = uris.map(uri => `${uri}:v0:v${version}`); | ||
| } |
There was a problem hiding this comment.
There are existing tests for searchUris in src/sidebar/store/modules/test/frames-test.js, but the new version-suffix behavior is untested. Add cases where frame.metadata.version is set and verify the produced URI list matches expectations (including how DOI/URN entries should be handled).
| const potential_version = this._findVersion(candidate); | ||
| if (!potential_version) { | ||
| return null; | ||
| } | ||
|
|
||
| // If the version is not set, set it to the potential version. | ||
| // If the version is set and the potential version is different, return null. | ||
| if (version === null) { | ||
| version = potential_version; | ||
| } else if (version !== potential_version) { |
There was a problem hiding this comment.
potential_version uses snake_case, which is inconsistent with the surrounding camelCase naming in this file. Rename it (and related references) to potentialVersion for consistency and readability.
| const potential_version = this._findVersion(candidate); | |
| if (!potential_version) { | |
| return null; | |
| } | |
| // If the version is not set, set it to the potential version. | |
| // If the version is set and the potential version is different, return null. | |
| if (version === null) { | |
| version = potential_version; | |
| } else if (version !== potential_version) { | |
| const potentialVersion = this._findVersion(candidate); | |
| if (!potentialVersion) { | |
| return null; | |
| } | |
| // If the version is not set, set it to the potential version. | |
| // If the version is set and the potential version is different, return null. | |
| if (version === null) { | |
| version = potentialVersion; | |
| } else if (version !== potentialVersion) { |
This pull request introduces support for extracting and handling document version information in the metadata processing and frame URI generation logic. The main changes involve parsing version numbers from specific metadata fields, storing this version in the document metadata, and incorporating it into the generated URIs for frames.
Metadata version extraction and propagation:
versionfield to theHTMLDocumentMetadataandDocumentMetadatatypes to store the document version if detected. [1] [2]HTMLMetadataclass to extract a version number fromhighwire.id,highwire.public_url, and the canonical link, ensuring all three sources agree on the version (must end with v1–v25).Frame URI handling:
searchUrisForFramefunction to append the version information to each URI in the format:v0:v{version}if a version is present in the frame's metadata.