Repository navigation
fix: open the editor on Windows - #567
Open
fushanbobfan wants to merge 2 commits into
Open
fushanbobfan wants to merge 2 commits into
fushanbobfan wants to merge 2 commits into
Conversation
The process polyfill has no platform, so the VS Code path module used POSIX paths while VS Code built Windows file paths from the user agent, and every editor file write failed. Set process.platform from the user agent before the editor loads. The relay also built the Metadata.lean URI by string concatenation, which is not a valid file URI on Windows; use pathToFileURL.
…ocess-platform # Conflicts: # relay/src/serverProcess.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
On Windows the level editor never opens (#451, #445). The console shows
Unable to write file '\workspace.code-workspace' (NoPermissions (FileSystemError): Not allowed)and the same for the level file, e.g.'\TestWorld\1.lean'. It also makes 16 of the 20game-features.cy.tstests fail on thewindows-latestCI job.There are two causes:
vite-plugin-node-polyfillsinstalls a globalprocesswithoutplatform. The VS Code libraries under lean4monaco treat aprocesswithoutversions.nodeas absent when decidingisWindows, so in a Windows browser they take it from the user agent and buildfsPathwith backslashes. Theirpathmodule, however, readsprocess.platformfrom that same polyfill, finds no'win32', and uses the POSIX implementation.resources.dirname(file:///TestWorld/1.lean)then evaluatesposix.dirname('\\TestWorld\\1.lean'), which is'.', so the in-memory file system looks for the parent directory/., does not find it, and the overlay provider reportsNoPermissions. This is the failure users hit on adam.math.hhu.de with a Windows browser, whatever OS the server runs on.`file://${gameDir}/Game/Metadata.lean`, which on Windows givesfile://D:\...\TestGame/Game/Metadata.lean. That is not a valid file URI, so the Lean server never answers for the level.What this changes
client/src/process-platform.ts, imported first inindex.tsx, setsprocess.platformon the polyfill from the user agent when it is missing, the same way VS Code's ownprocessfallback does (win32/darwin/linux). Both code paths then agree on the platform.pathToFileURL(path.join(gameDir, 'Game', 'Metadata.lean')). On Linux and macOS this gives the samefile:///...URI as before, except that characters such as spaces are now percent-encoded.How it was tested
On Windows 11 (Chrome-based browser and Cypress Electron):
Expected to find content: 'Assumptions:').npm run test:01-basic-interface.cy.ts6/6 pass;game-features.cy.ts17 pass, 3 fail. The 3 failures (Current Goal,Invalid rewrite argument,unsolved goals) are the same ones that fail on the macOS and Linux CI jobs onmain.npx tsc --noEmit -p clientadds no errors in the changed files; the relay builds withtsc -b.npm run build:client: succeeds; serving that build withnpm run prod(NO_BWRAP=true) on Windows, the TestGame level shows the goal and the first hint.I did not test on macOS or Linux locally; there the polyfill fix sets
platformtodarwin/linux, which matches what VS Code already assumed from the user agent.Fixes #451
Fixes #445