Repository navigation
Make the Copilot's entity context selector navigable (order, hierarchy, placement, click-to-focus) #350
Ron-Brouwer
started this conversation in
Ideas
Replies: 2 comments
|
Moved to discussions as it's a feature request rather than a bug. |
0 replies
|
The block focus turns out to be confusing. When the copilot is running clicking a block would shift focus. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Feature request: make the Copilot's entity context selector navigable
Repo:
umbraco/Umbraco.AIVersions:
Umbraco.AI17.4.0-rc.2,Umbraco.AI.Agent.Copilot17.1.0-rc.2,Umbraco.AI.Agent.UI17.1.0-rc.2, Umbraco CMS 17.6.2Summary
The Copilot's entity selector renders one chip per detected entity. On a content page with a block list this does not scale.
Concretely, on one of our pages: a document chip labelled "11 tips voor het maken van een goede contactpagina" followed by ten chips that all read "Block", wrapping over four rows and taking up the top fifth of the panel before the conversation has started. They are not in the order the blocks appear on the page, and a block nested inside another block looks exactly like a top-level one. Picking the right chip is guesswork.
Three concrete defects, then a proposal. The proposal runs today as a local App_Plugin (source at the bottom) and works on every block, so this is not a question of missing API. What a third party cannot do is fix the list it is working around.
Defect 1 — the order does not match the page
The chips are not in document order, and the cause is mechanical.
UaiWorkspaceRegistryContext.getAll()returns aMap's values, so insertion order:_rekey()deletes and re-sets, which in a JSMapmoves the entry to the end:And every workspace is first registered under a temporary key, then re-keyed once its
uniqueobservable emits (workspace.decorator.ts):Net effect: the final order is the order in which those observables happened to resolve — asynchronous and timing dependent — not the order the blocks appear in on the page.
UaiEntityAdapterContext.#refresh()iteratesgetAll()directly, so the selector inherits it.This looks fixable on its own, independent of the rest of this request.
Related side effect worth a look:
#refresh()picks the fallback selection asdetected[detected.length - 1], commented "Auto-select deepest (last)". Under this ordering that is not reliably the deepest entity — it is whichever one re-keyed last.Defect 2 — no hierarchy is visible
A block nested inside another block looks identical to a top-level block. Indenting nested entries in the list would make the list readable even before anything else changes.
The relationship is available:
Block Grid carries it explicitly.
UmbBlockGridWorkspaceOriginDataholdsparentUniqueandareaKey, and the grid entries context tracks them:Block List nested inside a block has no origin data for it — the nesting runs through the property editor tree instead — but it is derivable from context ancestry.
UmbContextConsumerdefaults tostopAtContextMatch, so a request resolves to the innermostUmbBlockEntryContext; the plugin below relies on exactly that.Defect 3 — placement and space
The row sits at the top of the panel and grows downward: eleven chips over four rows on the page described above, before the conversation has started. Even with labels fixed (see the related bug report) and ordering fixed, a page with a few dozen blocks will not fit — and long labels make it worse, not better.
Suggestion: move it to the bottom, directly above the chat input, and make it a fixed-height control rather than a growing row.
Copilot in Visual Studio is a reasonable reference for the shape. It puts a single compact row immediately above the input: a
+button to add context, then one chip per active context item — "Active Document" — each with an×to remove it, with the input directly below and the agent and model pickers under that. The row never wraps; additional context lives behind the+rather than expanding into the conversation area. Applied here that would mean the active entity visible as one chip, the rest reachable through a dropdown.This one genuinely cannot be done from outside the package:
uai-entity-selectoris a plain@customElementused in the Copilot panel template, not a manifest-driven slot. Third parties can add selection behaviour alongside it, but cannot replace or condense the UI.Proposal: click a block to make it the active entity
Rather than hunting for the right chip, click the block in the workspace.
The selection half is already fully supported from outside the package, which is why the proof of concept is small:
UAI_COPILOT_CONTEXTis registered as aglobalContext, so it is reachable from anywhere in the DOM tree — including from a block in the document workspace, which is not inside the Copilot panel.It exposes
setSelectedEntityKey(key), where the key is`${entityType}:${unique}`.A block workspace's
uniqueis the block'scontentKey:UmbBlockEntryContextknows that samecontentKey.So the whole bridge is: resolve the nearest block entry from the click, and hand its key over.
Why this belongs in the package
The plugin below works in practice: clicking any block in the list makes it the Copilot's active entity, collapsed or expanded. So this is not blocked on missing API — the behaviour is a small amount of code on top of what is already public.
It belongs upstream because of the three defects above, and because the one thing a third party cannot touch is the selector UI itself (defect 3). Behaviour can be added alongside it; the row cannot be replaced or condensed.
One robustness note for whoever implements it.
UaiEntityAdapterContext.#refresh()overwrites a selection whose key is not in the detected list:The plugin therefore only sets a key it can already see in
detectedEntities$, so that a click can never snap the selection to some unrelated entity. On the pages we tested, every block in a block list has a live workspace context and the guard simply passes — but a built-in implementation would want to decide deliberately what should happen when it does not, rather than inheriting the fallback.Working example
This runs today as an App_Plugin against the versions listed above. It uses context aliases rather than imported tokens because
UAI_COPILOT_CONTEXTlives in an@umbraco-ai/*package whose availability to third-party App_Plugins we do not control.umbraco-package.json:{ "alias": "TP.CopilotBlockFocus", "name": "TP Copilot Block Focus", "version": "1.0.0", "extensions": [ { "type": "appEntryPoint", "alias": "TP.CopilotBlockFocus.EntryPoint", "name": "Copilot Block Focus", "js": "/App_Plugins/TP.CopilotBlockFocus/copilot-block-focus.js" } ] }copilot-block-focus.js:Related
The chips being labelled "Block" is filed separately as #343. It is independent of this request, but it is a large part of why the row is unusable rather than merely cramped.
All reactions