Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(windows): reject empty vswhere results
HopeCollector58bc0037a19a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex d3bf689eb..9d7aa1c45 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -58,4 +58,4 @@ jobs:run: npm run host:build- name: Windows-relevant tests- run: npx vitest run src/core/fs-atomic.test.ts src/core/fs-atomic.guard.test.ts src/session-host/ src/core/session-host-client.test.ts src/core/session-host-launch-ledger.test.ts src/core/agent-launch.test.ts src/core/pty-session-host.test.ts src/main/media-protocol.test.ts src/main/remote-atomic-write.test.ts src/main/ssh-fs.test.ts src/main/remote-ssh/ssh-project.test.ts src/renderer/terminal/file-links.test.ts src/renderer/terminal/file-links.windows.test.ts src/renderer/terminal/file-link-dialect.test.ts src/renderer/terminal/host-platform.test.ts+ run: npx vitest run src/core/fs-atomic.test.ts src/core/fs-atomic.guard.test.ts src/session-host/ src/core/session-host-client.test.ts src/core/session-host-launch-ledger.test.ts src/core/agent-launch.test.ts src/core/pty-session-host.test.ts src/main/bootstrap-windows.test.ts src/main/media-protocol.test.ts src/main/remote-atomic-write.test.ts src/main/ssh-fs.test.ts src/main/remote-ssh/ssh-project.test.ts src/renderer/terminal/file-links.test.ts src/renderer/terminal/file-links.windows.test.ts src/renderer/terminal/file-link-dialect.test.ts src/renderer/terminal/host-platform.test.tsdiff --git a/bootstrap-windows.bat b/bootstrap-windows.batindex 5473cdc44..ed0b6de9d 100644--- a/bootstrap-windows.bat+++ b/bootstrap-windows.bat@@ -22,6 +22,12 @@ rem ============================================================================set "REPO=%~dp0"if "%REPO:~-1%"=="\" set "REPO=%REPO:~0,-1%"+set "_NODETERM_VSWHERE_OVERRIDE="++rem Keep the Visual Studio probe independently runnable for diagnostics and CI regression tests.+rem GitHub-hosted Windows runners are elevated, while the full bootstrap intentionally refuses+rem elevation before npm lifecycle scripts; this mode runs only the toolchain probe and never npm.+if /i "%~1"=="--check-vs-build-tools" goto :check_vs_build_tools_onlyrem --- Refuse elevation: npm lifecycle scripts must never run as Administrator. ----------------"%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -Command "$p=[Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()); if($p.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)){exit 86}else{exit 0}" >nul 2>nul@@ -51,20 +57,8 @@ if %NODE_MAJOR% LSS 20 (echo [OK] Node.js major %NODE_MAJOR%rem --- Visual Studio Build Tools with the C++ workload (node-gyp / electron-rebuild) -------------set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"-if not exist "%VSWHERE%" (- echo [MISSING] Visual Studio Build Tools were not found ^(vswhere.exe absent^).- echo Install: winget install Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"- echo ^(elevated; then open a NEW prompt and rerun this script^)- exit /b 1-)-"%VSWHERE%" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath >nul 2>nul-if errorlevel 1 (- echo [MISSING] A Visual Studio install exists but lacks the C++ build tools component.- echo Install: winget install Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"- exit /b 1-)-echo [OK] Visual Studio C++ build tools+call :check_vs_build_tools+if errorlevel 1 exit /b 1rem --- Python 3 (node-gyp) -----------------------------------------------------------------------py -3 --version >nul 2>nul@@ -96,3 +90,44 @@ echo [DONE] Dependencies installed and native modules rebuilt against Electron'secho npm run dev - development mode with HMRecho npm run dist:win - unsigned NSIS installer + zip into dist\exit /b 0++:check_vs_build_tools_only+if "%NODETERM_BOOTSTRAP_TESTING%"=="1" set "_NODETERM_VSWHERE_OVERRIDE=%NODETERM_TEST_VSWHERE%"+call :check_vs_build_tools+exit /b %ERRORLEVEL%++:check_vs_build_tools+set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"+rem The check-only mode may inject a fixture; the full bootstrap always uses vswhere's canonical+rem installer location so an inherited environment variable cannot redirect the production probe.+if defined _NODETERM_VSWHERE_OVERRIDE set "VSWHERE=%_NODETERM_VSWHERE_OVERRIDE%"+if not exist "%VSWHERE%" (+ echo [MISSING] Visual Studio Build Tools were not found ^(vswhere.exe absent^).+ echo Install: winget install Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"+ echo ^(elevated; then open a NEW prompt and rerun this script^)+ exit /b 1+)++set "VSWHERE_ARGS=-products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -latest -property installationPath"+call "%VSWHERE%" %VSWHERE_ARGS% >nul 2>nul+if errorlevel 1 (+ echo [FAILED] vswhere could not query Visual Studio installations.+ exit /b 1+)++rem vswhere returns exit code 0 even when the query matches nothing. Capture the first path and+rem test the value itself; checking only ERRORLEVEL silently accepts a machine without C++ tools.+set "VS_INSTALLATION="+for /f "usebackq delims=" %%I in (`call "%VSWHERE%" %VSWHERE_ARGS% 2^>nul`) do if not defined VS_INSTALLATION set "VS_INSTALLATION=%%I"+if not defined VS_INSTALLATION (+ echo [MISSING] No Visual Studio installation with the C++ build tools component was found.+ echo Install: winget install Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"+ exit /b 1+)+if not exist "%VS_INSTALLATION%\." (+ echo [FAILED] vswhere reported a Visual Studio path that does not exist: "%VS_INSTALLATION%"+ exit /b 1+)++echo [OK] Visual Studio C++ build tools: "%VS_INSTALLATION%"+exit /b 0diff --git a/src/main/bootstrap-windows.test.ts b/src/main/bootstrap-windows.test.tsnew file mode 100644index 000000000..48063aaef--- /dev/null+++ b/src/main/bootstrap-windows.test.ts@@ -0,0 +1,135 @@+import { spawnSync } from 'node:child_process'+import {+ copyFileSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ rmSync,+ writeFileSync+} from 'node:fs'+import { tmpdir } from 'node:os'+import path from 'node:path'+import { afterEach, describe, expect, it } from 'vitest'++const describeWindows = process.platform === 'win32' ? describe : describe.skip+const sourceBootstrap = path.resolve(__dirname, '../../bootstrap-windows.bat')+const scratchDirectories: string[] = []++interface ProbeResult {+ status: number | null+ stdout: string+ stderr: string+ installation: string+ invocations: string[]+}++function runVisualStudioProbe(vswhereBody: string): ProbeResult {+ const scratch = mkdtempSync(path.join(tmpdir(), 'nodeterm-bootstrap-'))+ scratchDirectories.push(scratch)+ const installation = path.join(scratch, 'VS Build Tools')+ mkdirSync(installation)++ const checkout = path.join(scratch, 'checkout with spaces')+ mkdirSync(checkout)+ const bootstrap = path.join(checkout, 'bootstrap-windows.bat')+ copyFileSync(sourceBootstrap, bootstrap)++ // The space in the filename makes this fixture exercise the quoting around VSWHERE too.+ const fakeVswhere = path.join(scratch, 'fake vswhere.cmd')+ const invocationLog = path.join(scratch, 'vswhere-arguments.txt')+ writeFileSync(+ fakeVswhere,+ `@echo off\r\necho %*>>"%NODETERM_TEST_VSWHERE_ARGS_LOG%"\r\n${vswhereBody}\r\n`,+ 'utf8'+ )++ const env = {+ ...process.env,+ NODETERM_BOOTSTRAP_TESTING: '1',+ NODETERM_TEST_VSWHERE: fakeVswhere,+ NODETERM_TEST_VSWHERE_ARGS_LOG: invocationLog,+ NODETERM_TEST_VS_INSTALLATION: installation+ }+ // Keep the batch path and its argument as separate argv entries. Node quotes the path for+ // CreateProcess, so a checkout directory containing spaces reaches cmd.exe intact.+ const result = spawnSync(+ process.env.ComSpec ?? 'cmd.exe',+ ['/d', '/c', bootstrap, '--check-vs-build-tools'],+ {+ encoding: 'utf8',+ env,+ timeout: 10_000,+ windowsHide: true+ }+ )++ expect(result.error).toBeUndefined()+ return {+ status: result.status,+ stdout: result.stdout,+ stderr: result.stderr,+ installation,+ invocations: readFileSync(invocationLog, 'utf8').trim().split(/\r?\n/)+ }+}++const expectedVswhereArguments =+ '-products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -latest -property installationPath'++function expectVswhereInvocations(result: ProbeResult, count: number): void {+ expect(result.invocations).toEqual(Array(count).fill(expectedVswhereArguments))+}++describeWindows('bootstrap-windows Visual Studio probe', () => {+ afterEach(() => {+ for (const directory of scratchDirectories.splice(0)) {+ rmSync(directory, { recursive: true, force: true })+ }+ })++ it('rejects a successful vswhere query with empty output', () => {+ const result = runVisualStudioProbe('exit /b 0')++ expect(result.status).toBe(1)+ expect(result.stdout, result.stderr).toContain(+ '[MISSING] No Visual Studio installation with the C++ build tools component was found.'+ )+ expect(result.stdout).not.toContain('[OK] Visual Studio C++ build tools')+ expectVswhereInvocations(result, 2)+ })++ it('keeps a failed query distinct from an empty successful query', () => {+ const result = runVisualStudioProbe('exit /b 7')++ expect(result.status).toBe(1)+ expect(result.stdout, result.stderr).toContain(+ '[FAILED] vswhere could not query Visual Studio installations.'+ )+ expect(result.stdout).not.toContain('[MISSING] No Visual Studio installation')+ expectVswhereInvocations(result, 1)+ })++ it('rejects a reported C++ toolchain path that does not exist', () => {+ const result = runVisualStudioProbe(+ 'echo %NODETERM_TEST_VS_INSTALLATION%\\missing-installation'+ )+ const missingInstallation = path.join(result.installation, 'missing-installation')++ expect(result.status).toBe(1)+ expect(result.stdout, result.stderr).toContain(+ `[FAILED] vswhere reported a Visual Studio path that does not exist: "${missingInstallation}"`+ )+ expect(result.stdout).not.toContain('[OK] Visual Studio C++ build tools')+ expectVswhereInvocations(result, 2)+ })++ it('accepts a reported C++ toolchain path, including spaces', () => {+ const result = runVisualStudioProbe('echo %NODETERM_TEST_VS_INSTALLATION%')++ expect(result.status).toBe(0)+ expect(result.stdout, result.stderr).toContain(+ `[OK] Visual Studio C++ build tools: "${result.installation}"`+ )+ expectVswhereInvocations(result, 2)+ })+})