@@ -12,6 +12,7 @@ import * as Layer from "effect/Layer";
1212import * as Path from "effect/Path" ;
1313
1414import * as ServerConfig from "../config.ts" ;
15+ import { makeFakeWslHost } from "../testUtils/fakeWsl.ts" ;
1516import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts" ;
1617import * as VcsProcess from "../vcs/VcsProcess.ts" ;
1718import * as KnownWorkspaces from "./KnownWorkspaces.ts" ;
@@ -96,6 +97,14 @@ const writeTextFile = Effect.fn("writeTextFile")(function* (
9697 yield * fileSystem . writeFileString ( absolutePath , contents ) . pipe ( Effect . orDie ) ;
9798} ) ;
9899
100+ const makeWslHost = Effect . gen ( function * ( ) {
101+ const { mountRoot, underWsl } = yield * makeFakeWslHost ;
102+ const service = yield * underWsl (
103+ WorkspaceFileSystem . make . pipe ( Effect . provide ( layerKnownWorkspacesTest ) ) ,
104+ ) ;
105+ return { mountRoot, service, underWsl } ;
106+ } ) ;
107+
99108it . layer ( layerTest , { excludeTestServices : true } ) ( "WorkspaceFileSystemLive" , ( it ) => {
100109 describe ( "getMetadata" , ( ) => {
101110 it . effect (
@@ -181,6 +190,31 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
181190 expect ( statted ) . toEqual ( [ ] ) ;
182191 } ) ,
183192 ) ;
193+
194+ it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) === "win32" ) (
195+ "reports a Windows drive path under WSL as the file it maps to" ,
196+ ( ) =>
197+ Effect . gen ( function * ( ) {
198+ const { mountRoot, service, underWsl } = yield * makeWslHost ;
199+ yield * writeTextFile ( mountRoot , "c/Users/me/Documents/notes.md" , "# Notes\n" ) ;
200+
201+ const { entries } = yield * underWsl (
202+ service . getMetadata ( {
203+ paths : [
204+ "C:\\Users\\me\\Documents\\notes.md" ,
205+ "C:/Users/me/Documents/notes.md" ,
206+ "C:/Users/me/Documents/notes\u0000.md" ,
207+ ] ,
208+ } ) ,
209+ ) ;
210+
211+ expect ( entries ) . toEqual ( [
212+ { kind : "file" , byteLength : 8 } ,
213+ { kind : "file" , byteLength : 8 } ,
214+ null ,
215+ ] ) ;
216+ } ) ,
217+ ) ;
184218 } ) ;
185219
186220 describe ( "readFile" , ( ) => {
@@ -351,6 +385,24 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
351385 } ) ,
352386 ) ;
353387
388+ it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) === "win32" ) (
389+ "reads a Windows drive path under WSL from where wslpath mounts it" ,
390+ ( ) =>
391+ Effect . gen ( function * ( ) {
392+ const { mountRoot, service, underWsl } = yield * makeWslHost ;
393+ const cwd = yield * makeTempDir ;
394+ yield * writeTextFile ( mountRoot , "c/Users/me/Documents/notes.md" , "# Notes\n" ) ;
395+
396+ for ( const relativePath of [
397+ "C:\\Users\\me\\Documents\\notes.md" ,
398+ "C:/Users/me/Documents/notes.md" ,
399+ ] ) {
400+ const result = yield * underWsl ( service . readFile ( { cwd, relativePath } ) ) ;
401+ expect ( result ) . toMatchObject ( { contents : "# Notes\n" , truncated : false } ) ;
402+ }
403+ } ) ,
404+ ) ;
405+
354406 it . effect ( "refuses a network path outside the workspace" , ( ) =>
355407 Effect . gen ( function * ( ) {
356408 const workspaceFileSystem = yield * WorkspaceFileSystem . WorkspaceFileSystem ;
0 commit comments