Fix ordered Multiple field producing duplicate RDF list heads#738
Draft
Fix ordered Multiple field producing duplicate RDF list heads#738
Conversation
… safely rebuild Collection in store Agent-Logs-Url: https://github.com/SolidOS/solid-ui/sessions/b5b014b0-8b31-48b8-8b6e-38a780fe55b5 Co-authored-by: SharonStrats <9412507+SharonStrats@users.noreply.github.com>
…ers per code review Agent-Logs-Url: https://github.com/SolidOS/solid-ui/sessions/b5b014b0-8b31-48b8-8b6e-38a780fe55b5 Co-authored-by: SharonStrats <9412507+SharonStrats@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix RDF serialization for ordered multiple fields
Fix ordered Multiple field producing duplicate RDF list heads
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ui:Multiplewithui:ordered trueproduces multiple disconnected list-head triples (subject property _:b1, _:b2, _:b3) instead of a single proper RDF Collection, breaking Turtle serialization and any list-aware consumer.Root cause
Two bugs in
saveListThenRefreshinsrc/widgets/forms.js:1. Stale object-index after in-place mutation
rdflib's
IndexedFormulaindexesCollectionobjects by element content (ExtendedTermFactory.id), not object identity.addItem/deleteThisItem/moveThisItemall mutatelist.elementsafter the Collection is already in the store. The object-index entry is then stale (keyed under the old element content). The subsequentremoveMany()call computes the current (post-mutation) content key, finds no index entry, and throws"Statement to be removed is not on store".2. Duplicate heads on re-fetch
After
putBackinvalidates the fetcher cache,updateManyre-fetches the document. The N3 parser creates a newCollectionwith a different blank-node ID.kb.holds()compares by blank-node ID (viaequals()), so it returnsfalseand adds a secondsubject property Collectiontriple — the duplicate head.Fix
saveListThenRefresh— replaceremoveManywith a safe remove + fresh Collection pattern:kb.statementsMatching(…, null, …)uses the subject/predicate index, bypassing the stale object-index.kb.removeStatementsafely skips a missing object-index entry (rdflib'sif (!this.index[p][h])guard). The freshCollectionis keyed under the current element content, so the next re-fetch call tokb.holds()finds it and suppresses the duplicate.createListIfNecessary— recover an existingCollectionfrom the store before creating a new one (guards against a second head on live-update/reload).refresh()— keeplistin sync with the store's currentCollectionafter external document reloads.Tests
Added
test/unit/widgets/forms/multiple.test.tscovering: existing Collection recovery, lazy list creation,refreshmethod exposure, pre-populated list rendering, reload sync, single add, double add, and reload + add deduplication.