🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(local-system): silence PowerShell progress so saved shell logs stay readable (#20104)
Arvin Xu789652482aad
diff --git a/packages/local-file-shell/src/shell/__tests__/utils.test.ts b/packages/local-file-shell/src/shell/__tests__/utils.test.tsindex 92f838e263b..2bc041b5a2d 100644--- a/packages/local-file-shell/src/shell/__tests__/utils.test.ts+++ b/packages/local-file-shell/src/shell/__tests__/utils.test.ts@@ -46,7 +46,8 @@ const decodeEncodedCommand = (encoded: string): string =>/** UTF-8 console setup prepended to every PowerShell script (see getShellConfig). */const ENCODING_PREAMBLE ='try { [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 } catch {}' +- '\n$OutputEncoding = [System.Text.Encoding]::UTF8\n';+ '\n$OutputEncoding = [System.Text.Encoding]::UTF8' ++ "\n$ProgressPreference = 'SilentlyContinue'\n";const EXIT_CODE_GUARD ='\n$__lobeExecOk = $?' +@@ -102,6 +103,25 @@ describe('getShellConfig', () => {);});+ it('silences progress records before the command runs', async () => {+ // Redirected progress lands in the saved stderr log as raw CLIXML+ // ("Preparing modules for first use."), which the model then reads back.+ setPlatform('win32');+ process.env.PATH = 'C:\\Tools';+ process.env.SystemRoot = 'C:\\Windows';+ mockExisting(+ path.join('C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'),+ );++ const script = decodeEncodedCommand(+ (await getShellConfig('Get-Module -ListAvailable')).args[3],+ );++ const silence = script.indexOf("$ProgressPreference = 'SilentlyContinue'");+ expect(silence).toBeGreaterThanOrEqual(0);+ expect(silence).toBeLessThan(script.indexOf('Get-Module -ListAvailable'));+ });+it('should fall back to Windows PowerShell 5.1 when only powershell.exe exists', async () => {setPlatform('win32');process.env.PATH = 'C:\\Tools';diff --git a/packages/local-file-shell/src/shell/utils.ts b/packages/local-file-shell/src/shell/utils.tsindex 13833b73e0d..213f5d68914 100644--- a/packages/local-file-shell/src/shell/utils.ts+++ b/packages/local-file-shell/src/shell/utils.ts@@ -419,9 +419,17 @@ export const getShellConfig = async (command: string): Promise<{ args: string[];// streams) and $OutputEncoding (used when piping into native commands) to// UTF-8 before the user command runs. The [Console] setter can throw when// no console is attached, hence the try/catch.+ //+ // Progress records are silenced too. With stderr redirected, Windows+ // PowerShell serializes every progress update (e.g. the "Preparing modules+ // for first use." that module auto-loading emits) into the stderr log as a+ // CLIXML block. The inline preview decodes CLIXML, but the saved log the+ // result points the model to does not, so reading it back returned raw XML+ // in a mis-decoded code page. There is no progress bar to show here anyway.const encodingPreamble ='try { [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 } catch {}' +- '\n$OutputEncoding = [System.Text.Encoding]::UTF8\n';+ '\n$OutputEncoding = [System.Text.Encoding]::UTF8' ++ "\n$ProgressPreference = 'SilentlyContinue'\n";const exitGuard ='\n$__lobeExecOk = $?' +'\nif (-not $__lobeExecOk) {' +