Compare commits

...
Author SHA1 Message Date
paseo-bot[bot]andDan Berindei acb88673ab fix(desktop): keep the window open when Ctrl+W has no tab action
Command Center suspends the workspace close-tab shortcut. Remove
Electron's competing Ctrl+W binding so that leaving the key unhandled
does not close the desktop window.

Co-authored-by: Dan Berindei <dan.berindei@gmail.com>
2026-11-29 05:37:54 +00:00
4 changed files with 74 additions and 5 deletions
@@ -514,6 +514,16 @@ describe("keyboard-shortcuts", () => {
event: { key: "w", code: "KeyW", ctrlKey: true },
context: { isMac: false, usesDesktopBindings: true, focusScope: "terminal" },
},
{
name: "leaves Ctrl+W to the command center search field on non-mac desktop",
event: { key: "w", code: "KeyW", ctrlKey: true },
context: {
isMac: false,
usesDesktopBindings: true,
focusScope: "command-center",
commandCenterOpen: true,
},
},
{
name: "does not switch tabs with Alt+Shift+] on mac desktop (Cmd+Shift+] only)",
event: { key: "’", code: "BracketRight", altKey: true, shiftKey: true },
+47 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { spawn } from "node:child_process";
import { execFileSync, spawn } from "node:child_process";
import fs from "node:fs";
import { createServer } from "node:http";
import net from "node:net";
@@ -363,6 +363,43 @@ async function openBrowserWorkspace(page, workspaceKey) {
await expect(page.getByTestId(`workspace-deck-entry-${workspaceKey}`)).toBeVisible();
}
async function verifyCloseTabShortcut({ page, inspectorPort, workspaceKey }) {
await openBrowserWorkspace(page, workspaceKey);
const workspace = page.getByTestId(`workspace-deck-entry-${workspaceKey}`);
await workspace.getByTestId("workspace-new-tab-button").filter({ visible: true }).first().click();
await page.getByTestId("workspace-new-tab-menu-agent").filter({ visible: true }).first().click();
const draft = workspace
.locator('[data-testid^="workspace-tab-draft_"]')
.filter({ visible: true });
await expect(draft).toBeVisible();
// Send the key through X11 so Electron can handle it as a native menu accelerator.
const { DISPLAY, XAUTHORITY } = await evaluateDesktopWindow(
inspectorPort,
"win.focus(); win.webContents.focus(); return { DISPLAY: process.env.DISPLAY, XAUTHORITY: process.env.XAUTHORITY };",
);
assert(DISPLAY && XAUTHORITY, "Ctrl+W regression requires the private Xvfb display");
const pressCloseTabShortcut = () =>
execFileSync("xdotool", ["key", "--clearmodifiers", "ctrl+w"], {
env: { ...process.env, DISPLAY, XAUTHORITY },
});
// Command Center disables the workspace close-tab binding.
await page.getByTestId("sidebar-search").click();
const commandCenterInput = page.getByTestId("command-center-input");
await expect(commandCenterInput).toBeFocused();
pressCloseTabShortcut();
await expect(commandCenterInput).toBeVisible();
await expect(draft).toBeVisible();
await page.keyboard.press("Escape");
await expect(commandCenterInput).toBeHidden();
pressCloseTabShortcut();
await expect(draft).toHaveCount(0);
await expect(workspace).toBeVisible();
console.log("Ctrl+W closed the workspace tab and kept the desktop window open.");
}
async function openSecondDesktopWindow(page) {
const nextWindow = page.context().waitForEvent("page", { timeout: timeoutMs });
await page.evaluate(() => window.paseoDesktop.window.openNew());
@@ -1429,7 +1466,7 @@ async function main() {
process.execPath,
devRunner,
`--inspect=127.0.0.1:${inspectorPort}`,
...(process.platform === "linux" ? ["--no-sandbox"] : []),
...(process.platform === "linux" ? ["--no-sandbox", "--ozone-platform=x11"] : []),
];
const desktopCommand = process.platform === "linux" ? "xvfb-run" : desktopArgs.shift();
const desktopCommandArgs =
@@ -1521,6 +1558,14 @@ async function main() {
return;
}
if (process.platform === "linux") {
await verifyCloseTabShortcut({
page,
inspectorPort,
workspaceKey: `${status.serverId}:${workspaceIds[0]}`,
});
}
const adaptiveTheme = await runAdaptiveThemeRegression(artifactDir);
await runAppearanceFontSizeRegression(page);
+9 -1
View File
@@ -1,5 +1,13 @@
import { describe, expect, it } from "vitest";
import { reloadActiveBrowserOrWindow } from "./menu.js";
import { buildApplicationMenuTemplate, reloadActiveBrowserOrWindow } from "./menu.js";
it.runIf(process.platform !== "darwin")("keeps the Window > Close action without Ctrl+W", () => {
const template = buildApplicationMenuTemplate({ onNewWindow: () => {} }, false);
const windowMenu = template.find((item) => item.label === "Window");
const closeItem = windowMenu?.submenu?.find((item) => item.role === "close");
expect(closeItem).toMatchObject({ role: "close", accelerator: "", registerAccelerator: false });
});
class FakeWebContents {
public readonly reloads: string[] = [];
+8 -2
View File
@@ -64,12 +64,18 @@ export function reloadActiveBrowserOrWindow({
win.webContents.reload();
}
function buildApplicationMenuTemplate(
export function buildApplicationMenuTemplate(
options: ApplicationMenuOptions,
capturing: boolean,
): Electron.MenuItemConstructorOptions[] {
const isMac = process.platform === "darwin";
const zoomEnabled = !capturing;
const closeWindowItem: Electron.MenuItemConstructorOptions = { role: "close" };
if (!isMac) {
// Electron's Close role defaults to Ctrl+W, which Paseo uses to close tabs.
closeWindowItem.accelerator = "";
closeWindowItem.registerAccelerator = false;
}
return [
...(isMac
@@ -175,7 +181,7 @@ function buildApplicationMenuTemplate(
{ role: "zoom" },
...(isMac
? [{ type: "separator" as const }, { role: "front" as const }]
: [{ role: "close" as const }]),
: [closeWindowItem]),
],
},
];