diff --git a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts index a6b81d3a1df..2d1dd15ce52 100644 --- a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts +++ b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts @@ -634,7 +634,7 @@ const terminalConfiguration: IStringDictionary = { }, [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, diff --git a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts index f9391f329cc..f72379411ca 100644 --- a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts +++ b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.ts @@ -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(resolve => { + const cursorMovedPromise = new Promise(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'); + } } diff --git a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.ts b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.ts index 2830c7b90e9..28416349eda 100644 --- a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.ts +++ b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.ts @@ -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 }; } diff --git a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts index e94af156a8f..e55ce632fd1 100644 --- a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts +++ b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts @@ -436,7 +436,7 @@ export const terminalChatAgentToolsConfiguration: IStringDictionary