reducer.ts ×7

Frontier kind: Code frontier

unlabeled · c_0927cdde436b

2 tests · 20015 LOC · 87 files · introduces 0 tests · 57 LOC · 5 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges57 lines · 5 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1912 ranges20015 lines · 87 files · Browse complete extent
All tests (intent)
2 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.

5 files ranked by introduced lines: 57 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/state/protocol/channels-annotations/reducer.ts 18 introduced LOC · 7 ranges

Open complete file

28 */
29 export function annotationsReducer(state: AnnotationsState, action: AnnotationsAction, log?: (msg: string) => void): AnnotationsState {
30 > switch (action.type) { reducer.ts
31 > case ActionType.AnnotationsSet: {
32 > const idx = state.annotations.findIndex(t => t.id === action.annotation.id);
33 > if (idx < 0) {
34 > return { ...state, annotations: [...state.annotations, action.annotation] };
35 > }
36 const next: Annotation[] = [...state.annotations];
37 next[idx] = action.annotation;
38 return { ...state, annotations: next };
39 }
40 > reducer.ts
41 > case ActionType.AnnotationsUpdated: {
42 const idx = state.annotations.findIndex(t => t.id === action.annotationId);
43 if (idx < 0) {
62 return { ...state, annotations: next };
63 }
64 > reducer.ts
65 > case ActionType.AnnotationsRemoved: {
66 const idx = state.annotations.findIndex(t => t.id === action.annotationId);
67 if (idx < 0) {
72 return { ...state, annotations: next };
73 }
74 > reducer.ts
75 > case ActionType.AnnotationsEntrySet: {
76 const tIdx = state.annotations.findIndex(t => t.id === action.annotationId);
77 if (tIdx < 0) {
91 return { ...state, annotations: nextAnnotations };
92 }
93 > reducer.ts
94 > case ActionType.AnnotationsEntryRemoved: {
95 const tIdx = state.annotations.findIndex(t => t.id === action.annotationId);
96 if (tIdx < 0) {
108 return { ...state, annotations: nextAnnotations };
109 }
110 > reducer.ts
111 > default:
112 softAssertNever(action, log);
113 return state;
114 > } reducer.ts
115 > }
src/vs/platform/agentHost/node/agentHostStateManager.ts 17 introduced LOC · 2 ranges

Open complete file

501 // a well-formed annotations URI even before the first write.
502 if (isAnnotationsUri(resource)) {
503 > return { agentHostStateManager.ts
504 > resource,
505 > state: this._annotations.get(resource) ?? { annotations: [] },
506 > fromSeq: this._serverSeq,
507 > };
508 > }
509
510 const entry = this._sessionStates.get(resource);
1245
1246 if (isAnnotationsAction(action)) {
1247 > const annotationsAction = action as AnnotationsAction; agentHostStateManager.ts
1248 > const key = channel;
1249 > // Annotations are client-dispatchable and lazily created: seed an
1250 > // empty state on first write rather than dropping the action.
1251 > const state = this._annotations.get(key) ?? { annotations: [] };
1252 > const newState = annotationsReducer(state, annotationsAction, this._log);
1253 > if (newState !== state) {
1254 > this._annotations.set(key, newState);
1255 > }
1256 > resultingState = newState;
1257 > }
1258
1259 // Emit envelope
src/vs/platform/agentHost/node/shared/agentFeedbackServerTools.ts 14 introduced LOC · 1 range

Open complete file

595 },
596 execute(stateManager, chatUri, toolName, rawArgs): string {
597 > // A session can contain multiple chats, each addressed by its own agentFeedbackServerTools.ts
598 > // `ahp-chat` URI but sharing the same context/workspace. Comments belong
599 > // to the session as a whole, so always resolve a chat URI back to its
600 > // owning session and operate on the main session's annotations channel.
601 > const mainSessionUri = parseChatUri(chatUri)?.session ?? chatUri;
602 > const annotationsUri = buildAnnotationsUri(mainSessionUri);
603 > const snapshot = stateManager.getSnapshot(annotationsUri);
604 > const state: AnnotationsState = (snapshot?.state as AnnotationsState | undefined) ?? { annotations: [] };
605 > const outcome = applyFeedbackTool(state, mainSessionUri, toolName, rawArgs);
606 > for (const action of outcome.actions) {
607 > stateManager.dispatchServerAction(annotationsUri, action);
608 > }
609 > return outcome.result;
610 > },
611 };
src/vs/platform/agentHost/common/annotationsUri.ts 4 introduced LOC · 2 ranges

Open complete file

36 return undefined;
37 }
38 > const sessionUri = uri.slice(0, uri.length - ANNOTATIONS_PATH_SEGMENT.length); annotationsUri.ts
39 > if (!sessionUri) {
40 return undefined;
41 }
42 > return { sessionUri }; annotationsUri.ts
43 > }
44
45 /** Returns `true` iff `uri` is a session's annotations channel URI. */
src/vs/platform/agentHost/node/shared/agentServerToolHost.ts 4 introduced LOC · 2 ranges

Open complete file

136
137 executeTool(sessionUri: URI, toolName: string, rawArgs: unknown): string | Promise<string> {
138 > const group = this._groupByToolName.get(toolName); agentServerToolHost.ts
139 > if (!group) {
140 throw new Error(`Unknown server tool: ${toolName}`);
141 }
142 > return group.execute(this._stateManager, sessionUri, toolName, rawArgs); agentServerToolHost.ts
143 > }
144 }