mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-08 15:55:15 +01:00
Address PR feedback: logging, performance, timeout, and docs
- Strip sensitive data from debug logs (log metadata only) - Use array join instead of O(n^2) string concat in stripNewLinesAndBuildMapping - Add 5s timeout to cursor-move wait to prevent indefinite hangs - Align shellIntegrationTimeout descriptions (0 = skip the wait)
This commit is contained in:
@@ -634,7 +634,7 @@ const terminalConfiguration: IStringDictionary<IConfigurationPropertySchema> = {
|
||||
},
|
||||
[TerminalSettingId.ShellIntegrationTimeout]: {
|
||||
restricted: true,
|
||||
markdownDescription: localize('terminal.integrated.shellIntegration.timeout', "Configures the duration in milliseconds to wait for shell integration after launch before declaring it's not there. Set to {0} to skip the wait entirely, the default value {1} means the wait time is variable based on whether shell integration injection is enabled and whether it's a remote window. Values between 1 and 499 are clamped to 500ms. Consider setting this to {0} if you intentionally disabled shell integration, or a large value if your shell starts very slowly.", '`0`', '`-1`'),
|
||||
markdownDescription: localize('terminal.integrated.shellIntegration.timeout', "Configures the duration in milliseconds to wait for shell integration after launch before declaring it's not there. Set to {0} to skip the wait entirely. The default value {1} uses a variable wait time based on whether shell integration injection is enabled and whether it's a remote window. Values between 1 and 499 are clamped to 500ms. Consider setting this to {0} if you intentionally disabled shell integration, or a large value if your shell starts very slowly.", '`0`', '`-1`'),
|
||||
type: 'integer',
|
||||
minimum: -1,
|
||||
maximum: 60000,
|
||||
|
||||
+13
-3
@@ -92,18 +92,28 @@ export class NoneExecuteStrategy extends Disposable implements ITerminalExecuteS
|
||||
// hasn't started processing the command yet.
|
||||
if (startLine !== undefined) {
|
||||
this._log('Waiting for cursor to move past start line');
|
||||
await new Promise<void>(resolve => {
|
||||
const cursorMovedPromise = new Promise<void>(resolve => {
|
||||
const check = () => {
|
||||
const buffer = xterm.raw.buffer.active;
|
||||
const cursorLine = buffer.baseY + buffer.cursorY;
|
||||
if (cursorLine > startLine) {
|
||||
resolve();
|
||||
} else {
|
||||
store.add(Event.once(this._instance.onData)(() => check()));
|
||||
}
|
||||
};
|
||||
const listener = this._instance.onData(() => check());
|
||||
store.add(listener);
|
||||
check();
|
||||
});
|
||||
|
||||
const cursorMoveTimeout = new Promise<'timeout'>(resolve => {
|
||||
const handle = setTimeout(() => resolve('timeout'), 5000);
|
||||
store.add({ dispose: () => clearTimeout(handle) });
|
||||
});
|
||||
|
||||
const raceResult = await Promise.race([cursorMovedPromise, cursorMoveTimeout]);
|
||||
if (raceResult === 'timeout') {
|
||||
this._log('Cursor did not move past start line before timeout, proceeding with idle detection');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-5
@@ -88,7 +88,7 @@ export function createAltBufferPromise(
|
||||
* This function removes (1) and (3) to isolate the actual output.
|
||||
*/
|
||||
export function stripCommandEchoAndPrompt(output: string, commandLine: string, log?: (message: string) => void): string {
|
||||
log?.(`stripCommandEchoAndPrompt input: ${JSON.stringify(output)}, commandLine: ${JSON.stringify(commandLine)}`);
|
||||
log?.(`stripCommandEchoAndPrompt input: output length=${output.length}, commandLine length=${commandLine.length}`);
|
||||
|
||||
const result = _stripCommandEchoAndPromptOnce(output, commandLine, log);
|
||||
|
||||
@@ -172,7 +172,7 @@ function _stripCommandEchoAndPromptOnce(output: string, commandLine: string, log
|
||||
}
|
||||
|
||||
const result = lines.slice(startIndex, endIndex).join('\n');
|
||||
log?.(`stripCommandEchoAndPrompt result: ${JSON.stringify(result)} (startIndex=${startIndex}, endIndex=${endIndex}, totalLines=${lines.length})`);
|
||||
log?.(`stripCommandEchoAndPrompt result: length=${result.length} (startIndex=${startIndex}, endIndex=${endIndex}, totalLines=${lines.length})`);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -247,12 +247,12 @@ export function findCommandEcho(output: string, commandLine: string, allowSuffix
|
||||
|
||||
export function stripNewLinesAndBuildMapping(output: string): { strippedOutput: string; indexMapping: number[] } {
|
||||
const indexMapping: number[] = [];
|
||||
let strippedOutput = '';
|
||||
const strippedChars: string[] = [];
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
if (output[i] !== '\n') {
|
||||
strippedOutput += output[i];
|
||||
strippedChars.push(output[i]);
|
||||
indexMapping.push(i);
|
||||
}
|
||||
}
|
||||
return { strippedOutput, indexMapping };
|
||||
return { strippedOutput: strippedChars.join(''), indexMapping };
|
||||
}
|
||||
|
||||
+1
-1
@@ -436,7 +436,7 @@ export const terminalChatAgentToolsConfiguration: IStringDictionary<IConfigurati
|
||||
markdownDescription: localize('blockFileWrites.description', "Controls whether detected file write operations are blocked in the run in terminal tool. When detected, this will require explicit approval regardless of whether the command would normally be auto approved. Note that this cannot detect all possible methods of writing files, this is what is currently detected:\n\n- File redirection (detected via the bash or PowerShell tree sitter grammar)\n- `sed` in-place editing (`-i`, `-I`, `--in-place`)"),
|
||||
},
|
||||
[TerminalChatAgentToolsSettingId.ShellIntegrationTimeout]: {
|
||||
markdownDescription: localize('shellIntegrationTimeout.description', "Configures the duration in milliseconds to wait for shell integration to be detected when the run in terminal tool launches a new terminal. Set to `0` to wait the minimum time, the default value `-1` means the wait time is variable based on the value of {0} and whether it's a remote window. A large value can be useful if your shell starts very slowly and a low value if you're intentionally not using shell integration.", `\`#${TerminalSettingId.ShellIntegrationEnabled}#\``),
|
||||
markdownDescription: localize('shellIntegrationTimeout.description', "Configures the duration in milliseconds to wait for shell integration to be detected when the run in terminal tool launches a new terminal. Set to `0` to skip the wait entirely, the default value `-1` uses a variable wait time based on the value of {0} and whether it's a remote window. A large value can be useful if your shell starts very slowly.", `\`#${TerminalSettingId.ShellIntegrationEnabled}#\``),
|
||||
type: 'integer',
|
||||
minimum: -1,
|
||||
maximum: 60000,
|
||||
|
||||
Reference in New Issue
Block a user