@@ -338,9 +338,80 @@ it.effect("reveals a file in File Explorer through PowerShell on Windows", () =>
338338 "$ProgressPreference = 'SilentlyContinue'; Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + 'C:\\workspace with spaces\\media\\author''s clip.mp4' + '\"')" ,
339339 ) ;
340340 assert . equal ( spawned . options . shell , false ) ;
341+
342+ yield * Effect . gen ( function * ( ) {
343+ const launcher = yield * ExternalLauncher . ExternalLauncher ;
344+ yield * launcher . launchEditor ( {
345+ editor : "file-manager" ,
346+ cwd : "C:/workspace with spaces/media/author's clip.mp4" ,
347+ } ) ;
348+ } ) . pipe (
349+ Effect . provide (
350+ testLayer ( {
351+ platform : "win32" ,
352+ env : { PATH : binDir , PATHEXT : ".COM;.EXE;.BAT;.CMD" } ,
353+ onSpawn : ( command ) => {
354+ spawned = command ;
355+ } ,
356+ } ) ,
357+ ) ,
358+ ) ;
359+ assert . deepEqual ( spawned . args , [ "C:\\workspace with spaces\\media\\author's clip.mp4" ] ) ;
341360 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
342361) ;
343362
363+ it . effect . skipIf ( ! windowsHost ) (
364+ "executes the Windows reveal helper with the launcher's process options" ,
365+ ( ) =>
366+ Effect . gen ( function * ( ) {
367+ const fileSystem = yield * FileSystem . FileSystem ;
368+ const path = yield * Path . Path ;
369+ const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
370+ const tempDir = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3-reveal-launch-" } ) ;
371+ const recorderPath = path . join ( tempDir , "recorder.cmd" ) ;
372+ const outputPath = path . join ( tempDir , "argv.txt" ) ;
373+ yield * fileSystem . writeFileString ( recorderPath , `@echo off\r\n>"${ outputPath } " echo(%*\r\n` ) ;
374+ let helper : ChildProcessSpawner . ChildProcessHandle | undefined ;
375+ const recordingSpawner = ChildProcessSpawner . make ( ( command ) =>
376+ Effect . gen ( function * ( ) {
377+ assert . ok ( ChildProcess . isStandardCommand ( command ) ) ;
378+ if ( ! ChildProcess . isStandardCommand ( command ) )
379+ throw new Error ( "Expected a standard command" ) ;
380+ const source = Buffer . from ( command . args . at ( - 1 ) ?? "" , "base64" ) . toString ( "utf16le" ) ;
381+ // Substitute only Explorer, preserving the production launch options.
382+ // Wait for the recorder so its output is complete when the helper exits.
383+ const recordingSource =
384+ source . replace ( "'explorer.exe'" , `'${ recorderPath . replaceAll ( "'" , "''" ) } '` ) + " -Wait" ;
385+ helper = yield * spawner . spawn (
386+ ChildProcess . make (
387+ command . command ,
388+ [
389+ ...command . args . slice ( 0 , - 1 ) ,
390+ Buffer . from ( recordingSource , "utf16le" ) . toString ( "base64" ) ,
391+ ] ,
392+ command . options ,
393+ ) ,
394+ ) ;
395+ return helper ;
396+ } ) ,
397+ ) ;
398+ const launcher = yield * ExternalLauncher . make . pipe (
399+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , recordingSpawner ) ,
400+ ) ;
401+ yield * launcher . launchEditor ( {
402+ editor : "file-manager" ,
403+ cwd : "C:/workspace with spaces/author's file.md" ,
404+ reveal : true ,
405+ } ) ;
406+ assert . ok ( helper ) ;
407+ assert . equal ( yield * helper . exitCode , 0 ) ;
408+ assert . equal (
409+ ( yield * fileSystem . readFileString ( outputPath ) ) . trim ( ) ,
410+ `/select,"C:\\workspace with spaces\\author's file.md"` ,
411+ ) ;
412+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
413+ ) ;
414+
344415// Real-chain smoke check for the Explorer selection contract: runs the exact
345416// PowerShell source the reveal launch encodes, against a stub that records
346417// the raw argument tail it receives, and asserts a spaced path arrives as the
0 commit comments