@@ -17,6 +17,8 @@ import type { Terminal as RawXtermTerminal, IMarker as IXtermMarker } from '@xte
1717import { Task } from '../../../tasks/common/taskService.js' ;
1818import { IMarker , IMarkerService } from '../../../../../platform/markers/common/markers.js' ;
1919import { ProblemMatcher , ProblemMatcherRegistry } from '../../../tasks/common/problemMatcher.js' ;
20+ import { Range } from '../../../../../editor/common/core/range.js' ;
21+ import { ILinkLocation } from './taskHelpers.js' ;
2022
2123export const enum PollingConsts {
2224 MinNoDataEvents = 2 , // Minimum number of no data checks before considering the terminal idle
@@ -34,7 +36,7 @@ export const enum PollingConsts {
3436export async function racePollingOrPrompt (
3537 pollFn : ( ) => Promise < { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } > ,
3638 promptFn : ( ) => { promise : Promise < boolean > ; part ?: Pick < ChatElicitationRequestPart , 'hide' | 'onDidRequestHide' > } ,
37- originalResult : { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } ,
39+ originalResult : { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; resources ?: ILinkLocation [ ] ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } ,
3840 token : CancellationToken ,
3941 languageModelsService : ILanguageModelsService ,
4042 markerService : IMarkerService ,
@@ -56,7 +58,6 @@ export async function racePollingOrPrompt(
5658 promptResolved = true ;
5759 return { type : 'prompt' , result } ;
5860 } ) ;
59-
6061 const raceResult = await Promise . race ( [
6162 pollPromiseWrapped ,
6263 promptPromiseWrapped
@@ -105,7 +106,7 @@ export async function pollForOutputAndIdle(
105106 languageModelsService : Pick < ILanguageModelsService , 'selectLanguageModels' | 'sendChatRequest' > ,
106107 markerService : Pick < IMarkerService , 'read' > ,
107108 knownMatchers ?: ProblemMatcher [ ]
108- ) : Promise < { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } > {
109+ ) : Promise < { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; resources ?: ILinkLocation [ ] ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } > {
109110 const maxWaitMs = extendedPolling ? PollingConsts . ExtendedPollingMaxDuration : PollingConsts . FirstPollingMaxDuration ;
110111 const maxInterval = PollingConsts . MaxPollingIntervalDuration ;
111112 let currentInterval = PollingConsts . MinPollingDuration ;
@@ -157,35 +158,19 @@ export async function pollForOutputAndIdle(
157158 }
158159 }
159160 terminalExecutionIdleBeforeTimeout = true ;
161+ let resources : ILinkLocation [ ] | undefined ;
160162 if ( execution . task ) {
161- const problems = await getProblemsForTasks ( execution . task , markerService , execution . dependencyTasks , knownMatchers ) ;
163+ const problems = getProblemsForTasks ( execution . task , markerService , execution . dependencyTasks , knownMatchers ) ;
162164 if ( problems ) {
163165 // Problem matchers exist for this task
164166 const problemList : string [ ] = [ ] ;
165167 for ( const [ , problemArray ] of problems . entries ( ) ) {
168+ resources = [ ] ;
166169 if ( problemArray . length ) {
167170 for ( const p of problemArray ) {
168- let location = '' ;
169- let label = p . resource ? p . resource . path . split ( '/' ) . pop ( ) ?? p . resource . toString ( ) : '' ;
170- let uri = p . resource ? p . resource . toString ( ) : '' ;
171- if ( typeof p . startLineNumber === 'number' && typeof p . startColumn === 'number' ) {
172- uri += `:${ p . startLineNumber } :${ p . startColumn } ` ;
173- label += `:${ p . startLineNumber } :${ p . startColumn } ` ;
174- if ( typeof p . endLineNumber === 'number' && typeof p . endColumn === 'number' ) {
175- uri += `-${ p . endLineNumber } :${ p . endColumn } ` ;
176- label += `-${ p . endLineNumber } :${ p . endColumn } ` ;
177- }
178- } else if ( typeof p . startLineNumber === 'number' ) {
179- uri += `:${ p . startLineNumber } ` ;
180- label += `:${ p . startLineNumber } ` ;
181- } else if ( typeof p . startColumn === 'number' ) {
182- uri += `:${ p . startColumn } ` ;
183- label += `:${ p . startColumn } ` ;
184- }
185- if ( uri ) {
186- location = `[${ label } ](${ uri } )` ;
187- }
188- problemList . push ( `Problem: ${ p . message } at ${ location ? ` ${ location } ` : 'unknown' } ` ) ;
171+ resources . push ( { uri : p . resource , range : new Range ( p . startLineNumber ?? 1 , p . startColumn ?? 1 , p . endLineNumber ?? ( p . startLineNumber ?? 1 ) , p . endColumn ?? ( p . startColumn ?? 1 ) ) } ) ;
172+ const label = p . resource ? p . resource . path . split ( '/' ) . pop ( ) ?? p . resource . toString ( ) : '' ;
173+ problemList . push ( `Problem: ${ p . message } in ${ label } ` ) ;
189174 }
190175 }
191176 }
@@ -195,6 +180,7 @@ export async function pollForOutputAndIdle(
195180 return {
196181 terminalExecutionIdleBeforeTimeout,
197182 output : problemList . join ( '\n' ) ,
183+ resources,
198184 pollDurationMs : Date . now ( ) - pollStartTime + ( extendedPolling ? PollingConsts . FirstPollingMaxDuration : 0 )
199185 } ;
200186 }
0 commit comments