agentFeedbackAttachments.ts ×9

Frontier kind: Code frontier

unlabeled · c_5286fc484079

609 tests · 35780 LOC · 201 files · introduces 0 tests · 48 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges48 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2936 ranges35780 lines · 201 files · Browse complete extent
All tests (intent)
609 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 48 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/meta/agentFeedbackAttachments.ts 48 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentFeedbackAttachments.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { isString } from '../../../../base/common/types.js';
7 > import { MessageAttachmentKind, type MessageAnnotationsAttachment, type MessageAttachment, type SimpleMessageAttachment, type TextRange } from '../state/protocol/state.js';
8 >
9 > export const AgentFeedbackAttachmentDisplayKind = 'agentFeedback';
10 > export const AgentFeedbackAttachmentMetadataKey = 'agentFeedback';
11 >
12 > export interface IAgentFeedbackAttachmentMetadata {
13 > readonly sessionResource: string;
14 > readonly feedbackItems: readonly IAgentFeedbackAttachmentItemMetadata[];
15 > }
16 >
17 > export interface IAgentFeedbackAttachmentItemMetadata {
18 > readonly id: string;
19 > readonly text: string;
20 > readonly resourceUri: string;
21 > readonly range: TextRange;
22 > readonly replies?: readonly string[];
23 > }
24 >
25 > export function isAgentFeedbackAttachment(attachment: MessageAttachment): attachment is SimpleMessageAttachment {
26 return attachment.type === MessageAttachmentKind.Simple && attachment.displayKind === AgentFeedbackAttachmentDisplayKind;
27 }
29 > /**
30 > * Agent feedback is sent to agent-host sessions as one
31 > * {@link MessageAnnotationsAttachment} per submitted comment, each referencing
32 > * the specific annotation(s) on the session's annotations channel. The agent
33 > * reads the comment content via the `listComments` tool and should act on the
34 > * referenced comments.
35 > */
36 > export function isAgentFeedbackAnnotationsAttachment(attachment: MessageAttachment): attachment is MessageAnnotationsAttachment {
37 return attachment.type === MessageAttachmentKind.Annotations && attachment.displayKind === AgentFeedbackAttachmentDisplayKind;
38 }
40 > /**
41 > * Renders an agent-feedback annotations attachment into the textual hint shown
42 > * to the agent. The hint references the attached comment ids and points the
43 > * agent at the `listComments` tool to read their content.
44 > */
45 > export function renderAgentFeedbackAnnotationsAttachment(attachment: MessageAnnotationsAttachment): string | undefined {
46 const ids = attachment.annotationIds?.filter(isString) ?? [];
47 if (ids.length === 0) {
52 'Use the `listComments` tool to read their content and focus on these comments.';
53 }
55 > export function getAgentFeedbackAttachmentMetadata(attachment: MessageAttachment): IAgentFeedbackAttachmentMetadata | undefined {
56 if (!isAgentFeedbackAttachment(attachment) && !isAgentFeedbackAnnotationsAttachment(attachment)) {
57 return undefined;
76 };
77 }
79 function parseAgentFeedbackAttachmentItem(item: unknown): IAgentFeedbackAttachmentItemMetadata | undefined {
80 if (!isRecord(item) || !isString(item.id) || !isString(item.text) || !isString(item.resourceUri)) {
94 };
95 }
97 function parseReplies(value: unknown): readonly string[] | undefined {
98 if (!Array.isArray(value)) {
102 return replies.length > 0 ? replies : undefined;
103 }
105 function parseTextRange(range: unknown): TextRange | undefined {
106 if (!isRecord(range) || !isRecord(range.start) || !isRecord(range.end)) {
114 return { start, end };
115 }
117 function parseTextPosition(position: Record<string, unknown>): TextRange['start'] | undefined {
118 if (typeof position.line !== 'number' || typeof position.character !== 'number') {
121 return { line: position.line, character: position.character };
122 }
124 function isRecord(value: unknown): value is Record<string, unknown> {
125 return typeof value === 'object' && value !== null;