Skip to content

Commit 9fcca59

Browse files
authored
Merge pull request microsoft#257141 from microsoft/tyriar/257132
Add acceptedUserInput to event
2 parents c937d1d + ef0687a commit 9fcca59

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { timeout } from '../../../../../base/common/async.js';
88
import { CancellationToken } from '../../../../../base/common/cancellation.js';
99
import { CancellationError } from '../../../../../base/common/errors.js';
1010
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
11-
import { Disposable } from '../../../../../base/common/lifecycle.js';
11+
import { Disposable, DisposableStore } from '../../../../../base/common/lifecycle.js';
1212
import { OperatingSystem, OS } from '../../../../../base/common/platform.js';
1313
import { count } from '../../../../../base/common/strings.js';
1414
import type { URI } from '../../../../../base/common/uri.js';
@@ -351,6 +351,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
351351
this._sendTelemetry(toolTerminal.instance, {
352352
didUserEditCommand,
353353
didToolEditCommand,
354+
didAcceptUserInput: false,
354355
shellIntegrationQuality: toolTerminal.shellIntegrationQuality,
355356
isBackground: true,
356357
error,
@@ -383,6 +384,13 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
383384

384385
const timingConnectMs = Date.now() - timingStart;
385386

387+
const store = new DisposableStore();
388+
let didAcceptUserInput = false;
389+
const xterm = await toolTerminal.instance.xtermReadyPromise;
390+
if (xterm) {
391+
store.add(xterm.raw.onData(() => didAcceptUserInput = true));
392+
}
393+
386394
let terminalResult = '';
387395
let outputLineCount = -1;
388396
let exitCode: number | undefined;
@@ -420,10 +428,12 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
420428
error = 'threw';
421429
throw e;
422430
} finally {
431+
store.dispose();
423432
const timingExecuteMs = Date.now() - timingStart;
424433
this._sendTelemetry(toolTerminal.instance, {
425434
didUserEditCommand,
426435
didToolEditCommand,
436+
didAcceptUserInput,
427437
isBackground: false,
428438
shellIntegrationQuality: toolTerminal.shellIntegrationQuality,
429439
error,
@@ -592,6 +602,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
592602
private _sendTelemetry(instance: ITerminalInstance, state: {
593603
didUserEditCommand: boolean;
594604
didToolEditCommand: boolean;
605+
didAcceptUserInput: boolean;
595606
error: string | undefined;
596607
isBackground: boolean;
597608
isNewSession: boolean;
@@ -610,6 +621,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
610621
strategy: 0 | 1 | 2;
611622
userEditedCommand: 0 | 1;
612623
toolEditedCommand: 0 | 1;
624+
acceptedUserInput: 0 | 1;
613625
isBackground: 0 | 1;
614626
isNewSession: 0 | 1;
615627
outputLineCount: number;
@@ -628,6 +640,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
628640
strategy: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'What strategy was used to execute the command (0=none, 1=basic, 2=rich)' };
629641
userEditedCommand: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether the user edited the command' };
630642
toolEditedCommand: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether the tool edited the command' };
643+
acceptedUserInput: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether the terminal accepted user input during the execution' };
631644
isBackground: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether the command is a background command' };
632645
isNewSession: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether this was the first execution for the terminal session' };
633646
outputLineCount: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'How many lines of output were produced, this is -1 when isBackground is true or if there\'s an error' };
@@ -642,6 +655,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
642655
strategy: state.shellIntegrationQuality === ShellIntegrationQuality.Rich ? 2 : state.shellIntegrationQuality === ShellIntegrationQuality.Basic ? 1 : 0,
643656
userEditedCommand: state.didUserEditCommand ? 1 : 0,
644657
toolEditedCommand: state.didToolEditCommand ? 1 : 0,
658+
acceptedUserInput: state.didAcceptUserInput ? 1 : 0,
645659
isBackground: state.isBackground ? 1 : 0,
646660
isNewSession: state.isNewSession ? 1 : 0,
647661
outputLineCount: state.outputLineCount,

0 commit comments

Comments
 (0)