feat(keyboard): add Cmd+./Ctrl+. shortcut to toggle both sidebars
Reassign Cmd+. (Mac) and Ctrl+. (Win/Linux) from toggling the left sidebar to toggling both sidebars at once. If either is open, both close; if both are closed, both open. Left sidebar toggle on non-Mac now uses Ctrl+B to match the Mac Cmd+B binding.
This commit is contained in:
@@ -264,6 +264,7 @@ function AppContainer({
|
|||||||
const daemons = useHosts();
|
const daemons = useHosts();
|
||||||
const toggleAgentList = usePanelStore((state) => state.toggleAgentList);
|
const toggleAgentList = usePanelStore((state) => state.toggleAgentList);
|
||||||
const toggleFileExplorer = usePanelStore((state) => state.toggleFileExplorer);
|
const toggleFileExplorer = usePanelStore((state) => state.toggleFileExplorer);
|
||||||
|
const toggleBothSidebars = usePanelStore((state) => state.toggleBothSidebars);
|
||||||
|
|
||||||
const isMobile = UnistylesRuntime.breakpoint === "xs" || UnistylesRuntime.breakpoint === "sm";
|
const isMobile = UnistylesRuntime.breakpoint === "xs" || UnistylesRuntime.breakpoint === "sm";
|
||||||
const chromeEnabled = chromeEnabledOverride ?? daemons.length > 0;
|
const chromeEnabled = chromeEnabledOverride ?? daemons.length > 0;
|
||||||
@@ -274,6 +275,7 @@ function AppContainer({
|
|||||||
toggleAgentList,
|
toggleAgentList,
|
||||||
selectedAgentId,
|
selectedAgentId,
|
||||||
toggleFileExplorer,
|
toggleFileExplorer,
|
||||||
|
toggleBothSidebars,
|
||||||
});
|
});
|
||||||
|
|
||||||
const containerStyle = useMemo(
|
const containerStyle = useMemo(
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ export function useKeyboardShortcuts({
|
|||||||
toggleAgentList,
|
toggleAgentList,
|
||||||
selectedAgentId,
|
selectedAgentId,
|
||||||
toggleFileExplorer,
|
toggleFileExplorer,
|
||||||
|
toggleBothSidebars,
|
||||||
}: {
|
}: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
isMobile: boolean;
|
isMobile: boolean;
|
||||||
toggleAgentList: () => void;
|
toggleAgentList: () => void;
|
||||||
selectedAgentId?: string;
|
selectedAgentId?: string;
|
||||||
toggleFileExplorer?: () => void;
|
toggleFileExplorer?: () => void;
|
||||||
|
toggleBothSidebars?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const hosts = useHosts();
|
const hosts = useHosts();
|
||||||
@@ -228,6 +230,11 @@ export function useKeyboardShortcuts({
|
|||||||
case "sidebar.toggle.left":
|
case "sidebar.toggle.left":
|
||||||
toggleAgentList();
|
toggleAgentList();
|
||||||
return true;
|
return true;
|
||||||
|
case "sidebar.toggle.both":
|
||||||
|
if (toggleBothSidebars) {
|
||||||
|
toggleBothSidebars();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case "sidebar.toggle.right":
|
case "sidebar.toggle.right":
|
||||||
if (!toggleFileExplorer) {
|
if (!toggleFileExplorer) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export type KeyboardActionId =
|
|||||||
| "workspace.navigate.relative"
|
| "workspace.navigate.relative"
|
||||||
| "sidebar.toggle.left"
|
| "sidebar.toggle.left"
|
||||||
| "sidebar.toggle.right"
|
| "sidebar.toggle.right"
|
||||||
|
| "sidebar.toggle.both"
|
||||||
| "command-center.toggle"
|
| "command-center.toggle"
|
||||||
| "shortcuts.dialog.toggle"
|
| "shortcuts.dialog.toggle"
|
||||||
| "workspace.terminal.new"
|
| "workspace.terminal.new"
|
||||||
|
|||||||
@@ -649,22 +649,16 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
keys: ["mod", "B"],
|
keys: ["mod", "B"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "sidebar-toggle-left-cmd-period-mac",
|
|
||||||
action: "sidebar.toggle.left",
|
|
||||||
combo: "Cmd+.",
|
|
||||||
when: { mac: true, commandCenter: false },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "sidebar-toggle-left-ctrl-period-non-mac",
|
id: "sidebar-toggle-left-ctrl-period-non-mac",
|
||||||
action: "sidebar.toggle.left",
|
action: "sidebar.toggle.left",
|
||||||
combo: "Ctrl+.",
|
combo: "Ctrl+B",
|
||||||
when: { mac: false, commandCenter: false, terminal: false },
|
when: { mac: false, commandCenter: false, terminal: false },
|
||||||
help: {
|
help: {
|
||||||
id: "toggle-left-sidebar",
|
id: "toggle-left-sidebar",
|
||||||
section: "panels",
|
section: "panels",
|
||||||
label: "Toggle left sidebar",
|
label: "Toggle left sidebar",
|
||||||
keys: ["mod", "."],
|
keys: ["mod", "B"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -698,6 +692,32 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
when: { hasSelectedAgent: true, commandCenter: false },
|
when: { hasSelectedAgent: true, commandCenter: false },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// --- Toggle both sidebars ---
|
||||||
|
{
|
||||||
|
id: "sidebar-toggle-both-cmd-period-mac",
|
||||||
|
action: "sidebar.toggle.both",
|
||||||
|
combo: "Cmd+.",
|
||||||
|
when: { mac: true, commandCenter: false },
|
||||||
|
help: {
|
||||||
|
id: "toggle-both-sidebars",
|
||||||
|
section: "panels",
|
||||||
|
label: "Toggle both sidebars",
|
||||||
|
keys: ["mod", "."],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "sidebar-toggle-both-ctrl-period-non-mac",
|
||||||
|
action: "sidebar.toggle.both",
|
||||||
|
combo: "Ctrl+.",
|
||||||
|
when: { mac: false, commandCenter: false, terminal: false },
|
||||||
|
help: {
|
||||||
|
id: "toggle-both-sidebars",
|
||||||
|
section: "panels",
|
||||||
|
label: "Toggle both sidebars",
|
||||||
|
keys: ["mod", "."],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// --- Message input ---
|
// --- Message input ---
|
||||||
{
|
{
|
||||||
id: "message-input-voice-toggle-cmd-shift-d-mac",
|
id: "message-input-voice-toggle-cmd-shift-d-mac",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ interface PanelState {
|
|||||||
closeToAgent: () => void;
|
closeToAgent: () => void;
|
||||||
toggleAgentList: () => void;
|
toggleAgentList: () => void;
|
||||||
toggleFileExplorer: () => void;
|
toggleFileExplorer: () => void;
|
||||||
|
toggleBothSidebars: () => void;
|
||||||
|
|
||||||
// File explorer settings actions
|
// File explorer settings actions
|
||||||
setExplorerTab: (tab: ExplorerTab) => void;
|
setExplorerTab: (tab: ExplorerTab) => void;
|
||||||
@@ -216,6 +217,24 @@ export const usePanelStore = create<PanelState>()(
|
|||||||
return nextState;
|
return nextState;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
toggleBothSidebars: () =>
|
||||||
|
set((state) => {
|
||||||
|
// If either sidebar is open, close both. Otherwise, open both.
|
||||||
|
const anyOpen = state.desktop.agentListOpen || state.desktop.fileExplorerOpen;
|
||||||
|
if (anyOpen) {
|
||||||
|
return {
|
||||||
|
mobileView: "agent" as MobilePanelView,
|
||||||
|
desktop: { agentListOpen: false, fileExplorerOpen: false },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const resolvedTab = resolveExplorerTabFromActiveCheckout(state);
|
||||||
|
return {
|
||||||
|
mobileView: "agent" as MobilePanelView,
|
||||||
|
desktop: { agentListOpen: true, fileExplorerOpen: true },
|
||||||
|
...(resolvedTab ? { explorerTab: resolvedTab } : {}),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
setExplorerTab: (tab) => set({ explorerTab: tab }),
|
setExplorerTab: (tab) => set({ explorerTab: tab }),
|
||||||
setExplorerTabForCheckout: ({ serverId, cwd, isGit, tab }) =>
|
setExplorerTabForCheckout: ({ serverId, cwd, isGit, tab }) =>
|
||||||
set((state) => {
|
set((state) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user