Skip to content

Add versioning support to annotation creation/editing and search#7518

Draft
karenrasmussen wants to merge 1 commit intomainfrom
document-equivalence
Draft

Add versioning support to annotation creation/editing and search#7518
karenrasmussen wants to merge 1 commit intomainfrom
document-equivalence

Conversation

@karenrasmussen
Copy link
Contributor

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:

  • Added a version field to the HTMLDocumentMetadata and DocumentMetadata types to store the document version if detected. [1] [2]
  • Implemented logic in the HTMLMetadata class to extract a version number from highwire.id, highwire.public_url, and the canonical link, ensuring all three sources agree on the version (must end with v1–v25).

Frame URI handling:

  • Updated the searchUrisForFrame function to append the version information to each URI in the format :v0:v{version} if a version is present in the frame's metadata.

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 48.57143% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.46%. Comparing base (b07c1b8) to head (89cec3c).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
src/annotator/integrations/html-metadata.ts 46.87% 17 Missing ⚠️
src/sidebar/store/modules/frames.ts 66.66% 1 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / HTMLDocumentMetadata with an optional version field.
  • 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.

Comment on lines +100 to +104
const version = this._getVersion(metadata);

if (version !== null) {
metadata.version = version;
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +191 to +195
// 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}`);
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +124 to +133
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) {
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants