Skip to content

feat: allow any URI or a local name in agent placeholders - #660

Merged
tkuhn merged 3 commits into
masterfrom
feat/652-any-uri-agent-placeholder
Aug 28, 2026
Merged

feat: allow any URI or a local name in agent placeholders#660
tkuhn merged 3 commits into
masterfrom
feat/652-any-uri-agent-placeholder

Conversation

@tkuhn

@tkuhn tkuhn commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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: TemplateContext already mints a plain name under the namespace of the nanopublication being published, and IriTextfieldItem.Validator already accepted one.

Changes

  • Offer any URI in an allowed scheme (Utils.isUriValue), not just http(s) ones.
  • Offer a plain name that the validator accepts (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.
  • Restricted choices are left restricted: they don't offer such a name and don't mark one.
  • Show a value that will be minted locally as local:john (mint locally), the note set apart from the term itself (span.mint-note, normal weight, italic — .select2-dropdown span.term is bold). The rule lives in TemplateContext.isToBeMinted, mirroring processValue, so a value under a prefix — minted under that prefix, which the field shows next to it — is not marked.
  • Don't blow up on a value that is not a URI (createIRI throws), and render a value with no known name once instead of as "value (value)" — which also affected unknown http URIs before.
  • Use the generic user icon rather than 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.

Verification

AgentChoiceItemTest (9 tests) and GuidedChoiceItemTest (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:

typed dropdown
john the matching John users, then local:john (mint locally)
did:plc:z72i7hdynmk6r22z27h6tvur the DID as-is
john doe (with a space) only the matching users — it can't be minted, so it isn't offered
0000-0002-1267-0234 the ORCID URI only, no near-duplicate

and its guided-choice space field:

typed dropdown
nanodash the Nanodash space, then local:nanodash (mint locally)
my-new-space local:my-new-space (mint locally)
my new space No results found

Selecting the local name and hitting Preview signs a nanopub whose team member is https://w3id.org/np/RAXwGpQe…/john.

🤖 Generated with Claude Code

tkuhn and others added 3 commits August 28, 2026 12:51
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>
@tkuhn
tkuhn merged commit d197efa into master Aug 28, 2026
8 checks passed
@tkuhn
tkuhn deleted the feat/652-any-uri-agent-placeholder branch August 28, 2026 12:05
@tkuhn

tkuhn commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@ashleycaselli See this.

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.

Allow for any URI in agent placeholder

1 participant