diff --git a/apps/desktop/src/renderer/hotkeys/registry.ts b/apps/desktop/src/renderer/hotkeys/registry.ts index 27d19256aa6..cb9aadf4517 100644 --- a/apps/desktop/src/renderer/hotkeys/registry.ts +++ b/apps/desktop/src/renderer/hotkeys/registry.ts @@ -186,14 +186,16 @@ export const HOTKEYS_REGISTRY = { label: "Toggle Changes Tab", category: "Layout", }, - TOGGLE_EXPAND_SIDEBAR: { + OPEN_DIFF_VIEWER: { key: { mac: "meta+shift+l", windows: "ctrl+shift+alt+l", linux: "ctrl+shift+alt+l", }, - label: "Toggle Expand Sidebar", + label: "Open Diff Viewer", category: "Layout", + description: + "Open the diff viewer in a new tab, or focus the existing diff viewer", }, TOGGLE_WORKSPACE_SIDEBAR: { key: { mac: "meta+b", windows: "ctrl+shift+b", linux: "ctrl+shift+b" }, diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts index 83308f52a08..205a334364c 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts @@ -12,6 +12,7 @@ import type { StoreApi } from "zustand"; import type { BrowserPaneData, ChatPaneData, + DiffPaneData, PaneViewerData, TerminalPaneData, } from "../../types"; @@ -70,6 +71,33 @@ export function useWorkspaceHotkeys({ }); }); + useHotkey("OPEN_DIFF_VIEWER", () => { + if (collections.v2WorkspaceLocalState.get(workspaceId)) { + collections.v2WorkspaceLocalState.update(workspaceId, (draft) => { + draft.rightSidebarOpen = true; + draft.sidebarState.activeTab = "changes"; + }); + } + + const state = store.getState(); + for (const tab of state.tabs) { + for (const pane of Object.values(tab.panes)) { + if (pane.kind !== "diff") continue; + state.setActiveTab(tab.id); + state.setActivePane({ tabId: tab.id, paneId: pane.id }); + return; + } + } + state.addTab({ + panes: [ + { + kind: "diff", + data: { path: "", collapsedFiles: [] } as DiffPaneData, + }, + ], + }); + }); + // --- Tab management --- const isClosingPaneRef = useRef(false); diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx index b5cfdee609d..6288cab9459 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx @@ -330,8 +330,8 @@ function WorkspacePage() { // Toggle changes sidebar (⌘L) useHotkey("TOGGLE_SIDEBAR", () => toggleSidebar()); - // Toggle expand/collapse sidebar (⌘⇧L) - useHotkey("TOGGLE_EXPAND_SIDEBAR", () => { + // Open diff viewer (⌘⇧L) + useHotkey("OPEN_DIFF_VIEWER", () => { if (!isSidebarOpen) { setSidebarOpen(true); setSidebarMode(SidebarMode.Changes); diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx index 11df11e195c..55ec2680787 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx @@ -198,7 +198,7 @@ export function RightSidebar() {