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

[Edits] Engine I/O support for editing submitted instances #349

Merged
merged 7 commits into from
Mar 20, 2025

Conversation

eyelidlessness
Copy link
Member

@eyelidlessness eyelidlessness commented Mar 17, 2025

Part of #247.

Note: I've done my best to balance:

I have verified this PR works in these browsers (latest versions):

  • Chrome
  • Firefox
  • Safari (macOS)
  • Safari (iOS)
  • Not applicable

Once again, I don't think there's anything browser specific here!

What else has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

Nearly everything in this PR has already been determined in prior work:

Any other approach would involve reconsidering all of that preliminary work, which I think we'd rather avoid.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

There's one big elephant in the room, which I consider important to address. In its current state, this change includes support for resolving instance attachments which is:

  • purely speculative
  • explicitly and intentionally naive
  • very likely to provide a poor experience under certain network conditions
  • very likely to make servers unhappy
  • very likely to need substantial evolution to address all of the above
  • unprovable until we support instance attachments past input

Given all of those caveats, I intentionally split that aspect of I/O into separate commits:

  1. 9c533b2 introduces logic suitable for resolving both an instance XML resource and any instance attachment resources (keeping in mind the above caveats). That commit also introduces a temporary restriction: if any instance attachment resources are actually present in the input, that aspect of the logic is blocked (i.e. it throws).
  2. 88ee1b9 removes that temporary restriction (i.e. it allows loading instance attachments, with all of the above caveats unaddressed).

(Note: the commits referenced above are present in the branch at time of writing have now been rebased to roll back to the behavior of 1 + link to 2. I'll reword this section more thoughtfully with my morning brains.)

I split the commits this way so it would be trivial for us to roll back to the implemented-albeit-naively-but-blocked state. Which, for this PR (and for the current Central release plan as I understand it)... I highly recommend we do roll it back!

Even if we don't have a clear indication at form load/instance creation time that instance attachments are not supported, we would definitely provide users with a clear indication that Web Forms isn't yet ready to edit instances with attachments.

Do we need any specific form for testing your changes? If so, please attach one.

N/A

What's changed

I think the above pretty much covers it!

Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: 87523b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@getodk/xforms-engine Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eyelidlessness eyelidlessness force-pushed the edit-epic/edit-instance-interface branch 3 times, most recently from 97ef52c to 855f50c Compare March 18, 2025 20:00
Both of these types will have additional usage in the next commit.

Re: `Awaitable`

This type is so general/common, I’m surprised we don’t already have a shared type for it (although our APIs have a lot less asynchrony than many typical JS/TS projects)

Re: `Thunk`

We’ve probably got a bunch of these floating around in some form or another, but I only found one usage _by name_.

Note: there are some cases which technically have the same effective type, but use a different name for clarity (self-documentation, often semantically important). Most of these are the `Accessor` type we import from Solid, where it’s useful to know that a Solid “accessor” is **reactive**. So… let’s not _over-generalize_ this as we come across same-type cases!
@eyelidlessness eyelidlessness force-pushed the edit-epic/edit-instance-interface branch from 855f50c to 7fec2f2 Compare March 18, 2025 20:07
@eyelidlessness eyelidlessness marked this pull request as ready for review March 18, 2025 20:42
@eyelidlessness eyelidlessness force-pushed the edit-epic/edit-instance-interface branch 2 times, most recently from 13a1be0 to c0be03e Compare March 19, 2025 14:18
* - The `odk-instance-first-load` event itself will **NOT** be triggered
*
* - Preload attributes _other than `uid`_ will **NOT** be recomputed
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

@lognaturel This describes both the I/O aspects of this PR, as well as semantics I'm implementing in #352. If you get a chance, could you take a quick look and correct anything I might have gotten wrong about the semantics of the latter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the PR has now been approved, and in the interest of moving forward on #352, I've revised this JSDoc to be less specific about application of the preload="uid" case (matching the current behavior there, pending tests to validate).

Copy link
Collaborator

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you, this was easy to navigate and understand

This generally follows the same patterns as `restoreInstance`, except that we anticipate needing to perform I/O to resolve instance and attachment input.
Note that this has several known limitations, which are detailed in JSDoc `@todo`s on `resolveInstanceAttachmentMapSource`
…7 LOC)…

… commit summary includes a LOC delta to call out that this was specifically done, and done now, to be mindful about concerns expressed over this module’s line count.

This consolidates:

- `Scenario.config`: as a shared/reusable initialization input
- `Scenario.fork`: as a shared mechanism to create a new `Scenario` instance from a new `instanceRoot` (aka engine’s `RootNode`)

This is being done now to prepare for addition in the next commit of another use of `Scenario.fork` for testing initializing instance state for edit.
…dit APIs

Note: as with the preceding commit, this change is intentionally mindful of concerns about the `Scenario.ts` module’s line count. While this does increase the count from the previous commit, it’s still at a net -30 LOC count on this branch.
@eyelidlessness eyelidlessness force-pushed the edit-epic/edit-instance-interface branch from c0be03e to 87523b7 Compare March 20, 2025 14:14
@eyelidlessness eyelidlessness merged commit cbfe1d3 into main Mar 20, 2025
74 checks passed
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