windows: Make collab run on Windows (#23117)

I’ve also updated the documentation in
`development\local-collaboration.md` and
`docs\src\development\windows.md`.

Testing collab on my Windows machine:

![屏幕截图 2025-01-14
162021](https://github.com/user-attachments/assets/28b4a36a-e156-4012-981a-5d0a23dcc613)


Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
张小白 2025-01-17 15:39:13 +08:00 committed by GitHub
parent b1375ab946
commit 70db427fc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 176 additions and 197 deletions

21
script/bootstrap.ps1 Normal file
View file

@ -0,0 +1,21 @@
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$env:POWERSHELL = $true
if (!(Get-Command sqlx -ErrorAction SilentlyContinue) -or (sqlx --version) -notlike "sqlx-cli 0.7.2") {
Write-Output "sqlx-cli not found or not the required version, installing version 0.7.2..."
cargo install sqlx-cli --version 0.7.2
}
Set-Location .\crates\collab
# Export contents of .env.toml
$env = (cargo run --bin dotenv) -join "`n";
Invoke-Expression $env
Set-Location ../..
Write-Output "creating databases..."
sqlx database create --database-url "$env:DATABASE_URL"
sqlx database create --database-url "$env:LLM_DATABASE_URL"

View file

@ -112,9 +112,23 @@ if (platform === "darwin") {
console.log(err);
throw new Error("Could not get screen resolution");
}
} else if (platform === "win32") {
// windows
try {
const resolutionOutput = execSync(
`powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea.Size}"`,
{ encoding: "utf8" }
).trim();
[screenWidth, screenHeight] = resolutionOutput.match(/\d+/g).map(Number);
} catch (err) {
console.log(err);
throw new Error("Could not get screen resolution on Windows");
}
}
screenHeight -= titleBarHeight;
if (platform !== "win32") {
screenHeight -= titleBarHeight;
}
if (isTop) {
screenHeight = Math.floor(screenHeight / 2);
@ -168,10 +182,18 @@ setTimeout(() => {
for (let i = 0; i < instanceCount; i++) {
const row = Math.floor(i / columns);
const column = i % columns;
const position = [
column * instanceWidth,
row * instanceHeight + titleBarHeight,
].join(",");
let position;
if (platform == "win32") {
position = [
column * instanceWidth,
row * instanceHeight,
].join(",");
} else {
position = [
column * instanceWidth,
row * instanceHeight + titleBarHeight,
].join(",");
}
const size = [instanceWidth, instanceHeight].join(",");
let binaryPath = zedBinary;
if (i != 0 && othersOnStable) {
@ -186,8 +208,8 @@ setTimeout(() => {
ZED_WINDOW_POSITION: position,
ZED_STATELESS: isStateful && i == 0 ? "" : "1",
ZED_ALWAYS_ACTIVE: "1",
ZED_SERVER_URL: "http://localhost:3000",
ZED_RPC_URL: "http://localhost:8080/rpc",
ZED_SERVER_URL: "http://127.0.0.1:3000", // On windows, the http_client could not parse localhost
ZED_RPC_URL: "http://127.0.0.1:8080/rpc",
ZED_ADMIN_API_TOKEN: "secret",
ZED_WINDOW_SIZE: size,
ZED_CLIENT_CHECKSUM_SEED: "development-checksum-seed",