@codingame/monaco-vscode-xterm-common 37.2.0 → 37.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.js +39 -39
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollContribution.js +3 -3
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.d.ts +0 -11
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.js +0 -26
- package/vscode/src/vs/platform/terminal/common/environmentVariable.d.ts +0 -86
- package/vscode/src/vs/platform/terminal/common/environmentVariable.js +0 -10
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.d.ts +0 -17
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.js +0 -218
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.d.ts +0 -14
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.js +0 -84
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostOutputChannel.d.ts +0 -22
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostOutputChannel.js +0 -48
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.d.ts +0 -129
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.js +0 -439
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.d.ts +0 -77
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.js +0 -345
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.d.ts +0 -111
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.js +0 -138
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.d.ts +0 -28
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.js +0 -119
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.d.ts +0 -104
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.js +0 -1643
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.js +0 -54
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.js +0 -78
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.d.ts +0 -144
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.js +0 -806
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.js +0 -83
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.d.ts +0 -57
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.js +0 -139
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.d.ts +0 -45
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.js +0 -804
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.d.ts +0 -9
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.js +0 -75
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.js +0 -61
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.d.ts +0 -38
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.js +0 -127
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.d.ts +0 -38
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.js +0 -321
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.js +0 -17
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/media/stickyScroll.css +0 -49
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.js +0 -25
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +0 -58
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +0 -462
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Barrier, raceCancellation, DeferredPromise, disposableTimeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
-
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
4
|
-
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
5
|
-
import { MutableDisposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
-
import { ProcessPropertyType } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
7
|
-
import { AGENT_HOST_SCHEME, fromAgentHostUri } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostUri';
|
|
8
|
-
import { ActionType } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/common/actions';
|
|
9
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/common/notifications';
|
|
10
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-root/state';
|
|
11
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/state';
|
|
12
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/state';
|
|
13
|
-
import { TerminalClaimKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-terminal/state';
|
|
14
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-changeset/state';
|
|
15
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-resource-watch/state';
|
|
16
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation/state';
|
|
17
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation-run/state';
|
|
18
|
-
import { StateComponents } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/sessionState';
|
|
19
|
-
import { BasePty } from '../common/basePty.js';
|
|
20
|
-
|
|
21
|
-
var AhpCommandMarkKind;
|
|
22
|
-
(function(AhpCommandMarkKind) {
|
|
23
|
-
AhpCommandMarkKind["Executed"] = "s";
|
|
24
|
-
AhpCommandMarkKind["End"] = "e";
|
|
25
|
-
})(AhpCommandMarkKind || (AhpCommandMarkKind = {}));
|
|
26
|
-
function getAhpCommandMarkId(commandId, kind) {
|
|
27
|
-
return `ahp-${commandId}-${kind}`;
|
|
28
|
-
}
|
|
29
|
-
function getAhpCommandMarkCode(commandId, kind) {
|
|
30
|
-
return `\x1b]633;SetMark;Id=${getAhpCommandMarkId(commandId, kind)};Hidden\x07`;
|
|
31
|
-
}
|
|
32
|
-
const COPILOT_SENTINEL_PREFIX = "<<<COPILOT_SENTINEL_";
|
|
33
|
-
function isCopilotSentinelCommand(commandLine) {
|
|
34
|
-
return commandLine.includes(COPILOT_SENTINEL_PREFIX);
|
|
35
|
-
}
|
|
36
|
-
class AgentHostPty extends BasePty {
|
|
37
|
-
get supportsCommandDetection() {
|
|
38
|
-
return this._supportsCommandDetection;
|
|
39
|
-
}
|
|
40
|
-
constructor(id, _connection, _terminalUri, _options, _logService) {
|
|
41
|
-
super(id, false);
|
|
42
|
-
this._connection = _connection;
|
|
43
|
-
this._terminalUri = _terminalUri;
|
|
44
|
-
this._options = _options;
|
|
45
|
-
this._logService = _logService;
|
|
46
|
-
this._startBarrier = ( new Barrier());
|
|
47
|
-
this._lifetime = this._register(( new CancellationTokenSource()));
|
|
48
|
-
this._subscription = this._register(( new MutableDisposable()));
|
|
49
|
-
this._initialCwd = "";
|
|
50
|
-
this._didSignalReady = false;
|
|
51
|
-
this._onCommandExecuted = this._register(( new Emitter()));
|
|
52
|
-
this.onCommandExecuted = this._onCommandExecuted.event;
|
|
53
|
-
this._onCommandFinished = this._register(( new Emitter()));
|
|
54
|
-
this.onCommandFinished = this._onCommandFinished.event;
|
|
55
|
-
this._onSupportsCommandDetection = this._register(( new Emitter()));
|
|
56
|
-
this.onSupportsCommandDetection = this._onSupportsCommandDetection.event;
|
|
57
|
-
this._supportsCommandDetection = false;
|
|
58
|
-
this._suppressedCommandIds = ( new Set());
|
|
59
|
-
}
|
|
60
|
-
async start() {
|
|
61
|
-
const connection = this._connection;
|
|
62
|
-
try {
|
|
63
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
if (!this._options?.attachOnly) {
|
|
67
|
-
const terminalCreation = connection.createTerminal({
|
|
68
|
-
channel: ( this._terminalUri.toString()),
|
|
69
|
-
claim: {
|
|
70
|
-
kind: TerminalClaimKind.Client,
|
|
71
|
-
clientId: connection.clientId
|
|
72
|
-
},
|
|
73
|
-
name: this._options?.name,
|
|
74
|
-
cwd: this._resolveCwdForProtocol(this._options?.cwd),
|
|
75
|
-
cols: this._lastDimensions.cols > 0 ? this._lastDimensions.cols : undefined,
|
|
76
|
-
rows: this._lastDimensions.rows > 0 ? this._lastDimensions.rows : undefined
|
|
77
|
-
});
|
|
78
|
-
this._terminalCreation = terminalCreation;
|
|
79
|
-
terminalCreation.then(
|
|
80
|
-
() => this._clearTerminalCreation(terminalCreation),
|
|
81
|
-
() => this._clearTerminalCreation(terminalCreation)
|
|
82
|
-
);
|
|
83
|
-
const created = await raceCancellation(terminalCreation.then(() => true), this._lifetime.token, false);
|
|
84
|
-
if (!created) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (this._lifetime.token.isCancellationRequested || this._connection !== connection) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
const {
|
|
92
|
-
subscription,
|
|
93
|
-
store
|
|
94
|
-
} = this._createSubscription(this._connection);
|
|
95
|
-
if (!(await this._waitForHydration(subscription, store))) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
if (this._lifetime.token.isCancellationRequested || this._subscription.value !== store) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
const state = subscription.value;
|
|
102
|
-
if (state.supportsCommandDetection) {
|
|
103
|
-
this._supportsCommandDetection = true;
|
|
104
|
-
this._onSupportsCommandDetection.fire();
|
|
105
|
-
}
|
|
106
|
-
this._replayContent(state.content);
|
|
107
|
-
this._initialCwd = state.cwd?.toString() ?? "";
|
|
108
|
-
this._properties.cwd = this._initialCwd;
|
|
109
|
-
this._properties.initialCwd = this._initialCwd;
|
|
110
|
-
if (state.title) {
|
|
111
|
-
this._properties.title = state.title;
|
|
112
|
-
}
|
|
113
|
-
this._signalReady();
|
|
114
|
-
store.add(subscription.onDidApplyAction(envelope => {
|
|
115
|
-
this._handleAction(envelope);
|
|
116
|
-
}));
|
|
117
|
-
return undefined;
|
|
118
|
-
} catch (err) {
|
|
119
|
-
if (this._lifetime.token.isCancellationRequested || this._connection !== connection) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
message: err instanceof Error ? err.message : String(err)
|
|
124
|
-
};
|
|
125
|
-
} finally {
|
|
126
|
-
this._startBarrier.open();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
_clearTerminalCreation(terminalCreation) {
|
|
130
|
-
if (this._terminalCreation === terminalCreation) {
|
|
131
|
-
this._terminalCreation = undefined;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
_signalReady() {
|
|
135
|
-
if (this._didSignalReady || this._lifetime.token.isCancellationRequested) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
this._didSignalReady = true;
|
|
139
|
-
this.handleReady({
|
|
140
|
-
pid: -1,
|
|
141
|
-
cwd: this._initialCwd,
|
|
142
|
-
windowsPty: undefined
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
_handleAction(envelope) {
|
|
146
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const action = envelope.action;
|
|
150
|
-
switch (action.type) {
|
|
151
|
-
case ActionType.TerminalData:
|
|
152
|
-
this.handleData(action.data);
|
|
153
|
-
break;
|
|
154
|
-
case ActionType.TerminalExited:
|
|
155
|
-
this._exitAndDispose(action.exitCode);
|
|
156
|
-
break;
|
|
157
|
-
case ActionType.TerminalCwdChanged:
|
|
158
|
-
this._properties.cwd = ( action.cwd.toString());
|
|
159
|
-
this.handleDidChangeProperty({
|
|
160
|
-
type: ProcessPropertyType.Cwd,
|
|
161
|
-
value: ( action.cwd.toString())
|
|
162
|
-
});
|
|
163
|
-
break;
|
|
164
|
-
case ActionType.TerminalTitleChanged:
|
|
165
|
-
this._properties.title = action.title;
|
|
166
|
-
this.handleDidChangeProperty({
|
|
167
|
-
type: ProcessPropertyType.Title,
|
|
168
|
-
value: action.title
|
|
169
|
-
});
|
|
170
|
-
break;
|
|
171
|
-
case ActionType.TerminalResized:
|
|
172
|
-
if (envelope.origin?.clientId !== this._connection.clientId) {
|
|
173
|
-
this.handleDidChangeProperty({
|
|
174
|
-
type: ProcessPropertyType.OverrideDimensions,
|
|
175
|
-
value: {
|
|
176
|
-
cols: action.cols,
|
|
177
|
-
rows: action.rows
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
case ActionType.TerminalCommandDetectionAvailable:
|
|
183
|
-
if (!this._supportsCommandDetection) {
|
|
184
|
-
this._supportsCommandDetection = true;
|
|
185
|
-
this._onSupportsCommandDetection.fire();
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
case ActionType.TerminalCommandExecuted:
|
|
189
|
-
if (isCopilotSentinelCommand(action.commandLine)) {
|
|
190
|
-
this._suppressedCommandIds.add(action.commandId);
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
this.handleData(getAhpCommandMarkCode(action.commandId, AhpCommandMarkKind.Executed));
|
|
194
|
-
this._onCommandExecuted.fire({
|
|
195
|
-
commandId: action.commandId,
|
|
196
|
-
commandLine: action.commandLine,
|
|
197
|
-
timestamp: action.timestamp
|
|
198
|
-
});
|
|
199
|
-
break;
|
|
200
|
-
case ActionType.TerminalCommandFinished:
|
|
201
|
-
if (this._suppressedCommandIds.delete(action.commandId)) {
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
this.handleData(getAhpCommandMarkCode(action.commandId, AhpCommandMarkKind.End));
|
|
205
|
-
this._onCommandFinished.fire({
|
|
206
|
-
commandId: action.commandId,
|
|
207
|
-
exitCode: action.exitCode,
|
|
208
|
-
durationMs: action.durationMs
|
|
209
|
-
});
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
_replayContent(content) {
|
|
214
|
-
for (const part of content) {
|
|
215
|
-
if (part.type === "unclassified") {
|
|
216
|
-
if (part.value) {
|
|
217
|
-
this.handleData(part.value);
|
|
218
|
-
}
|
|
219
|
-
} else if (part.type === "command") {
|
|
220
|
-
if (isCopilotSentinelCommand(part.commandLine)) {
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
this.handleData(getAhpCommandMarkCode(part.commandId, AhpCommandMarkKind.Executed));
|
|
224
|
-
this._onCommandExecuted.fire({
|
|
225
|
-
commandId: part.commandId,
|
|
226
|
-
commandLine: part.commandLine,
|
|
227
|
-
timestamp: part.timestamp,
|
|
228
|
-
storedOutput: part.output
|
|
229
|
-
});
|
|
230
|
-
if (part.output) {
|
|
231
|
-
this.handleData(part.output);
|
|
232
|
-
}
|
|
233
|
-
if (part.isComplete) {
|
|
234
|
-
this.handleData(getAhpCommandMarkCode(part.commandId, AhpCommandMarkKind.End));
|
|
235
|
-
this._onCommandFinished.fire({
|
|
236
|
-
commandId: part.commandId,
|
|
237
|
-
exitCode: part.exitCode,
|
|
238
|
-
durationMs: part.durationMs
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
_resolveCwdForProtocol(cwd) {
|
|
245
|
-
if (!cwd) {
|
|
246
|
-
return undefined;
|
|
247
|
-
}
|
|
248
|
-
if (cwd.scheme === AGENT_HOST_SCHEME) {
|
|
249
|
-
return ( fromAgentHostUri(cwd).toString());
|
|
250
|
-
}
|
|
251
|
-
return ( cwd.toString());
|
|
252
|
-
}
|
|
253
|
-
_createSubscription(connection) {
|
|
254
|
-
const store = ( new DisposableStore());
|
|
255
|
-
try {
|
|
256
|
-
const subscription = store.add(
|
|
257
|
-
connection.getSubscription(StateComponents.Terminal, this._terminalUri, "AgentHostPty")
|
|
258
|
-
).object;
|
|
259
|
-
this._subscription.value = store;
|
|
260
|
-
return {
|
|
261
|
-
subscription,
|
|
262
|
-
store
|
|
263
|
-
};
|
|
264
|
-
} catch (error) {
|
|
265
|
-
store.dispose();
|
|
266
|
-
throw error;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
async _waitForHydration(subscription, store, timeoutMs) {
|
|
270
|
-
if (subscription.value !== undefined) {
|
|
271
|
-
return true;
|
|
272
|
-
}
|
|
273
|
-
const hydration = ( new DeferredPromise());
|
|
274
|
-
const timeout = timeoutMs === undefined ? undefined : disposableTimeout(() => hydration.error(( new Error("Reconnect hydration timed out"))), timeoutMs, store);
|
|
275
|
-
store.add(toDisposable(() => hydration.complete(false)));
|
|
276
|
-
store.add(Event.once(subscription.onDidChange)(() => {
|
|
277
|
-
timeout?.dispose();
|
|
278
|
-
hydration.complete(true);
|
|
279
|
-
}));
|
|
280
|
-
return raceCancellation(hydration.p, this._lifetime.token, false);
|
|
281
|
-
}
|
|
282
|
-
input(data) {
|
|
283
|
-
if (this._inReplay || this._lifetime.token.isCancellationRequested) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
this._startBarrier.wait().then(() => {
|
|
287
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
this._connection.dispatch(( this._terminalUri.toString()), {
|
|
291
|
-
type: ActionType.TerminalInput,
|
|
292
|
-
data
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
resize(cols, rows) {
|
|
297
|
-
if (this._lifetime.token.isCancellationRequested || this._inReplay || (this._lastDimensions.cols === cols && this._lastDimensions.rows === rows)) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
this._lastDimensions.cols = cols;
|
|
301
|
-
this._lastDimensions.rows = rows;
|
|
302
|
-
this._startBarrier.wait().then(() => {
|
|
303
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
this._connection.dispatch(( this._terminalUri.toString()), {
|
|
307
|
-
type: ActionType.TerminalResized,
|
|
308
|
-
cols,
|
|
309
|
-
rows
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
shutdown(_immediate) {
|
|
314
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
this._requestHostTerminalDisposal();
|
|
318
|
-
this._exitAndDispose(undefined);
|
|
319
|
-
}
|
|
320
|
-
_requestHostTerminalDisposal() {
|
|
321
|
-
if (this._options?.attachOnly) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
this._disposeHostTerminal();
|
|
325
|
-
if (this._terminalCreation) {
|
|
326
|
-
void this._terminalCreation.then(() => this._disposeHostTerminal(), () => this._disposeHostTerminal());
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
_disposeHostTerminal() {
|
|
330
|
-
try {
|
|
331
|
-
void this._connection.disposeTerminal(this._terminalUri).catch(err => this._logHostDisposalError(err));
|
|
332
|
-
} catch (err) {
|
|
333
|
-
this._logHostDisposalError(err);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
_logHostDisposalError(err) {
|
|
337
|
-
this._logService.warn(
|
|
338
|
-
`[AgentHostPty] Failed to dispose host terminal: ${err instanceof Error ? err.message : String(err)}`
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
_exitAndDispose(exitCode) {
|
|
342
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
this._lifetime.cancel();
|
|
346
|
-
this._subscription.clear();
|
|
347
|
-
this._startBarrier.open();
|
|
348
|
-
queueMicrotask(() => {
|
|
349
|
-
this.handleExit(exitCode);
|
|
350
|
-
this.dispose();
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
async getInitialCwd() {
|
|
354
|
-
return this._initialCwd;
|
|
355
|
-
}
|
|
356
|
-
async getCwd() {
|
|
357
|
-
return this._properties.cwd || this._initialCwd;
|
|
358
|
-
}
|
|
359
|
-
async clearBuffer() {
|
|
360
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
this._connection.dispatch(( this._terminalUri.toString()), {
|
|
364
|
-
type: ActionType.TerminalCleared
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
acknowledgeDataEvent(_charCount) {}
|
|
368
|
-
async setUnicodeVersion(_version) {}
|
|
369
|
-
processBinary(_data) {
|
|
370
|
-
return Promise.resolve();
|
|
371
|
-
}
|
|
372
|
-
sendSignal(_signal) {}
|
|
373
|
-
async refreshProperty(type) {
|
|
374
|
-
return this._properties[type];
|
|
375
|
-
}
|
|
376
|
-
async updateProperty(_type, _value) {}
|
|
377
|
-
async reconnect(newConnection) {
|
|
378
|
-
if (this._lifetime.token.isCancellationRequested) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
this._subscription.clear();
|
|
382
|
-
this._connection = newConnection;
|
|
383
|
-
let subscriptionStore;
|
|
384
|
-
try {
|
|
385
|
-
const result = this._createSubscription(this._connection);
|
|
386
|
-
const subscription = result.subscription;
|
|
387
|
-
subscriptionStore = result.store;
|
|
388
|
-
const RECONNECT_HYDRATE_TIMEOUT_MS = 10_000;
|
|
389
|
-
if (!(await this._waitForHydration(subscription, subscriptionStore, RECONNECT_HYDRATE_TIMEOUT_MS))) {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
if (this._lifetime.token.isCancellationRequested || this._subscription.value !== subscriptionStore) {
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
const state = subscription.value;
|
|
396
|
-
if (state.supportsCommandDetection && !this._supportsCommandDetection) {
|
|
397
|
-
this._supportsCommandDetection = true;
|
|
398
|
-
this._onSupportsCommandDetection.fire();
|
|
399
|
-
}
|
|
400
|
-
this.handleData("\u001b[2J\u001b[3J\u001b[H");
|
|
401
|
-
this._replayContent(state.content);
|
|
402
|
-
if (state.cwd) {
|
|
403
|
-
this._properties.cwd = ( state.cwd.toString());
|
|
404
|
-
}
|
|
405
|
-
if (state.title) {
|
|
406
|
-
this._properties.title = state.title;
|
|
407
|
-
}
|
|
408
|
-
this._signalReady();
|
|
409
|
-
subscriptionStore.add(subscription.onDidApplyAction(envelope => {
|
|
410
|
-
this._handleAction(envelope);
|
|
411
|
-
}));
|
|
412
|
-
return true;
|
|
413
|
-
} catch (err) {
|
|
414
|
-
if (!this._lifetime.token.isCancellationRequested) {
|
|
415
|
-
this._logService.warn(
|
|
416
|
-
`[AgentHostPty] Reconnection failed: ${err instanceof Error ? err.message : String(err)}`
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
if (subscriptionStore && this._subscription.value === subscriptionStore) {
|
|
420
|
-
this._subscription.clear();
|
|
421
|
-
}
|
|
422
|
-
if (!this._didSignalReady && !this._lifetime.token.isCancellationRequested) {
|
|
423
|
-
this._requestHostTerminalDisposal();
|
|
424
|
-
this._exitAndDispose(undefined);
|
|
425
|
-
}
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
get terminalUri() {
|
|
430
|
-
return this._terminalUri;
|
|
431
|
-
}
|
|
432
|
-
dispose() {
|
|
433
|
-
this._lifetime.cancel();
|
|
434
|
-
this._subscription.clear();
|
|
435
|
-
super.dispose();
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export { AgentHostPty, AhpCommandMarkKind, getAhpCommandMarkId };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
-
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
3
|
-
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
4
|
-
import { IAgentConnection } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentService";
|
|
5
|
-
import { IQuickInputService } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service";
|
|
6
|
-
import { ITerminalLogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service";
|
|
7
|
-
import { ITerminalInstance, ITerminalLocationOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
8
|
-
import { ITerminalChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service";
|
|
9
|
-
import { ITerminalService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service";
|
|
10
|
-
import { ITerminalProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service";
|
|
11
|
-
import { IAgentHostTerminalService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/agentHostTerminalService.service";
|
|
12
|
-
export interface IAgentHostTerminalCreateOptions {
|
|
13
|
-
/** Human-readable terminal name. */
|
|
14
|
-
readonly name?: string;
|
|
15
|
-
/** Initial working directory. */
|
|
16
|
-
readonly cwd?: URI;
|
|
17
|
-
/** Terminal location (panel, editor, split, etc.). */
|
|
18
|
-
readonly location?: ITerminalLocationOptions;
|
|
19
|
-
}
|
|
20
|
-
export interface IAgentHostEntry {
|
|
21
|
-
/** Display name for the profile. */
|
|
22
|
-
readonly name: string;
|
|
23
|
-
/** Address or identifier for the host. */
|
|
24
|
-
readonly address: string;
|
|
25
|
-
/** Getter for the connection (may be lazily resolved). */
|
|
26
|
-
readonly getConnection: () => IAgentConnection | undefined;
|
|
27
|
-
}
|
|
28
|
-
export interface IAgentHostTerminalProfileInfo {
|
|
29
|
-
readonly extensionIdentifier: string;
|
|
30
|
-
readonly profileId: string;
|
|
31
|
-
readonly title: string;
|
|
32
|
-
readonly address: string;
|
|
33
|
-
}
|
|
34
|
-
export declare class AgentHostTerminalService extends Disposable implements IAgentHostTerminalService {
|
|
35
|
-
private readonly _terminalService;
|
|
36
|
-
private readonly _terminalChatService;
|
|
37
|
-
private readonly _terminalProfileService;
|
|
38
|
-
private readonly _quickInputService;
|
|
39
|
-
private readonly _logService;
|
|
40
|
-
readonly _serviceBrand: undefined;
|
|
41
|
-
private readonly _entries;
|
|
42
|
-
private readonly _usedHosts;
|
|
43
|
-
private readonly _profileRegistrations;
|
|
44
|
-
private readonly _profiles;
|
|
45
|
-
readonly profiles: IObservable<readonly IAgentHostTerminalProfileInfo[]>;
|
|
46
|
-
private _defaultCwd;
|
|
47
|
-
/** Revived terminal instances, keyed by terminal URI string. */
|
|
48
|
-
private readonly _revivedInstances;
|
|
49
|
-
/**
|
|
50
|
-
* Active AgentHostPty instances with their owning connection clientId,
|
|
51
|
-
* keyed by terminal URI string. Used for reconnection scoping.
|
|
52
|
-
*/
|
|
53
|
-
private readonly _activePtys;
|
|
54
|
-
private readonly _pendingRevives;
|
|
55
|
-
constructor(_terminalService: ITerminalService, _terminalChatService: ITerminalChatService, _terminalProfileService: ITerminalProfileService, _quickInputService: IQuickInputService, _logService: ITerminalLogService);
|
|
56
|
-
registerEntry(entry: IAgentHostEntry): IDisposable;
|
|
57
|
-
getProfileForConnection(address: string): IAgentHostTerminalProfileInfo | undefined;
|
|
58
|
-
setDefaultCwd(cwd: URI | undefined): void;
|
|
59
|
-
private _reconcile;
|
|
60
|
-
private _registerProfile;
|
|
61
|
-
createTerminalForEntry(address: string, options?: IAgentHostTerminalCreateOptions): Promise<ITerminalInstance | undefined>;
|
|
62
|
-
createTerminal(connection: IAgentConnection, options?: IAgentHostTerminalCreateOptions): Promise<ITerminalInstance>;
|
|
63
|
-
reviveTerminal(connection: IAgentConnection, terminalUri: URI, terminalToolSessionId: string): Promise<ITerminalInstance>;
|
|
64
|
-
attachOutputTerminal(connection: IAgentConnection, terminalUri: URI, terminalToolSessionId: string): IDisposable;
|
|
65
|
-
private _doReviveTerminal;
|
|
66
|
-
/** Creates the registration that owns the pty produced for {@link key}. */
|
|
67
|
-
private _createPtyRegistration;
|
|
68
|
-
/**
|
|
69
|
-
* Ties the registration's lifetime to the terminal instance so the local
|
|
70
|
-
* pty is disposed even on paths that never call `shutdown()`.
|
|
71
|
-
*/
|
|
72
|
-
private _registerInstancePtyCleanup;
|
|
73
|
-
reconnectTerminals(newConnection: IAgentConnection, oldClientId: string): Promise<{
|
|
74
|
-
recovered: number;
|
|
75
|
-
total: number;
|
|
76
|
-
}>;
|
|
77
|
-
}
|