feat(desktop): add zen mode toggle for data tabs

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-27 17:59:10 +08:00
1 parent 955558c81f
commit 214bf86a6f
16 files changed
+105 -9

No files matched your search

@@ -55,7 +55,20 @@ describe("right sidebar panel entry points", () => {
expect(appSource).toContain(':maximized="isAiPanelMaximized"');
expect(appSource).toContain('@toggle-maximize="toggleAiPanelMaximized"');
expect(appSource).toContain("isAiPanelMaximized ? 'min-w-0 flex-1' : 'min-w-[180px] max-w-full'");
expect(appSource).toContain('v-show="!isAiPanelMaximized"');
expect(appSource).toContain('v-show="!isAiPanelMaximized && !isZenMode"');
expect(functionSource("setRightSidebarPanelOpen", "toggleRightSidebarPanel")).toContain("isAiPanelMaximized.value = false;");
});
it("keeps Zen mode as a temporary data-tab layout", () => {
expect(appSource).toContain("const isZenMode = ref(false);");
expect(appSource).toContain('if (mode !== "data") isZenMode.value = false;');
expect(appSource).toContain("function toggleZenMode() {");
expect(appSource).toContain('if (activeTab.value?.mode !== "data") return;');
expect(appSource).toContain('isToggleZenModeShortcut(e, shortcuts) && activeTab.value?.mode === "data"');
expect(appSource).toContain('@toggle-zen-mode="toggleZenMode"');
expect(appSource).toContain('v-show="sidebarOpen && !isZenMode"');
expect(appSource).toContain('v-show="!sidebarOpen && !isZenMode"');
expect(appSource).toContain('v-show="!isAiPanelMaximized || isZenMode"');
expect(appSource).toContain('v-show="!isZenMode"');
});
});
@@ -9,6 +9,7 @@ import {
isGoToLastPageShortcut,
isGoToNextPageShortcut,
isGoToPreviousPageShortcut,
isToggleZenModeShortcut,
matchesModifierOnlyShortcut,
matchesShortcut,
tabSwitcherDirectionFromShortcut,
@@ -98,6 +99,14 @@ describe("keyboard shortcut matching", () => {
expect(isExecuteSqlInNewResultTabShortcut({ key: "\\", metaKey: true }, { executeSqlInNewResultTab: "Mod+\\" })).toBe(true);
});
it("matches the configurable Zen mode shortcut", () => {
const platformModEvent = isMacShortcutPlatform() ? { key: "F12", metaKey: true, shiftKey: true } : { key: "F12", ctrlKey: true, shiftKey: true };
expect(isToggleZenModeShortcut(platformModEvent, { toggleZenMode: "Shift+Mod+F12" })).toBe(true);
expect(isToggleZenModeShortcut({ ...platformModEvent, shiftKey: false }, { toggleZenMode: "Shift+Mod+F12" })).toBe(false);
expect(isToggleZenModeShortcut(platformModEvent, { toggleZenMode: "" })).toBe(false);
});
it("matches legacy plus-key shortcuts saved with plus as a separator", () => {
expect(matchesShortcut({ key: "+", ctrlKey: true }, "Mod++", "Win32")).toBe(true);
expect(matchesShortcut({ key: "+", ctrlKey: true, shiftKey: true }, "Shift+Mod++", "Win32")).toBe(true);
@@ -146,6 +146,14 @@ describe("shortcutRegistry editor actions", () => {
expect(findShortcutConflict("find", DEFAULT_SHORTCUT_SETTINGS.find, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
});
it("registers a conflict-free global shortcut for Zen mode", () => {
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "toggleZenMode");
expect(definition).toMatchObject({ labelKey: "settings.shortcutToggleZenMode", scope: "global", defaultShortcut: "Shift+Mod+F12" });
expect(DEFAULT_SHORTCUT_SETTINGS.toggleZenMode).toBe("Shift+Mod+F12");
expect(findShortcutConflict("toggleZenMode", DEFAULT_SHORTCUT_SETTINGS.toggleZenMode, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
});
it("uses Shift+Enter for inserting a complete line below", () => {
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "insertLineBelow");
@@ -246,6 +246,10 @@ export function isToggleSidebarShortcut(event: ShortcutLikeEvent, shortcuts?: Pa
return matchesShortcut(event, actionShortcut("toggleSidebar", shortcuts));
}
export function isToggleZenModeShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("toggleZenMode", shortcuts));
}
export function isCopySidebarSelectionShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("copySidebarSelection", shortcuts));
}
@@ -66,6 +66,7 @@ export type ShortcutActionId =
| "toggleTranspose"
| "cancelSearch"
| "toggleSidebar"
| "toggleZenMode"
| "copySidebarSelection"
| "pasteSidebarSelection"
| "editSidebarConnection"
@@ -503,6 +504,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "global",
defaultShortcut: "Mod+B",
},
{
id: "toggleZenMode",
labelKey: "settings.shortcutToggleZenMode",
scope: "global",
defaultShortcut: "Shift+Mod+F12",
},
{
id: "copySidebarSelection",
labelKey: "settings.shortcutCopySidebarSelection",