fix: v2.5.3 — Windows workspace folders, picker on top, no console flashes

A workspace could not be created on Windows: "cwd must be an absolute path"
for D:\…, because createLane/canonicalCwd tested for a leading "/".

- lanes.js: path.isAbsolute/path.resolve; canonicalCwd stops at any root (a
  missing drive looped forever); resolveLaneByCwd and /ensure accept "\" too
- native-dialog.js: the Windows picker gets an invisible TopMost owner form,
  shown first — an ownerless dialog from the background server opened behind
  the browser, or hidden
- windows-hide.js: every child process on Windows starts with windowsHide,
  required first by the server and the detached scripts (a console window
  flashed per git/npm call)
- Confirm/update/clear-data modals and the quota panel scroll instead of
  overflowing a short window
This commit is contained in:
2026-10-06 20:22:34 +07:00
parent f8acd5fc29
commit af014d9829
22 changed files with 151 additions and 27 deletions
+18 -2
View File
@@ -44,6 +44,16 @@ describe("native-dialog", () => {
assert.ok(!args.slice(0, -2).join(" ").includes("shell script"));
});
it("gives the Windows dialog a TopMost owner, so it does not open behind the browser", () => {
for (const kind of ["dir", "file"]) {
const [[cmd, args]] = nd.dialogCommands(kind, "C:\\x", "win32");
assert.equal(cmd, "powershell.exe");
const script = args.at(-1);
assert.match(script, /\$o\.TopMost = \$true;.*\$o\.Show\(\);.*\$d\.ShowDialog\(\$o\)/);
assert.ok(!script.includes("C:\\x"), "the folder travels in env, never the script");
}
});
it(
"answers the chosen path, null on Cancel, and falls through a missing program",
{
@@ -95,10 +105,16 @@ describe("native-dialog", () => {
it("tells a Cancel from a failure per program", () => {
assert.equal(nd.isCancel("zenity", ""), true);
assert.equal(nd.isCancel("zenity", "Gtk-Message: GtkDialog mapped without a transient parent"), true);
assert.equal(
nd.isCancel("zenity", "Gtk-Message: GtkDialog mapped without a transient parent"),
true
);
assert.equal(nd.isCancel("kdialog", "qt.qpa.xcb: could not connect to display :1"), false);
assert.equal(nd.isCancel("osascript", "execution error: User canceled. (-128)"), true);
assert.equal(nd.isCancel("osascript", "execution error: No user interaction allowed. (-1713)"), false);
assert.equal(
nd.isCancel("osascript", "execution error: No user interaction allowed. (-1713)"),
false
);
assert.equal(nd.isCancel("powershell.exe", ""), true);
assert.equal(nd.isCancel("powershell.exe", "Add-Type : Cannot add type"), false);
});
+50
View File
@@ -0,0 +1,50 @@
/**
* @file Tests for server/lib/windows-hide.js: on win32 every child process,
* async or sync, is started with `windowsHide: true`; elsewhere nothing changes.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
const { test } = require("node:test");
const assert = require("node:assert/strict");
const { install } = require("../lib/windows-hide");
function fakeCp() {
const seen = [];
class ChildProcess {
spawn(options) {
seen.push(options);
}
}
const rec = (...args) => seen.push(args);
return { seen, cp: { ChildProcess, spawnSync: rec, execFileSync: rec, execSync: rec } };
}
test("win32: async spawns and every sync form get windowsHide", () => {
const { seen, cp } = fakeCp();
install(cp, "win32");
install(cp, "win32"); // idempotent: no double wrap
new cp.ChildProcess().spawn({ file: "git", windowsHide: false });
cp.execFileSync("git", ["status"]);
cp.execFileSync("git", ["status"], { cwd: "x" });
cp.execFileSync("git", { cwd: "x" });
cp.execSync("dir");
cp.spawnSync("git", ["log"], undefined);
assert.deepEqual(seen, [
{ file: "git", windowsHide: true },
["git", ["status"], { windowsHide: true }],
["git", ["status"], { cwd: "x", windowsHide: true }],
["git", { cwd: "x", windowsHide: true }],
["dir", { windowsHide: true }],
["git", ["log"], { windowsHide: true }],
]);
});
test("other platforms are left alone", () => {
const { cp } = fakeCp();
const before = { ...cp, spawn: cp.ChildProcess.prototype.spawn };
install(cp, "linux");
assert.equal(cp.execSync, before.execSync);
assert.equal(cp.ChildProcess.prototype.spawn, before.spawn);
});