Skip to content

Commit 7cadbfc

Browse files
benibenjCopilot
andauthored
Artifact integrations: keep references in the References pill and present item actions on their item (#347045)
* Artifact integrations: keep references in the References pill and present item actions on their item Only artifacts get a pill of their own from their integration's group ID. A reference, such as an ExP scorecard or a commit, is now listed in the References pill with the other references instead of in a single pill of its own, and a reference to the resource of an artifact with a pill of its own is represented by that artifact. A prompt that an item action runs for one details item, such as Fix Issue on one of a test plan item's reported issues, is now presented in chat as that item action on that item alone, rather than as the artifact action on every item it could apply to. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Artifact integrations: address review feedback on references and item action capture - A new extension details model starts from the latest details the extension sent for that list, rather than those from when the integration was created, so the request for an item action finds an item listed since. When the details no longer list the item, the request names the item action without the details of every item. - A reference is no longer hidden behind an artifact with a pill of its own. That pill's filters, such as showing only open pull requests, could hide both, and the reference's pin could not be shown or cleared. The reference stays in the References pill with the other references. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2b5417b commit 7cadbfc

11 files changed

Lines changed: 235 additions & 27 deletions

File tree

‎src/vs/platform/agentHost/ARTIFACT_INTEGRATIONS_PROPOSAL.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,11 @@ interface ArtifactContributionView {
527527

528528
`ArtifactIcon.id` and `colorId` reference registered icons and theme colors; a missing color uses the normal foreground. This permits domain colors such as a merged PR's icon without accepting arbitrary CSS or hardcoded RGB values. Color always accompanies a text meaning.
529529

530-
The main integration decides, per artifact, whether the artifact gets a pill of its own. An artifact whose main integration assigns a `groupId` is presented in a dedicated pill; without one, the artifact is listed in the client's ordinary pill for its kind, such as Artifacts or References, alongside unintegrated records, with the integration's icon and label. Activating such a row opens the artifact's details, a row action opens the resource, and an artifact that is its pill's only entry renders as its full integration pill. The ID can follow the resource's state, but changing it moves the artifact between pills, so integrations should keep it stable.
530+
The main integration decides, per artifact, whether the artifact gets a pill of its own. An artifact whose main integration assigns a `groupId` is presented in a dedicated pill; without one, the artifact is listed in the client's ordinary pill for its kind, such as Artifacts, alongside unintegrated records, with the integration's icon and label. References are always listed in the References pill with the other references, whatever their `groupId`. Activating such a row opens the artifact's details, a row action opens the resource, and an artifact that is its pill's only entry renders as its full integration pill. The ID can follow the resource's state, but changing it moves the artifact between pills, so integrations should keep it stable.
531531

532-
When several recorded artifacts share a `groupId`, including artifacts of different integrations, the client may present them as one group whose members keep their own segmented controls in a list. References assigned a `groupId` keep a pill of their own and never join a group. The main integration names such a group with a fixed, registration-level `groupLabel`, such as "Pull Requests", taken from the group's first artifact; each artifact's optional `group` supplies the icon the group shows and a priority, so a group of pull requests shows a failing pull request's icon over an open one's. Only the main integration's `groupId` and `group` are consulted, and priorities are compared only among the group's artifacts; the client picks the highest priority and keeps the earlier artifact on ties. Without a `groupLabel` or `group`, the client falls back to the integration label and the first artifact's main icon. Grouping is presentation only: it never merges bindings, consent, runs, or details.
532+
When several recorded artifacts share a `groupId`, including artifacts of different integrations, the client may present them as one group whose members keep their own segmented controls in a list. References never join a group. The main integration names such a group with a fixed, registration-level `groupLabel`, such as "Pull Requests", taken from the group's first artifact; each artifact's optional `group` supplies the icon the group shows and a priority, so a group of pull requests shows a failing pull request's icon over an open one's. Only the main integration's `groupId` and `group` are consulted, and priorities are compared only among the group's artifacts; the client picks the highest priority and keeps the earlier artifact on ties. Without a `groupLabel` or `group`, the client falls back to the integration label and the first artifact's main icon. Grouping is presentation only: it never merges bindings, consent, runs, or details.
533533

534-
Each contribution exposes its binding's canonical `resourceKey`, the match key that identifies aliases of the same resource. When the main integration binds several recorded artifacts or references to the same resource, such as several scorecard links of one experiment step, the client shows them once, keeping the first artifact among them, else the first reference. Like grouping, this is presentation only: each record keeps its own binding, consent, runs, and recorded label. A record with enabled Autopilot rules or activity remains visible, since only its own entry reaches its controls, and a dedicated pill stays pinned while any alias it hides is pinned; unpinning it clears every such pin.
534+
Each contribution exposes its binding's canonical `resourceKey`, the match key that identifies aliases of the same resource. When the main integration binds several recorded artifacts or references to the same resource, such as several scorecard links of one experiment step, the client shows them once, keeping the first artifact among them, else the first reference. An artifact with a pill of its own stands in only for its aliases among the other artifacts with pills of their own: its pill's filters can hide it and its pins are kept apart, so a reference to its resource stays listed in the References pill. Like grouping, this is presentation only: each record keeps its own binding, consent, runs, and recorded label. A record with enabled Autopilot rules or activity remains visible, since only its own entry reaches its controls, and a dedicated pill stays pinned while any alias it hides is pinned; unpinning it clears every such pin.
535535

536536
The main part's label may be a provider-supplied display label, but it does not rewrite the recorded label, resource, or provenance. Its open target always comes from the artifact record. `main` is optional for integrations that only contribute sections/actions; the generic artifact presentation is the fallback.
537537

‎src/vs/platform/artifactIntegrations/common/artifactExecutionService.ts‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { URI } from '../../../base/common/uri.js';
1616
import { generateUuid } from '../../../base/common/uuid.js';
1717
import { localize } from '../../../nls.js';
1818
import { ILogService } from '../../log/common/log.js';
19-
import { ArtifactAction, ArtifactActionRejectedError, ArtifactActor, ArtifactJsonValue, ArtifactAutomationOption, ArtifactAutomationRequest, ArtifactContributionView, ArtifactDetails, ArtifactRecord, ArtifactRequestPresentation, ArtifactRun, IArtifactActionContext, IArtifactIntegrationBinding, artifactOptionDisabledValue, getArtifactActionAvailability, getArtifactRunInitiator, isArtifactOptionEnabled, isArtifactRunSettled } from './artifactIntegration.js';
19+
import { ArtifactAction, ArtifactActionRejectedError, ArtifactActor, ArtifactJsonValue, ArtifactAutomationOption, ArtifactAutomationRequest, ArtifactContributionView, ArtifactDetails, ArtifactRecord, ArtifactRequestPresentation, ArtifactRun, IArtifactActionContext, IArtifactIntegrationBinding, artifactOptionDisabledValue, getArtifactActionAvailability, getArtifactRunInitiator, isArtifactItemActionInput, isArtifactOptionEnabled, isArtifactRunSettled } from './artifactIntegration.js';
2020
import { artifactActionConsent, artifactOptionConsent } from './artifactAutomationConfiguration.js';
2121
import { ArtifactConfigurationConflictError, ArtifactIntegrationState, ArtifactIntegrationStore, ArtifactRetryLimitError, ArtifactStoredBinding } from './artifactIntegrationStore.js';
2222
import { isArtifactJsonValue } from './artifactIntegrationValidation.js';
@@ -669,12 +669,13 @@ export class ArtifactExecutionService extends Disposable {
669669

670670
private capturePresentation(binding: IArtifactExecutionBinding, action: ArtifactAction, run: ArtifactRun, promptDetails: readonly ArtifactDetails[] | undefined): ArtifactRequestPresentation {
671671
const view = binding.presentation.get();
672-
const details = promptDetails ? this.capturePromptDetails(action, promptDetails) : this.captureLinkedDetails(binding, action, view);
672+
const item = this.captureItem(binding, action, run);
673+
const details = promptDetails ? this.capturePromptDetails(action, promptDetails) : item ? item.details : this.captureLinkedDetails(binding, action, view);
673674
return {
674675
version: 1,
675676
integrationLabel: binding.integrationLabel,
676677
source: run.source,
677-
action: { label: action.label, iconId: action.iconId },
678+
action: item?.action ?? { label: action.label, iconId: action.iconId },
678679
artifact: {
679680
resource: binding.artifact.resource,
680681
label: view.main?.label ?? binding.artifact.label,
@@ -729,6 +730,46 @@ export class ArtifactExecutionService extends Disposable {
729730
return details;
730731
}
731732

733+
/**
734+
* A run an item action started for one details item, such as fixing one of several reported issues, is presented
735+
* as that item action on that item alone, rather than as the artifact action on every item it could apply to. When
736+
* the details no longer list the item, the request names the item action without any details.
737+
*/
738+
private captureItem(binding: IArtifactExecutionBinding, action: ArtifactAction, run: ArtifactRun): { readonly action: ArtifactRequestPresentation['action']; readonly details: readonly ArtifactDetails[] } | undefined {
739+
const input = run.input;
740+
if (!isArtifactItemActionInput(input)) {
741+
return undefined;
742+
}
743+
try {
744+
const model = binding.provider.acquireDetails(input.detailsId);
745+
try {
746+
const snapshot = model.details.get();
747+
if (!isArtifactDetails(snapshot)) {
748+
return undefined;
749+
}
750+
const item = snapshot.items.find(candidate => candidate.id === input.itemId);
751+
const itemAction = snapshot.itemActions?.find(candidate => candidate.actionId === action.id && (!item || item.actions?.includes(candidate.id)));
752+
if (!itemAction) {
753+
return undefined;
754+
}
755+
const presentedAction = { label: itemAction.label, iconId: itemAction.iconId };
756+
if (!item) {
757+
return { action: presentedAction, details: [] };
758+
}
759+
const { actions: _, ...presented } = item;
760+
return {
761+
action: presentedAction,
762+
details: [deepClone({ title: snapshot.title, availability: snapshot.availability, links: [], items: [presented], completeness: 'complete' })],
763+
};
764+
} finally {
765+
model.dispose();
766+
}
767+
} catch (error) {
768+
this.logService.error('[ArtifactIntegrations] Could not capture the item an action runs for', error);
769+
return undefined;
770+
}
771+
}
772+
732773
private context(binding: IArtifactExecutionBinding, run: ArtifactRun): IArtifactActionContext {
733774
return { authority: this.runtime.authority, session: binding.session, artifact: binding.artifact, integrationId: binding.integrationId, run };
734775
}

‎src/vs/platform/artifactIntegrations/common/artifactIntegration.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export interface ArtifactContributionView {
107107
/**
108108
* Gives the artifact a pill of its own, shared with the other artifacts whose main integration assigns the same ID,
109109
* including those of other integrations. Without one, the artifact is listed in the pill for its kind, such as
110-
* Artifacts, with the other artifacts. Only the main integration's ID is consulted.
110+
* Artifacts, with the other artifacts. References are always listed in the References pill. Only the main
111+
* integration's ID is consulted.
111112
*/
112113
readonly groupId?: string;
113114
/** This artifact's contribution to a group of several artifacts sharing its {@link groupId}. */
@@ -144,6 +145,15 @@ export interface ArtifactItemActionInput {
144145
readonly itemId: string;
145146
}
146147

148+
/** Whether a run's input names the details item it runs for, as an item action's registered action receives. */
149+
export function isArtifactItemActionInput(value: ArtifactJsonValue | undefined): value is ArtifactItemActionInput {
150+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
151+
return false;
152+
}
153+
const fields = value as { readonly [key: string]: ArtifactJsonValue };
154+
return typeof fields.detailsId === 'string' && typeof fields.itemId === 'string';
155+
}
156+
147157
export interface ArtifactDetailsItem {
148158
readonly id: string;
149159
readonly icon: ArtifactIcon;

‎src/vs/platform/artifactIntegrations/test/common/artifactIntegrations.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,36 @@ suite('Artifact Integrations', () => {
12901290
});
12911291
}));
12921292

1293+
const presentedIssue = { id: '2', label: '#2', icon: { id: 'issues' }, resource: 'https://github.com/o/r/issues/2' };
1294+
for (const [itemId, expectedDetails] of [
1295+
['2', [{ title: 'Reported Issues', availability: { kind: 'available' }, links: [], items: [presentedIssue], completeness: 'complete' }]],
1296+
// The details no longer list the item, so the request names the item action without the details of every item.
1297+
['3', []],
1298+
] as const) {
1299+
test(`a prompt an item action starts for ${itemId === '2' ? 'a listed' : 'an unlisted'} item is presented as that action on its own item`, () => run(async store => {
1300+
const f = fixture(store, { id: 'fix', label: 'Fix Issues…', iconId: 'sparkle', kind: 'prompt', prepare: async () => ({ kind: 'ready', value: { text: `Fix #${itemId}` } }) });
1301+
const model = store.add(await f.service.acquireArtifact('session', artifact.id)).object;
1302+
const binding = f.bindings[0];
1303+
const issue = (id: string) => ({ id, label: `#${id}`, icon: { id: 'issues' }, resource: `https://github.com/o/r/issues/${id}`, actions: ['fixIssue'] });
1304+
const issues = {
1305+
title: 'Reported Issues', description: '2 open issues', availability: { kind: 'available' as const },
1306+
facts: [{ id: 'open', label: 'Open', value: '2' }],
1307+
links: [{ kind: 'action' as const, actionId: 'fix' }],
1308+
itemActions: [{ id: 'fixIssue', label: 'Fix Issue', iconId: 'wand', actionId: 'fix' }],
1309+
items: [issue('1'), issue('2')],
1310+
completeness: 'partial' as const,
1311+
};
1312+
binding.view.set({ ...binding.view.get(), lists: [{ id: 'issues', label: 'Reported Issues', detailsId: 'issues' }] }, undefined);
1313+
binding.acquireDetails = (detailsId = 'main') => ({ details: constObservable(detailsId === 'issues' ? issues : binding.details.get()), dispose: () => { } });
1314+
const requested = await model.invoke('test', 'fix', 'invoking-chat', 'manual', undefined, { detailsId: 'issues', itemId });
1315+
await waitForState(f.service.ledger.state, state => state.runs.some(run => run.id === requested.id && run.state === 'submitted'));
1316+
assert.deepStrictEqual({ action: f.submitted[0].presentation?.action, details: f.submitted[0].presentation?.details }, {
1317+
action: { label: 'Fix Issue', iconId: 'wand' },
1318+
details: expectedDetails,
1319+
});
1320+
}));
1321+
}
1322+
12931323
for (const source of ['manual', 'automation'] as const) {
12941324
test(`retains an asynchronously loaded chat while admitting ${source} prompts`, () => run(async store => {
12951325
const action: ArtifactAction = { id: 'act', label: 'Analyse', iconId: 'search', kind: 'prompt', prepare: async () => ({ kind: 'ready', value: { text: 'Analyse' } }) };

0 commit comments

Comments
 (0)