Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send annotations to correct frame when annotation URL does not match frame URL #4191

Open
robertknight opened this issue Feb 7, 2022 · 2 comments
Labels

Comments

@robertknight
Copy link
Member

robertknight commented Feb 7, 2022

#4131 implemented initial support for sending annotations to a specific frame based on a match between the annotation URL and the frame URL. This means that if an annotation is fetched for a non-main guest frame based on some other identifier (eg. a DOI, a fingerprint) or the backend returns an annotation with URL A when viewing frame with URL B because URLs A and B are deemed equivalent by the h backend (in other words storage.expand_uri for URL A returns a set that includes URL B), then the annotation will not be sent to the frame.

The client currently requests annotations for all frames with a single sequence of search requests, and the backend does not provide information about why a particular URL matched the query (eg. which of the search URLs matched). In order to fix this we'll either need to make separate calls to the /api/search endpoint for each frame, or make this endpoint return information about which URL (from the uri query params) matched a particular annotation.

The same issues also applies to the WebSocket. The client sends a filter to the backend which includes a set of query URLs for each frame. When the WebSocket server matches an annotation-related notification to a socket and sends a notification to the client, it does not indicate which of the query URLs matched. As a result the client can't tell which frame a newly-added annotation relates to.

Related issues:

@robertknight
Copy link
Member Author

I think it is likely we will need to solve this as part of hypothesis/product-backlog#1253.

robertknight added a commit that referenced this issue Feb 8, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
robertknight added a commit that referenced this issue Feb 10, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
robertknight added a commit that referenced this issue Feb 10, 2022
Handle the case when an annotation is returned from the backend whose URL does
not match the frame URL and where there is no "main" guest frame. This can
happen in VitalSource, where no guest is created in the host frame.

The general solution to this is to change the client and h so that it can always
determine which query URL an annotation from h matched. See [1]. This is an
interim step which will work in VitalSource and similar scenarios.

[1] #4191
robertknight added a commit that referenced this issue Feb 11, 2022
Handle the case when an annotation is returned from the backend whose URL does
not match the frame URL and where there is no "main" guest frame. This can
happen in VitalSource, where no guest is created in the host frame.

The general solution to this is to change the client and h so that it can always
determine which query URL an annotation from h matched. See [1]. This is an
interim step which will work in VitalSource and similar scenarios.

[1] #4191
robertknight added a commit that referenced this issue Mar 4, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
robertknight added a commit that referenced this issue Mar 11, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
robertknight added a commit that referenced this issue Mar 15, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
robertknight added a commit that referenced this issue Mar 17, 2022
Explore a client-side solution to sending annotations to correct frame
if annotation URL does not exactly match frame URL (see [1]). In the
client-side solution, a separate search request is made for each frame
and the returned annotations are then associated with that frame.

Some issues to resolve:

 - How can we test this locally with the dev server?
 - What if searches for different frames return the same annotation?
   Make the `frameId` property of `Annotation` an array?
 - How should the WebSocket be adapted? A separate WebSocket instance
   per frame?
 - What do about frame IDs for non-sidebar applications (notebook,
   stream, single annotation page) where annotations are not associated
   with frames?

[1] #4191
@leedenison leedenison added the bug label May 24, 2023
@robertknight
Copy link
Member Author

Note for anyone looking into this in future - the relevant code, which shows the current policy for picking a frame to send an annotation to, is

function frameForAnnotation(frames: Frame[], ann: Annotation): Frame | null {
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants