Skip to content

Commit 98cdb63

Browse files
authored
improve task problem rendering (microsoft#261675)
1 parent 2a1c679 commit 98cdb63

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/bufferOutputPolling.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ChatMessageRole, ILanguageModelsService } from '../../../chat/common/la
1515
import { IToolInvocationContext } from '../../../chat/common/languageModelToolsService.js';
1616
import type { Terminal as RawXtermTerminal, IMarker as IXtermMarker } from '@xterm/xterm';
1717
import { Task } from '../../../tasks/common/taskService.js';
18-
import { IMarkerData, IMarkerService } from '../../../../../platform/markers/common/markers.js';
18+
import { IMarker, IMarkerService } from '../../../../../platform/markers/common/markers.js';
1919
import { ProblemMatcher, ProblemMatcherRegistry } from '../../../tasks/common/problemMatcher.js';
2020

2121
export const enum PollingConsts {
@@ -165,7 +165,27 @@ export async function pollForOutputAndIdle(
165165
for (const [, problemArray] of problems.entries()) {
166166
if (problemArray.length) {
167167
for (const p of problemArray) {
168-
problemList.push(`${p.severity}: ${p.message}`);
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'}`);
169189
}
170190
}
171191
}
@@ -252,8 +272,8 @@ export async function assessOutputForErrors(buffer: string, token: CancellationT
252272
}
253273
}
254274

255-
export function getProblemsForTasks(task: Pick<Task, 'configurationProperties'>, markerService: Pick<IMarkerService, 'read'>, dependencyTasks?: Task[], knownMatchers?: ProblemMatcher[]): Map<string, IMarkerData[]> | undefined {
256-
const problemsMap = new Map<string, IMarkerData[]>();
275+
export function getProblemsForTasks(task: Pick<Task, 'configurationProperties'>, markerService: Pick<IMarkerService, 'read'>, dependencyTasks?: Task[], knownMatchers?: ProblemMatcher[]): Map<string, IMarker[]> | undefined {
276+
const problemsMap = new Map<string, IMarker[]>();
257277
let hadDefinedMatcher = false;
258278

259279
const collectProblems = (t: Pick<Task, 'configurationProperties'>) => {

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/runTaskTool.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ export class RunTaskTool implements IToolImpl {
9999
});
100100
}
101101

102-
let output = '';
102+
let resultSummary = '';
103103
if (result?.exitCode) {
104-
output = localize('copilotChat.taskFailedWithExitCode', 'Task `{0}` failed with exit code {1}.', taskLabel, result.exitCode);
104+
resultSummary = localize('copilotChat.taskFailedWithExitCode', 'Task `{0}` failed with exit code {1}.', taskLabel, result.exitCode);
105105
} else {
106-
output += `\`${taskLabel}\` task `;
107-
output += terminalResults.every(r => r.idle)
106+
resultSummary += `\`${taskLabel}\` task `;
107+
resultSummary += terminalResults.every(r => r.idle)
108108
? 'finished'
109109
: 'started and will continue to run in the background.';
110110
}
111111

112112
const details = terminalResults.map(r => `Terminal: ${r.name}\nOutput:\n${r.output}`).join('\n\n');
113113
return {
114-
content: [{ kind: 'text', value: `Task output summary:\n${details}` }],
115-
toolResultMessage: new MarkdownString(output)
114+
content: [{ kind: 'text', value: details }],
115+
toolResultMessage: new MarkdownString(resultSummary)
116116
};
117117
}
118118

0 commit comments

Comments
 (0)