feat(app): use Cmd+Shift+[ / ] for previous/next tab on macOS desktop (#7692)
* feat(app): use Cmd+Shift+[ / ] for previous/next tab on macOS desktop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(app): drop Alt+Shift tab navigation on macOS desktop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(app): cover previous/next tab shortcuts on web and macOS desktop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(app): adopt desktopBindings condition for tab navigation shortcuts Main renamed the binding condition `desktop` to `desktopBindings` and the test context `isDesktop` to `usesDesktopBindings` (#8625). Rebase the Cmd+Shift+[ / ] tab shortcuts onto that vocabulary. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
4 files changed
+182
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { clickNewTerminal, gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { waitForWorkspaceTabsVisible } from "../support/helpers/workspace-tabs";
|
||||
|
||||
// The browser owns Cmd+Shift+brackets for its own tabs, so web keeps
|
||||
// Alt+Shift+brackets on every OS. Desktop bindings live in the desktop suite.
|
||||
test("web switches to the previous and next tab with Alt+Shift+[ and ]", async ({ page }) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "tab-relative-web-" });
|
||||
try {
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await waitForWorkspaceTabsVisible(page);
|
||||
const terminalTabs = page
|
||||
.locator('[data-testid^="workspace-tab-terminal_"]')
|
||||
.filter({ visible: true });
|
||||
await clickNewTerminal(page);
|
||||
await expect(terminalTabs).toHaveCount(1, { timeout: 30_000 });
|
||||
await clickNewTerminal(page);
|
||||
await expect(terminalTabs).toHaveCount(2, { timeout: 30_000 });
|
||||
const first = terminalTabs.nth(0);
|
||||
const second = terminalTabs.nth(1);
|
||||
await expect(second).toHaveAttribute("aria-selected", "true");
|
||||
|
||||
await page.keyboard.press("Alt+Shift+BracketLeft");
|
||||
await expect(first).toHaveAttribute("aria-selected", "true");
|
||||
|
||||
await page.keyboard.press("Alt+Shift+BracketRight");
|
||||
await expect(second).toHaveAttribute("aria-selected", "true");
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
@@ -226,6 +226,20 @@ describe("keyboard-shortcuts", () => {
|
||||
action: "workspace.tab.navigate.relative",
|
||||
payload: { delta: 1 },
|
||||
},
|
||||
{
|
||||
name: "matches tab relative navigation on macOS desktop via Cmd+Shift+[",
|
||||
event: { key: "{", code: "BracketLeft", metaKey: true, shiftKey: true },
|
||||
context: { isMac: true, usesDesktopBindings: true },
|
||||
action: "workspace.tab.navigate.relative",
|
||||
payload: { delta: -1 },
|
||||
},
|
||||
{
|
||||
name: "matches tab relative navigation on macOS desktop via Cmd+Shift+]",
|
||||
event: { key: "}", code: "BracketRight", metaKey: true, shiftKey: true },
|
||||
context: { isMac: true, usesDesktopBindings: true },
|
||||
action: "workspace.tab.navigate.relative",
|
||||
payload: { delta: 1 },
|
||||
},
|
||||
{
|
||||
name: "matches Mod+T to open new tab",
|
||||
event: { key: "t", code: "KeyT", metaKey: true },
|
||||
@@ -479,6 +493,11 @@ describe("keyboard-shortcuts", () => {
|
||||
event: { key: "w", code: "KeyW", ctrlKey: true },
|
||||
context: { isMac: false, usesDesktopBindings: true, focusScope: "terminal" },
|
||||
},
|
||||
{
|
||||
name: "does not switch tabs with Alt+Shift+] on mac desktop (Cmd+Shift+] only)",
|
||||
event: { key: "’", code: "BracketRight", altKey: true, shiftKey: true },
|
||||
context: { isMac: true, usesDesktopBindings: true },
|
||||
},
|
||||
{
|
||||
name: "does not match Ctrl+T on mac (Cmd only)",
|
||||
event: { key: "t", code: "KeyT", ctrlKey: true },
|
||||
@@ -1306,6 +1325,17 @@ describe("unassigned shortcuts", () => {
|
||||
expect(getBindingIdForAction("workspace-tab-new", desktopNonMac)).toBe(TAB_NEW_BINDING);
|
||||
});
|
||||
|
||||
it("advertises Cmd+Shift+brackets for tab navigation on macOS desktop", () => {
|
||||
const desktopMac = { isMac: true, usesDesktopBindings: true };
|
||||
|
||||
expect(getDefaultKeysForAction("workspace-tab-prev", desktopMac)).toEqual([
|
||||
["mod", "shift", "["],
|
||||
]);
|
||||
expect(getDefaultKeysForAction("workspace-tab-next", desktopMac)).toEqual([
|
||||
["mod", "shift", "]"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("still lists the default keys when nothing is overridden", () => {
|
||||
const sections = buildKeyboardShortcutHelpSections(desktopNonMac);
|
||||
|
||||
|
||||
@@ -715,11 +715,37 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
||||
},
|
||||
|
||||
// --- Tab relative navigation ---
|
||||
// macOS desktop uses Cmd+Shift+brackets; the browser owns those keys, so
|
||||
// macOS web keeps Alt+Shift alongside every non-mac platform.
|
||||
{
|
||||
id: "workspace-tab-navigate-relative-cmd-shift-left-mac",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Cmd+Shift+[",
|
||||
when: { mac: true, desktopBindings: true, commandCenter: false },
|
||||
payload: { type: "delta", delta: -1 },
|
||||
help: {
|
||||
id: "workspace-tab-prev",
|
||||
section: "tabs-panes",
|
||||
label: "Previous tab",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "workspace-tab-navigate-relative-cmd-shift-right-mac",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Cmd+Shift+]",
|
||||
when: { mac: true, desktopBindings: true, commandCenter: false },
|
||||
payload: { type: "delta", delta: 1 },
|
||||
help: {
|
||||
id: "workspace-tab-next",
|
||||
section: "tabs-panes",
|
||||
label: "Next tab",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "workspace-tab-navigate-relative-alt-shift-left",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Alt+Shift+[",
|
||||
when: { commandCenter: false },
|
||||
when: { mac: false, commandCenter: false },
|
||||
payload: { type: "delta", delta: -1 },
|
||||
help: {
|
||||
id: "workspace-tab-prev",
|
||||
@@ -731,7 +757,31 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
||||
id: "workspace-tab-navigate-relative-alt-shift-right",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Alt+Shift+]",
|
||||
when: { commandCenter: false },
|
||||
when: { mac: false, commandCenter: false },
|
||||
payload: { type: "delta", delta: 1 },
|
||||
help: {
|
||||
id: "workspace-tab-next",
|
||||
section: "tabs-panes",
|
||||
label: "Next tab",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "workspace-tab-navigate-relative-alt-shift-left-mac-web",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Alt+Shift+[",
|
||||
when: { mac: true, desktopBindings: false, commandCenter: false },
|
||||
payload: { type: "delta", delta: -1 },
|
||||
help: {
|
||||
id: "workspace-tab-prev",
|
||||
section: "tabs-panes",
|
||||
label: "Previous tab",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "workspace-tab-navigate-relative-alt-shift-right-mac-web",
|
||||
action: "workspace.tab.navigate.relative",
|
||||
combo: "Alt+Shift+]",
|
||||
when: { mac: true, desktopBindings: false, commandCenter: false },
|
||||
payload: { type: "delta", delta: 1 },
|
||||
help: {
|
||||
id: "workspace-tab-next",
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { test, expect } from "../../app/e2e/support/fixtures";
|
||||
import { clickNewTerminal, gotoWorkspace } from "../../app/e2e/support/helpers/launcher";
|
||||
import { seedWorkspace } from "../../app/e2e/support/helpers/seed-client";
|
||||
import { waitForWorkspaceTabsVisible } from "../../app/e2e/support/helpers/workspace-tabs";
|
||||
|
||||
// macOS desktop switches tabs with Cmd+Shift+brackets, like other Mac apps.
|
||||
// Web keeps Alt+Shift (the browser owns Cmd+Shift+brackets) and is covered in
|
||||
// the app browser suite. Windows/Linux desktop can't be emulated here: shortcut
|
||||
// OS detection falls back to the host user agent for non-darwin bridges.
|
||||
|
||||
async function installMacDesktopBridge(page: Page): Promise<void> {
|
||||
await page.addInitScript(() => {
|
||||
window.paseoDesktop = {
|
||||
platform: "darwin",
|
||||
events: { on: () => () => {} },
|
||||
invoke: async (command: string) => {
|
||||
if (command === "get_desktop_settings") {
|
||||
return {
|
||||
releaseChannel: "stable",
|
||||
daemon: { manageBuiltInDaemon: false, keepRunningAfterQuit: true },
|
||||
};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const terminalTabs = (page: Page) =>
|
||||
page.locator('[data-testid^="workspace-tab-terminal_"]').filter({ visible: true });
|
||||
|
||||
async function openTwoTerminalTabs(page: Page) {
|
||||
await waitForWorkspaceTabsVisible(page);
|
||||
await clickNewTerminal(page);
|
||||
await expect(terminalTabs(page)).toHaveCount(1, { timeout: 30_000 });
|
||||
await clickNewTerminal(page);
|
||||
await expect(terminalTabs(page)).toHaveCount(2, { timeout: 30_000 });
|
||||
const first = terminalTabs(page).nth(0);
|
||||
const second = terminalTabs(page).nth(1);
|
||||
await expect(second).toHaveAttribute("aria-selected", "true");
|
||||
return { first, second };
|
||||
}
|
||||
|
||||
test.describe("Previous/next tab shortcuts on desktop", () => {
|
||||
test("macOS desktop switches tabs with Cmd+Shift+[ and ], not Alt+Shift", async ({ page }) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "tab-relative-mac-desktop-" });
|
||||
try {
|
||||
await installMacDesktopBridge(page);
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
const { first, second } = await openTwoTerminalTabs(page);
|
||||
|
||||
await page.keyboard.press("Meta+Shift+BracketLeft");
|
||||
await expect(first).toHaveAttribute("aria-selected", "true");
|
||||
|
||||
await page.keyboard.press("Meta+Shift+BracketRight");
|
||||
await expect(second).toHaveAttribute("aria-selected", "true");
|
||||
|
||||
// Alt+Shift is the web and Windows/Linux binding and must not fire here.
|
||||
// Had it moved to the first tab, Cmd+Shift+[ would wrap back to the second.
|
||||
await page.keyboard.press("Alt+Shift+BracketLeft");
|
||||
await page.keyboard.press("Meta+Shift+BracketLeft");
|
||||
await expect(first).toHaveAttribute("aria-selected", "true");
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user