JavaScript: prodigy.update(...) doesn't trigger a re-render

I'm currently playing around with Prodigy's JavaScript API and ran into a problem when using the update(...) function. The documentation says that it will trigger a shallow merge of the current task object. Since the frontend is based on React/Redux and I get back the corresponding UPDATE_TASK action object, I was expecting the UI to re-render based on the state update I provided, but this was not the case.

I'm running the latest Prodigy version and am using the ner_manual interface, my goal was to play around with other methods for adding the entity spans. Unfortunately not getting visual feedback for the updated span state is kind of a dealbreaker for that :slight_smile:

I'm updating the spans on the current task like this:

prodigy.update({
  spans: [
    ...prodigy.content.spans,
    { start: 0, end: 5, token_start: 0, token_end: 0,
       label: 'PER' }
]})

This will return the corresponding Redux action (UPDATE_TASK) with the correct data, and prodigy.content also contains the updated task. However, the UI does not seem to re-render. It also seems that the update corrupted the state, since I can now also no longer add a span on the token targeted by my custom span via the regular interface. If I then add another span via the regular interface, the span I added via update disappears again, but I'm still not able to click-select a span to the token targeted by it.

Good point – this makes sense, because exposing the update method wasn't originally designed for this kind of use case and was mostly supposed to support custom interfaces and adding arbitrary content to the current task object. The manual spans interface keeps separate state of the spans etc. and doesn't only use the current task object as the single source of truth. So just calling update doesn't currently work here. It currently needs a different internal method that then delegates to update.

I think it should be possible to adjust the interface to make this use case possible, and I also think it shouldn't be a problem for the other interfaces (most of them probably already do support it).

1 Like

Thanks for clarifying! It's not really an urgent need for me at the moment, I just noticed it while exploring the API.
Maybe there should be a note in the documentation about this, though. I'm probably not the only one jumping to conclusions on what update does :slight_smile: Especially since the "uppercase the text" example mutates the task state, which does result in a re-render (probably because this is happening in the html view?)