🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: add branch name copy action (#18911)
Arvin Xuef6f478c2c4a
diff --git a/apps/desktop/src/main/menus/impls/macOS.test.ts b/apps/desktop/src/main/menus/impls/macOS.test.tsindex c8f23805076..49c292f88b8 100644--- a/apps/desktop/src/main/menus/impls/macOS.test.ts+++ b/apps/desktop/src/main/menus/impls/macOS.test.ts@@ -235,6 +235,9 @@ describe('MacOSMenu', () => {expect(preferencesItem).toBeDefined();await preferencesItem.click();expect(mockApp.browserManager.getMainWindow).toHaveBeenCalled();+ const mainWindow = (mockApp.browserManager.getMainWindow as any).mock.results[0].value;+ expect(mainWindow.show).toHaveBeenCalled();+ expect(mainWindow.broadcast).toHaveBeenCalledWith('createNewTab', { path: '/settings' });});it('should handle visit website click', async () => {diff --git a/apps/desktop/src/main/menus/impls/macOS.ts b/apps/desktop/src/main/menus/impls/macOS.tsindex 50ad1cde620..6a5b1c75092 100644--- a/apps/desktop/src/main/menus/impls/macOS.ts+++ b/apps/desktop/src/main/menus/impls/macOS.ts@@ -92,7 +92,7 @@ export class MacOSMenu extends BaseMenuPlatform implements IMenuPlatform {click: async () => {const mainWindow = this.app.browserManager.getMainWindow();mainWindow.show();- mainWindow.broadcast('navigate', { path: '/settings' });+ mainWindow.broadcast('createNewTab', { path: '/settings' });},label: t('macOS.preferences'),},diff --git a/packages/electron-client-ipc/src/events/navigation.ts b/packages/electron-client-ipc/src/events/navigation.tsindex bb1fcfd71f0..bc1aa43b941 100644--- a/packages/electron-client-ipc/src/events/navigation.ts+++ b/packages/electron-client-ipc/src/events/navigation.ts@@ -24,10 +24,10 @@ export interface NavigationBroadcastEvents {createNewPage: () => void;/**- * Ask renderer to open a new tab based on the currently active tab's context.- * Triggered by Cmd/Ctrl+T on the main window.+ * Ask renderer to open a new tab, optionally at a specific path.+ * Triggered by Cmd/Ctrl+T on the main window and menu actions that need a fresh tab.*/- createNewTab: () => void;+ createNewTab: (data?: { path: string }) => void;/*** Ask renderer to create a new topic (start a new conversation).diff --git a/src/features/ChatInput/ControlBar/BranchSwitcher.tsx b/src/features/ChatInput/ControlBar/BranchSwitcher.tsxindex e553860c288..f4d68608993 100644--- a/src/features/ChatInput/ControlBar/BranchSwitcher.tsx+++ b/src/features/ChatInput/ControlBar/BranchSwitcher.tsx@@ -1,5 +1,5 @@import type { DeviceGitWorktreeListItem } from '@lobechat/types';-import { Icon, Input, Tooltip } from '@lobehub/ui';+import { copyToClipboard, Icon, Input, Tooltip } from '@lobehub/ui';import {confirmModal,DropdownMenuItem,@@ -13,6 +13,7 @@ import {import { createStaticStyles, cssVar, cx } from 'antd-style';import {CheckIcon,+ CopyIcon,GitBranchIcon,GitBranchPlusIcon,GitForkIcon,@@ -434,6 +435,19 @@ const BranchSwitcher = memo<BranchSwitcherProps>([deviceId, onAfterCheckout, onOpenChange, path, t],);+ const handleCopy = useCallback(+ async (event: MouseEvent, branch: string) => {+ event.stopPropagation();+ try {+ await copyToClipboard(branch);+ toast.success(tCommon('copySuccess'));+ } catch {+ toast.error(tCommon('copyFail'));+ }+ },+ [tCommon],+ );+// Delete a branch behind a destructive confirm. git rejects deleting the// checked-out branch, so the action is hidden for the current branch.const handleDelete = useCallback(@@ -554,6 +568,16 @@ const BranchSwitcher = memo<BranchSwitcherProps>(/>)}<div className={cx('branch-row-actions', styles.rowActions)}>+ <Tooltip title={tCommon('copy')}>+ <div+ aria-label={tCommon('copy')}+ className={styles.rowAction}+ role="button"+ onClick={(e) => void handleCopy(e, branch.name)}+ >+ <Icon icon={CopyIcon} size={13} />+ </div>+ </Tooltip><Tooltip title={t('workingDirectory.renameBranchAction')}><divclassName={styles.rowAction}diff --git a/src/features/Electron/titlebar/TabBar/index.tsx b/src/features/Electron/titlebar/TabBar/index.tsxindex a0289beb125..a02a64ddadd 100644--- a/src/features/Electron/titlebar/TabBar/index.tsx+++ b/src/features/Electron/titlebar/TabBar/index.tsx@@ -200,15 +200,18 @@ const TabBar = () => {}});- const handleNewTab = useCallback(() => {- if (!canCreate) return;+ const handleNewTab = useCallback(+ (path?: string) => {+ if (!canCreate) return;- // Always open a fresh Home tab, even if a Home tab already exists.- addNewTab(newTabUrl);- }, [canCreate, addNewTab, newTabUrl]);+ // Always open a fresh tab, even if one with the same target already exists.+ addNewTab(path ?? newTabUrl);+ },+ [canCreate, addNewTab, newTabUrl],+ );- useWatchBroadcast('createNewTab', () => {- handleNewTab();+ useWatchBroadcast('createNewTab', (data) => {+ handleNewTab(data?.path);});const overflowItems = useCallback((): DropdownItem[] => {@@ -285,7 +288,7 @@ const TabBar = () => {icon={Plus}size="small"title={canCreate ? t('tab.newTab') : reason}- onClick={canCreate ? handleNewTab : undefined}+ onClick={canCreate ? () => handleNewTab() : undefined}/>{layout.hiddenCount > 0 && (<DropdownMenu items={overflowItems} placement={'bottomRight'}>