🤯 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
🐛 fix(desktop): keep Cmd+, settings tab in the active workspace (#22902)
YuTengjinga91c042c8319
diff --git a/src/features/Electron/titlebar/TabBar/index.tsx b/src/features/Electron/titlebar/TabBar/index.tsxindex 286cc780e74..35bc7efe529 100644--- a/src/features/Electron/titlebar/TabBar/index.tsx+++ b/src/features/Electron/titlebar/TabBar/index.tsx@@ -9,7 +9,6 @@ import { useCallback, useEffect, useMemo, useRef } from 'react';import { useTranslation } from 'react-i18next';import { captureVisibleTabPreviews } from '@/features/Electron/TabHost';-import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';import { useActiveLocation } from '@/hooks/useActiveLocation';import { useRegisterDesktopTabHotkeys } from '@/hooks/useHotkeys/desktopTabScope';import { usePermission } from '@/hooks/usePermission';@@ -25,7 +24,7 @@ import { useStripWidth } from './hooks/useStripWidth';import { useTabDrag } from './hooks/useTabDrag';import { TAB_SPRING } from './motion';import { resolveCloseShortcut } from './resolveCloseShortcut';-import { resolveTabScope } from './scope';+import { resolveNewTabUrl } from './scope';import { useStyles } from './styles';import TabItem from './TabItem';import {@@ -133,12 +132,7 @@ const TabBar = () => {followInstantly,]);- const newTabUrl = useMemo(() => {- const scope = resolveTabScope(location.pathname + location.search);- const activeSlug = scope.type === 'workspace' ? scope.slug : null;-- return buildWorkspaceAwarePath(NEW_TAB_URL, activeSlug);- }, [location.pathname, location.search]);+ const activeUrl = location.pathname + location.search;const handleMoveBy = useCallback((id: string, delta: -1 | 1) => {@@ -221,9 +215,9 @@ const TabBar = () => {if (!canCreate) return;// Always open a fresh tab, even if one with the same target already exists.- addNewTab(path ?? newTabUrl);+ addNewTab(resolveNewTabUrl(path ?? NEW_TAB_URL, activeUrl));},- [canCreate, addNewTab, newTabUrl],+ [canCreate, addNewTab, activeUrl],);useWatchBroadcast('createNewTab', (data) => {diff --git a/src/features/Electron/titlebar/TabBar/scope.test.ts b/src/features/Electron/titlebar/TabBar/scope.test.tsindex 6e046668fd3..fcd037bb2bd 100644--- a/src/features/Electron/titlebar/TabBar/scope.test.ts+++ b/src/features/Electron/titlebar/TabBar/scope.test.ts@@ -1,6 +1,12 @@import { describe, expect, it } from 'vitest';-import { isSameTabTarget, normalizeTabScope, resolveTabScope, tabTargetId } from './scope';+import {+ isSameTabTarget,+ normalizeTabScope,+ resolveNewTabUrl,+ resolveTabScope,+ tabTargetId,+} from './scope';describe('desktop tab scope', () => {it('marks known top-level desktop routes as personal scope', () => {@@ -46,4 +52,14 @@ describe('desktop tab scope', () => {it('keeps the historical recent/pinned id as the normalized URL', () => {expect(tabTargetId('/acme/agent/a?b=2&a=1')).toBe('/acme/agent/a?a=1&b=2');});++ // Regression: the macOS Preferences menu (Cmd+,) broadcasts `createNewTab`+ // with a bare `/settings`, which resolved as personal and swapped the whole+ // tab strip out of the workspace.+ it('keeps new tabs in the active workspace scope', () => {+ expect(resolveNewTabUrl('/settings', '/acme/agent/a')).toBe('/acme/settings');+ expect(resolveNewTabUrl('/', '/acme/agent/a')).toBe('/acme/');+ expect(resolveNewTabUrl('/settings', '/agent/a')).toBe('/settings');+ expect(resolveNewTabUrl('/settings/llm', '/acme/agent/a')).toBe('/settings/llm');+ });});diff --git a/src/features/Electron/titlebar/TabBar/scope.ts b/src/features/Electron/titlebar/TabBar/scope.tsindex 182b969ef52..d5a6fd3244a 100644--- a/src/features/Electron/titlebar/TabBar/scope.ts+++ b/src/features/Electron/titlebar/TabBar/scope.ts@@ -1,4 +1,5 @@import { parseRootSegment, RESERVED_ROOT_SEGMENTS } from '@/features/Workspace/rootSegments';+import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';import { normalizeTabUrl } from './url';@@ -28,6 +29,20 @@ export const resolveTabScope = (url: string): TabScope => {return { slug: firstSegment, type: 'workspace' };};+/**+ * Resolve the URL a new tab opens at, keeping it in the scope of the tab the+ * user is looking at. Unprefixed app paths (`/`, or `/settings` sent by the+ * macOS Preferences menu) get the active workspace prefix; without it,+ * `addNewTab` resolves them as personal and swaps the whole strip to the+ * personal bucket. Personal-only paths stay unprefixed.+ */+export const resolveNewTabUrl = (path: string, activeUrl: string): string => {+ const scope = resolveTabScope(activeUrl);+ const activeSlug = scope.type === 'workspace' ? scope.slug : null;++ return buildWorkspaceAwarePath(path, activeSlug);+};+export const tabScopeHomeUrl = (scope: TabScope): string =>scope.type === 'workspace' ? `/${scope.slug}` : '/';