feat: allow any URI or a local name in agent placeholders - #660
Merged
Conversation
The agent placeholder offered a typed term only when it started with http(s):// or matched the ORCID pattern, so a URI in one of the other allowed schemes, or a name to be minted locally, could not be entered at all: the dropdown just said "No results found". Only the dropdown was in the way. TemplateContext already mints a plain name under the namespace of the nanopublication being published, and the validator already accepted one. - Offer any URI in an allowed scheme (Utils.isUriValue), not just http(s). - Offer a plain name that the validator accepts as a locally minted identifier, last in the list, so that matching known users keep the top. - Show a value that will be minted as "local:john (mint locally)", the note being set apart from the term itself. The rule lives in TemplateContext.isToBeMinted, mirroring processValue, and is used by the guided and restricted choice items too, where such a value can turn up after a fill. - Don't blow up on a value that is not a URI (createIRI throws), and show a value with no known name once rather than as "value (value)". - Use the generic user icon, not the logged-in user's picture, for an agent that isn't a parseable IRI. - Blank the href of a URI link built on a model when the value is not a URI, the way the String overload already does for local URIs. Closes #652 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A guided choice suggests values but does not limit them, so a plain name for a resource that has no identifier yet belongs there as much as in the agent placeholder: it is minted under the prefix of the field, or under the namespace of the nanopublication when the field has none, in which case the value is shown as "local:john (mint locally)" as well. A restricted choice, on the other hand, is meant to be restricted. It never offered such a name, and it no longer marks one either. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
In the selected choice the value is an inline-block pushed down by 3px, so the note next to it, being a plain inline span, sat that much higher. It gets the same treatment now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@ashleycaselli See this. |
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.
Closes #652.
The agent placeholder offered a typed term only when it started with
http(s)://or matched the ORCID pattern, so a URI in one of the other allowed schemes (did:,ipfs:, …) or a name to be minted locally could not be entered at all — the dropdown just said "No results found".Only the dropdown was in the way:
TemplateContextalready mints a plain name under the namespace of the nanopublication being published, andIriTextfieldItem.Validatoralready accepted one.Changes
Utils.isUriValue), not just http(s) ones.Utils.isPlainName) — last in the list, so that the known users or suggestions a term matches keep the top and a free-form option never preempts the highlighted first entry. This goes for guided choices as well: they suggest values but don't limit them, so a name for a resource that has no identifier yet belongs there too, minted under the prefix of the field or under the namespace of the nanopublication when the field has none.span.mint-note, normal weight, italic —.select2-dropdown span.termis bold). The rule lives inTemplateContext.isToBeMinted, mirroringprocessValue, so a value under a prefix — minted under that prefix, which the field shows next to it — is not marked.createIRIthrows), and render a value with no known name once instead of as "value (value)" — which also affected unknown http URIs before.Stringoverload already does for local URIs.Verification
AgentChoiceItemTest(9 tests) andGuidedChoiceItemTest(6 tests, one of them asserting that a restricted choice offers no made-up name) cover the suggestions, the display value and the minting; full suite green (1230 tests).Driven in a browser on "Assigning a team member to a Space" — agent placeholder:
johnlocal:john (mint locally)did:plc:z72i7hdynmk6r22z27h6tvurjohn doe(with a space)0000-0002-1267-0234and its guided-choice space field:
nanodashlocal:nanodash (mint locally)my-new-spacelocal:my-new-space (mint locally)my new spaceSelecting the local name and hitting Preview signs a nanopub whose team member is
https://w3id.org/np/RAXwGpQe…/john.🤖 Generated with Claude Code