Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(hotkey): add Mod+1–9 and Ctrl+Tab desktop tab switching shortcuts (#16147)

Arvin Xub675dd26c5ea
diff --git a/locales/en-US/hotkey.json b/locales/en-US/hotkey.json
index 56a0e9c669f..58e58c2bf3b 100644
--- a/locales/en-US/hotkey.json
+++ b/locales/en-US/hotkey.json
@@ -19,10 +19,14 @@
"editMessage.title": "Edit Message",
"navigateToChat.desc": "Switch to the Chat tab and enter Lobe AI",
"navigateToChat.title": "Switch to Default Chat",
+ "nextTab.desc": "Cycle to the next browser-style tab in the Desktop app; wraps around to the first tab at the end",
+ "nextTab.title": "Next Tab",
"openChatSettings.desc": "View and modify the settings for the current conversation",
"openChatSettings.title": "Open Chat Settings",
"openHotkeyHelper.desc": "View instructions for all keyboard shortcuts",
"openHotkeyHelper.title": "Open Hotkey Help",
+ "prevTab.desc": "Cycle to the previous tab in the Desktop app; wraps around to the last tab at the beginning",
+ "prevTab.title": "Previous Tab",
"regenerateMessage.desc": "Regenerate the last message",
"regenerateMessage.title": "Regenerate Message",
"saveDocument.desc": "Save all changes to the current page immediately",
@@ -35,6 +39,8 @@
"showApp.title": "Show Main Window",
"switchAgent.desc": "Switch between pinned agents in the sidebar by holding Ctrl and pressing numbers 0-9",
"switchAgent.title": "Quick Switch Agent",
+ "switchTab.desc": "Jump to a specific tab by its position (1–9) in the Desktop app tab bar",
+ "switchTab.title": "Switch to Tab by Number",
"toggleLeftPanel.desc": "Show or hide the left panel",
"toggleLeftPanel.title": "Toggle Left Panel",
"toggleRightPanel.desc": "Show or hide the right panel",
diff --git a/locales/zh-CN/hotkey.json b/locales/zh-CN/hotkey.json
index 6ac063772e6..e3d1ed6104f 100644
--- a/locales/zh-CN/hotkey.json
+++ b/locales/zh-CN/hotkey.json
@@ -19,10 +19,14 @@
"editMessage.title": "编辑消息",
"navigateToChat.desc": "切换至会话标签并进入Lobe AI",
"navigateToChat.title": "切换至默认会话",
+ "nextTab.desc": "在桌面端标签页之间循环切换,到达末尾后跳回第一个标签页",
+ "nextTab.title": "下一个标签页",
"openChatSettings.desc": "查看和修改当前会话的设置",
"openChatSettings.title": "打开会话设置",
"openHotkeyHelper.desc": "查看所有快捷键的使用说明",
"openHotkeyHelper.title": "打开快捷键帮助",
+ "prevTab.desc": "在桌面端标签页之间反向循环切换,到达开头后跳回最后一个标签页",
+ "prevTab.title": "上一个标签页",
"regenerateMessage.desc": "重新生成最后一条消息",
"regenerateMessage.title": "重新生成消息",
"saveDocument.desc": "立即保存当前文档的所有更改",
@@ -35,6 +39,8 @@
"showApp.title": "显示主窗口",
"switchAgent.desc": "通过按住 Ctrl 加数字 0~9 切换固定在侧边栏的助理",
"switchAgent.title": "快捷切换助理",
+ "switchTab.desc": "通过按住 ⌘/Ctrl 加数字 1~9 跳转到对应位置的标签页",
+ "switchTab.title": "按编号切换标签页",
"toggleLeftPanel.desc": "显示或隐藏左侧面板",
"toggleLeftPanel.title": "显示/隐藏左侧面板",
"toggleRightPanel.desc": "显示或隐藏右侧面板",
diff --git a/packages/const/src/hotkeys.ts b/packages/const/src/hotkeys.ts
index a64dd1e2016..22bfc8562d5 100644
--- a/packages/const/src/hotkeys.ts
+++ b/packages/const/src/hotkeys.ts
@@ -46,7 +46,9 @@ export const HotkeyEnum = {
DeleteLastMessage: 'deleteLastMessage',
EditMessage: 'editMessage',
NavigateToChat: 'navigateToChat',
+ NextTab: 'nextTab',
OpenChatSettings: 'openChatSettings',
+ PrevTab: 'prevTab',
OpenHotkeyHelper: 'openHotkeyHelper',
RegenerateMessage: 'regenerateMessage',
SaveDocument: 'saveDocument',
@@ -54,6 +56,7 @@ export const HotkeyEnum = {
Search: 'search',
ShowApp: 'showApp',
SwitchAgent: 'switchAgent',
+ SwitchTab: 'switchTab',
ToggleLeftPanel: 'toggleLeftPanel',
ToggleRightPanel: 'toggleRightPanel',
} as const satisfies Record<string, HotkeyId>;
@@ -92,6 +95,27 @@ export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
nonEditable: true,
scopes: [HotkeyScopeEnum.Global],
},
+ {
+ group: HotkeyGroupEnum.Essential,
+ id: HotkeyEnum.SwitchTab,
+ keys: combineKeys([KeyEnum.Mod, KeyEnum.Number]),
+ nonEditable: true,
+ scopes: [HotkeyScopeEnum.Global],
+ },
+ {
+ group: HotkeyGroupEnum.Essential,
+ id: HotkeyEnum.NextTab,
+ keys: combineKeys([KeyEnum.Ctrl, KeyEnum.Tab]),
+ nonEditable: true,
+ scopes: [HotkeyScopeEnum.Global],
+ },
+ {
+ group: HotkeyGroupEnum.Essential,
+ id: HotkeyEnum.PrevTab,
+ keys: combineKeys([KeyEnum.Ctrl, KeyEnum.Shift, KeyEnum.Tab]),
+ nonEditable: true,
+ scopes: [HotkeyScopeEnum.Global],
+ },
{
group: HotkeyGroupEnum.Essential,
id: HotkeyEnum.NavigateToChat,
diff --git a/packages/locales/src/default/hotkey.ts b/packages/locales/src/default/hotkey.ts
index c5529d204d4..9c627e2bcfa 100644
--- a/packages/locales/src/default/hotkey.ts
+++ b/packages/locales/src/default/hotkey.ts
@@ -19,8 +19,14 @@ export default {
'editMessage.title': 'Edit Message',
'navigateToChat.desc': 'Switch to the Chat tab and enter Lobe AI',
'navigateToChat.title': 'Switch to Default Chat',
+ 'nextTab.desc':
+ 'Cycle to the next browser-style tab in the Desktop app; wraps around to the first tab at the end',
+ 'nextTab.title': 'Next Tab',
'openChatSettings.desc': 'View and modify the settings for the current conversation',
'openChatSettings.title': 'Open Chat Settings',
+ 'prevTab.desc':
+ 'Cycle to the previous tab in the Desktop app; wraps around to the last tab at the beginning',
+ 'prevTab.title': 'Previous Tab',
'openHotkeyHelper.desc': 'View instructions for all keyboard shortcuts',
'openHotkeyHelper.title': 'Open Hotkey Help',
'regenerateMessage.desc': 'Regenerate the last message',
@@ -36,6 +42,8 @@ export default {
'switchAgent.desc':
'Switch between pinned agents in the sidebar by holding Ctrl and pressing numbers 0-9',
'switchAgent.title': 'Quick Switch Agent',
+ 'switchTab.desc': 'Jump to a specific tab by its position (1–9) in the Desktop app tab bar',
+ 'switchTab.title': 'Switch to Tab by Number',
'toggleLeftPanel.desc': 'Show or hide the left panel',
'toggleLeftPanel.title': 'Toggle Left Panel',
'toggleRightPanel.desc': 'Show or hide the right panel',
diff --git a/packages/types/src/hotkey.ts b/packages/types/src/hotkey.ts
index 15c02dd6536..5a389b7fed3 100644
--- a/packages/types/src/hotkey.ts
+++ b/packages/types/src/hotkey.ts
@@ -5,7 +5,9 @@ export type HotkeyId =
| 'deleteLastMessage'
| 'editMessage'
| 'navigateToChat'
+ | 'nextTab'
| 'openChatSettings'
+ | 'prevTab'
| 'openHotkeyHelper'
| 'regenerateMessage'
| 'saveDocument'
@@ -13,6 +15,7 @@ export type HotkeyId =
| 'search'
| 'showApp'
| 'switchAgent'
+ | 'switchTab'
| 'toggleLeftPanel'
| 'toggleRightPanel';
diff --git a/src/features/Electron/titlebar/TabBar/index.tsx b/src/features/Electron/titlebar/TabBar/index.tsx
index cd0c9fbf008..921cc658161 100644
--- a/src/features/Electron/titlebar/TabBar/index.tsx
+++ b/src/features/Electron/titlebar/TabBar/index.tsx
@@ -19,6 +19,7 @@ import { startTransition, useCallback, useEffect, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useRegisterDesktopTabHotkeys } from '@/hooks/useHotkeys/desktopTabScope';
import { usePermission } from '@/hooks/usePermission';
import { electronSystemService } from '@/services/electron/system';
import { useElectronStore } from '@/store/electron';
@@ -40,6 +41,7 @@ const restrictToHorizontalAxis: Modifier = ({ transform }) => ({ ...transform, y
const TabBar = () => {
const styles = useStyles;
const navigate = useWorkspaceAwareNavigate();
+ useRegisterDesktopTabHotkeys();
const { t } = useTranslation('electron');
const { allowed: canCreate, reason } = usePermission('create_content');
const viewportRef = useRef<HTMLDivElement>(null);
diff --git a/src/hooks/useHotkeys/desktopTabScope.ts b/src/hooks/useHotkeys/desktopTabScope.ts
new file mode 100644
index 00000000000..9b458974910
--- /dev/null
+++ b/src/hooks/useHotkeys/desktopTabScope.ts
@@ -0,0 +1,89 @@
+'use client';
+
+import { useCallback } from 'react';
+import { useHotkeys } from 'react-hotkeys-hook';
+
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useElectronStore } from '@/store/electron';
+
+/**
+ * Mod+1–9: jump to the Nth tab.
+ * Ctrl+Tab: cycle to the next tab, wrapping around.
+ * Ctrl+Shift+Tab: cycle to the previous tab, wrapping around.
+ *
+ * Must be called from a component that only renders in the Desktop app
+ * (e.g. TabBar) — no `isDesktop` guard needed.
+ */
+export const useRegisterDesktopTabHotkeys = () => {
+ const navigate = useWorkspaceAwareNavigate();
+
+ const switchToTabByIndex = useCallback(
+ (index: number) => {
+ const { tabs, activateTab } = useElectronStore.getState();
+ if (index < 0 || index >= tabs.length) return;
+
+ const target = tabs[index];
+ activateTab(target.id);
+ navigate(target.url);
+ },
+ [navigate],
+ );
+
+ // Mod+1 through Mod+9
+ useHotkeys(
+ 'mod+1,mod+2,mod+3,mod+4,mod+5,mod+6,mod+7,mod+8,mod+9',
+ (e) => {
+ e.preventDefault();
+ const digit = Number(e.key);
+ if (digit >= 1 && digit <= 9) {
+ switchToTabByIndex(digit - 1);
+ }
+ },
+ {
+ enableOnFormTags: true,
+ preventDefault: true,
+ },
+ );
+
+ // Ctrl+Tab: next tab (wrap around)
+ useHotkeys(
+ 'ctrl+tab',
+ (e) => {
+ e.preventDefault();
+ const { tabs, activeTabId, activateTab } = useElectronStore.getState();
+ if (tabs.length === 0) return;
+
+ const currentIndex = tabs.findIndex((t) => t.id === activeTabId);
+ const nextIndex = (currentIndex + 1) % tabs.length;
+ const target = tabs[nextIndex];
+
+ activateTab(target.id);
+ navigate(target.url);
+ },
+ {
+ enableOnFormTags: true,
+ preventDefault: true,
+ },
+ );
+
+ // Ctrl+Shift+Tab: previous tab (wrap around)
+ useHotkeys(
+ 'ctrl+shift+tab',
+ (e) => {
+ e.preventDefault();
+ const { tabs, activeTabId, activateTab } = useElectronStore.getState();
+ if (tabs.length === 0) return;
+
+ const currentIndex = tabs.findIndex((t) => t.id === activeTabId);
+ const prevIndex = (currentIndex - 1 + tabs.length) % tabs.length;
+ const target = tabs[prevIndex];
+
+ activateTab(target.id);
+ navigate(target.url);
+ },
+ {
+ enableOnFormTags: true,
+ preventDefault: true,
+ },
+ );
+};