5
5
6
6
import { strictEqual , deepStrictEqual } from 'assert' ;
7
7
import { timeout } from '../../../../../../base/common/async.js' ;
8
- import { CancellationTokenSource } from '../../../../../../base/common/cancellation.js' ;
8
+ import { CancellationTokenSource , type CancellationToken } from '../../../../../../base/common/cancellation.js' ;
9
9
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js' ;
10
10
import { ILanguageModelsService } from '../../../../chat/common/languageModels.js' ;
11
11
import { OutputMonitor , OutputMonitorAction } from '../../browser/outputMonitor.js' ;
12
12
13
+ class TestOutputMonitor extends OutputMonitor {
14
+ async internalStartMonitoring ( extendedPolling : boolean , token : CancellationToken ) : Promise < { terminalExecutionIdleBeforeTimeout : boolean ; output : string ; pollDurationMs ?: number ; modelOutputEvalResponse ?: string } > {
15
+ return super . _startMonitoring ( extendedPolling , token ) ;
16
+ }
17
+ }
18
+
13
19
suite ( 'OutputMonitor' , ( ) => {
14
20
const store = ensureNoDisposablesAreLeakedInTestSuite ( ) ;
15
21
@@ -51,7 +57,7 @@ suite('OutputMonitor', () => {
51
57
52
58
test ( 'should implement IOutputMonitor interface' , ( ) => {
53
59
const execution = createMockExecution ( [ '' ] ) ;
54
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
60
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
55
61
store . add ( monitor ) ;
56
62
57
63
// Verify core interface properties exist
@@ -61,17 +67,16 @@ suite('OutputMonitor', () => {
61
67
strictEqual ( monitor . onDidIdle !== undefined , true ) ;
62
68
strictEqual ( monitor . onDidTimeout !== undefined , true ) ;
63
69
strictEqual ( monitor . startMonitoring !== undefined , true ) ;
64
- strictEqual ( monitor . startMonitoringLegacy !== undefined , true ) ;
65
70
strictEqual ( monitor . dispose !== undefined , true ) ;
66
71
} ) ;
67
72
68
73
test ( 'should track actions correctly' , async ( ) => {
69
74
const execution = createMockExecution ( [ 'output1' , 'output1' , 'output1' ] ) ; // No new output to trigger idle
70
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
75
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
71
76
store . add ( monitor ) ;
72
77
73
78
const tokenSource = new CancellationTokenSource ( ) ;
74
- const result = monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
79
+ const result = monitor . internalStartMonitoring ( false , tokenSource . token ) ;
75
80
76
81
// Give it some time to start and detect idle
77
82
await timeout ( 100 ) ;
@@ -86,7 +91,7 @@ suite('OutputMonitor', () => {
86
91
87
92
test ( 'should detect idle state when no new output' , async ( ) => {
88
93
const execution = createMockExecution ( [ 'initial output' , 'initial output' , 'initial output' ] ) ; // Same output to trigger idle
89
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
94
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
90
95
store . add ( monitor ) ;
91
96
92
97
let idleEventFired = false ;
@@ -104,7 +109,7 @@ suite('OutputMonitor', () => {
104
109
105
110
const tokenSource = new CancellationTokenSource ( ) ;
106
111
107
- const result = await monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
112
+ const result = await monitor . internalStartMonitoring ( false , tokenSource . token ) ;
108
113
109
114
strictEqual ( result . terminalExecutionIdleBeforeTimeout , true ) ;
110
115
strictEqual ( typeof result . output , 'string' ) ;
@@ -128,15 +133,15 @@ suite('OutputMonitor', () => {
128
133
isActive : undefined
129
134
} ;
130
135
131
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
136
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
132
137
store . add ( monitor ) ;
133
138
134
139
const tokenSource = new CancellationTokenSource ( ) ;
135
140
136
141
// Cancel after a short time to simulate timeout
137
142
setTimeout ( ( ) => tokenSource . cancel ( ) , 100 ) ;
138
143
139
- await monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
144
+ await monitor . internalStartMonitoring ( false , tokenSource . token ) ;
140
145
141
146
const actions = monitor . actions ;
142
147
strictEqual ( actions . includes ( OutputMonitorAction . PollingStarted ) , true ) ;
@@ -145,7 +150,7 @@ suite('OutputMonitor', () => {
145
150
146
151
test ( 'should handle cancellation correctly' , async ( ) => {
147
152
const execution = createMockExecution ( [ 'output' ] ) ;
148
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
153
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
149
154
store . add ( monitor ) ;
150
155
151
156
const tokenSource = new CancellationTokenSource ( ) ;
@@ -154,7 +159,7 @@ suite('OutputMonitor', () => {
154
159
tokenSource . cancel ( ) ;
155
160
156
161
try {
157
- await monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
162
+ await monitor . internalStartMonitoring ( false , tokenSource . token ) ;
158
163
strictEqual ( true , false , 'Should have thrown cancellation error' ) ;
159
164
} catch ( error ) {
160
165
// Expected cancellation
@@ -167,12 +172,12 @@ suite('OutputMonitor', () => {
167
172
168
173
test ( 'should track output received actions' , async ( ) => {
169
174
const execution = createMockExecution ( [ 'output1' , 'output2' , 'output2' , 'output2' ] ) ; // Output changes once then stays same
170
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
175
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
171
176
store . add ( monitor ) ;
172
177
173
178
const tokenSource = new CancellationTokenSource ( ) ;
174
179
175
- const result = await monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
180
+ const result = await monitor . internalStartMonitoring ( false , tokenSource . token ) ;
176
181
177
182
strictEqual ( result . terminalExecutionIdleBeforeTimeout , true ) ;
178
183
@@ -184,12 +189,12 @@ suite('OutputMonitor', () => {
184
189
185
190
test ( 'should handle extended polling correctly' , async ( ) => {
186
191
const execution = createMockExecution ( [ 'output' , 'output' , 'output' ] ) ; // Same output to trigger idle quickly
187
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
192
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
188
193
store . add ( monitor ) ;
189
194
190
195
const tokenSource = new CancellationTokenSource ( ) ;
191
196
192
- const result = await monitor . startMonitoringLegacy ( true , tokenSource . token ) ; // Extended polling = true
197
+ const result = await monitor . internalStartMonitoring ( true , tokenSource . token ) ; // Extended polling = true
193
198
194
199
strictEqual ( result . terminalExecutionIdleBeforeTimeout , true ) ;
195
200
strictEqual ( typeof result . modelOutputEvalResponse , 'string' ) ;
@@ -206,15 +211,15 @@ suite('OutputMonitor', () => {
206
211
[ 'output' , 'output' , 'output' , 'output' ] , // Same output to trigger no new data
207
212
[ true , false ] // Active once, then inactive (should trigger idle quickly)
208
213
) ;
209
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
214
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
210
215
store . add ( monitor ) ;
211
216
212
217
const tokenSource = new CancellationTokenSource ( ) ;
213
218
214
219
// Set a timeout to cancel if it takes too long
215
220
setTimeout ( ( ) => tokenSource . cancel ( ) , 2000 ) ;
216
221
217
- await monitor . startMonitoringLegacy ( false , tokenSource . token ) ;
222
+ await monitor . internalStartMonitoring ( false , tokenSource . token ) ;
218
223
219
224
// Check that it didn't timeout (either completed successfully or was cancelled)
220
225
const actions = monitor . actions ;
@@ -227,7 +232,7 @@ suite('OutputMonitor', () => {
227
232
228
233
test ( 'should return immutable copy of actions' , ( ) => {
229
234
const execution = createMockExecution ( [ '' ] ) ;
230
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
235
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
231
236
store . add ( monitor ) ;
232
237
233
238
const actions1 = monitor . actions ;
@@ -247,7 +252,7 @@ suite('OutputMonitor', () => {
247
252
248
253
test ( 'should dispose correctly' , ( ) => {
249
254
const execution = createMockExecution ( [ '' ] ) ;
250
- const monitor = new OutputMonitor ( execution , mockLanguageModelsService ) ;
255
+ const monitor = new TestOutputMonitor ( execution , mockLanguageModelsService ) ;
251
256
252
257
let eventFired = false ;
253
258
const disposable = monitor . onDidFinishCommand ( ( ) => {
0 commit comments